Actions
Bug #23925
closedParameters are not properly intepreted in method call conditions
Pull Request:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
To do
Fix check:
Error - Next version
Regression:
No
Description
The techniques parameters are not defined globally in the technique and so, expressions resolved outside of the bundles and containing a technique parameter reference are never evaluated.
See the technique.cf below:
# @name hfjakhf # @version 1.0 bundle agent hfjakhf(file) { vars: "args" slist => {"${file}"}; "report_param" string => join("_", args); "full_class_prefix" string => canonify("hfjakhf_${report_param}"); "class_prefix" string => string_head("${full_class_prefix}", "1000"); methods: "9e763779-9f33-44bc-ad73-1c5d5732301c_${report_data.directive_id}" usebundle => call_hfjakhf_9e763779_9f33_44bc_ad73_1c5d5732301c("File check exists", "/tmp/${file}", "9e763779-9f33-44bc-ad73-1c5d5732301c", @{args}, "${class_prefix}", "/tmp/${file}"); "e8362340-dc50-4231-9b7f-748b51e9fa07_${report_data.directive_id}" usebundle => call_hfjakhf_e8362340_dc50_4231_9b7f_748b51e9fa07("Command execution", "echo \"oui\"", "e8362340-dc50-4231-9b7f-748b51e9fa07", @{args}, "${class_prefix}", "echo \"oui\""); } bundle agent call_hfjakhf_9e763779_9f33_44bc_ad73_1c5d5732301c(c_name, c_key, report_id, args, class_prefix, path) { methods: "9e763779-9f33-44bc-ad73-1c5d5732301c_${report_data.directive_id}" usebundle => _method_reporting_context_v4("${c_name}", "${c_key}", "${report_id}"); "9e763779-9f33-44bc-ad73-1c5d5732301c_${report_data.directive_id}" usebundle => file_check_exists("${path}"); } bundle agent call_hfjakhf_e8362340_dc50_4231_9b7f_748b51e9fa07(c_name, c_key, report_id, args, class_prefix, command) { methods: "e8362340-dc50-4231-9b7f-748b51e9fa07_${report_data.directive_id}" usebundle => _method_reporting_context_v4("${c_name}", "${c_key}", "${report_id}"); "e8362340-dc50-4231-9b7f-748b51e9fa07_${report_data.directive_id}" usebundle => command_execution("${command}"), if => concat("file_check_exists__tmp_",canonify("${file}"),"_kept"); "e8362340-dc50-4231-9b7f-748b51e9fa07_${report_data.directive_id}" usebundle => _classes_noop(canonify("${class_prefix}_command_execution_${c_key}")), unless => concat("file_check_exists__tmp_",canonify("${file}"),"_kept"); "e8362340-dc50-4231-9b7f-748b51e9fa07_${report_data.directive_id}" usebundle => log_rudder("Skipping method 'Command execution' with key parameter 'echo \"oui\"' since condition 'file_check_exists__tmp_${file}_kept' is not reached", "echo \"oui\"", canonify("${class_prefix}_command_execution_${c_key}"), canonify("${class_prefix}_command_execution_${c_key}"), @{args}), unless => concat("file_check_exists__tmp_",canonify("${file}"),"_kept"); }
Generated from:
id: hfjakhf name: hfjakhf version: '1.0' category: ncf_techniques params: - id: 2f415dc5-9f9e-4fbe-b836-8960af613ec9 name: file description: file constraints: allow_empty: false items: - id: 9e763779-9f33-44bc-ad73-1c5d5732301c name: '' method: file_check_exists params: path: /tmp/${hfjakhf.file} - id: e8362340-dc50-4231-9b7f-748b51e9fa07 name: '' condition: file_check_exists__tmp_${hfjakhf.file}_kept method: command_execution params: command: echo "oui"
The expression unless => concat("file_check_exists__tmp_",canonify("${file}"),"_kept");
will never be checked as the file
variable is not exposed here. It should instead use the long variable name hfjakhf.file
.
A quick workaround is to replace any parameter call in expression with their fully qualified name.
This issue is most likely also impacting expressions refering to the resource_dir
variable.
Actions