Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #20372: there is no validation on the variable name in generic method variable_from_smth #1324

Draft
wants to merge 2 commits into
base: branches/rudder/6.1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tree/30_generic_methods/variable_dict.cf
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
# Be careful that using a global variable can lead to unpredictable content in case of multiple definition, which is implicitly the case when a technique has more than one instance (directive).
# Please note that only global variables are available within templates.
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter value The variable content in JSON format
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter value The variable content in JSON format
#
# @class_prefix variable_dict
# @class_parameter variable_name
Expand Down
8 changes: 5 additions & 3 deletions tree/30_generic_methods/variable_dict_from_file.cf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
# Please note that only global variables are available within templates.
#
# See [variable_dict_from_file_type](#_variable_dict_from_file_type) for complete documentation.
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter file_name The absolute local file name with JSON content
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter file_name The absolute local file name with JSON content
#
#
# @class_prefix variable_dict_from_file
Expand Down
10 changes: 6 additions & 4 deletions tree/30_generic_methods/variable_dict_from_file_type.cf
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
#
# You will be able to access the `value1` value with `${prefix.var[key1]}`.
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter file_name The file name to load data from
# @parameter file_type The file type, can be "JSON", "CSV", "YAML" or "auto" for auto detection based on file extension, with a fallback to JSON (default is "auto")
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter file_name The file name to load data from
# @parameter file_type The file type, can be "JSON", "CSV", "YAML" or "auto" for auto detection based on file extension, with a fallback to JSON (default is "auto")
# @parameter_constraint file_type "allow_empty_string" : true
# @parameter_constraint file_type "select" : [ "", "auto", "JSON", "YAML", "CSV" ]
#
Expand Down
8 changes: 5 additions & 3 deletions tree/30_generic_methods/variable_dict_from_osquery.cf
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@
#
# To access this value, use the `${prefix.var1[0][cpu_logical_cores]}` syntax.
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter query The query to execute (ending with a semicolon)
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter query The query to execute (ending with a semicolon)
#
# @class_prefix variable_dict_from_osquery
# @class_parameter variable_name
Expand Down
10 changes: 6 additions & 4 deletions tree/30_generic_methods/variable_dict_merge.cf
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@
# }
# ```
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter first_variable The first variable, which content will be overridden in the resulting variable if necessary (written in the form variable_prefix.variable_name)
# @parameter second_variable The second variable, which content will override the first in the resulting variable if necessary (written in the form variable_prefix.variable_name)
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter first_variable The first variable, which content will be overridden in the resulting variable if necessary (written in the form variable_prefix.variable_name)
# @parameter second_variable The second variable, which content will override the first in the resulting variable if necessary (written in the form variable_prefix.variable_name)
#
#
# @class_prefix variable_dict_merge
Expand Down
10 changes: 6 additions & 4 deletions tree/30_generic_methods/variable_dict_merge_tolerant.cf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
# See [variable_dict_merge](#_variable_dict_merge) for usage documentation. The only difference is that this method
# will not fail if one of the variables do not exist, and will return the other one. If both are undefined, the method will still fail.
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter first_variable The first variable, which content will be overridden in the resulting variable if necessary (written in the form variable_prefix.variable_name)
# @parameter second_variable The second variable, which content will override the first in the resulting variable if necessary (written in the form variable_prefix.variable_name)
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter first_variable The first variable, which content will be overridden in the resulting variable if necessary (written in the form variable_prefix.variable_name)
# @parameter second_variable The second variable, which content will override the first in the resulting variable if necessary (written in the form variable_prefix.variable_name)
#
#
# @class_prefix variable_dict_merge_tolerant
Expand Down
10 changes: 6 additions & 4 deletions tree/30_generic_methods/variable_iterator.cf
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
# Be careful that using a global variable can lead to unpredictable content in case of multiple definition, which is implicitly the case when a technique has more than one instance (directive).
# Please note that only global variables are available within templates.
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter value The variable content
# @parameter separator Regular expression that is used to split the value into items ( usually: , )
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter value The variable content
# @parameter separator Regular expression that is used to split the value into items ( usually: , )
# @parameter_constraint separator "allow_whitespace_string" : true
#
#
Expand Down
12 changes: 7 additions & 5 deletions tree/30_generic_methods/variable_iterator_from_file.cf
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
# Be careful that using a global variable can lead to unpredictable content in case of multiple definition, which is implicitly the case when a technique has more than one instance (directive).
# Please note that only global variables are available within templates.
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter file_name The path to the file
# @parameter separator_regex Regular expression that is used to split the value into items ( usually: \n )
# @parameter comments_regex Regular expression that is used to remove comments ( usually: \s*#.*?(?=\n) )
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter file_name The path to the file
# @parameter separator_regex Regular expression that is used to split the value into items ( usually: \n )
# @parameter comments_regex Regular expression that is used to remove comments ( usually: \s*#.*?(?=\n) )
#
# @class_prefix variable_iterator_from_file
# @class_parameter variable_name
Expand Down
8 changes: 5 additions & 3 deletions tree/30_generic_methods/variable_string.cf
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
# Be careful that using a global variable can lead to unpredictable content in case of multiple definition, which is implicitly the case when a technique has more than one instance (directive).
# Please note that only global variables are available within templates.
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter value The variable content
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter value The variable content
#
# @class_prefix variable_string
# @class_parameter variable_name
Expand Down
10 changes: 6 additions & 4 deletions tree/30_generic_methods/variable_string_default.cf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
# Be careful that using a global variable can lead to unpredictable content in case of multiple definition, which is implicitly the case when a technique has more than one instance (directive).
# Please note that only global variables are available within templates.
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter source_variable The source variable name
# @parameter default_value The default value to use if source_variable is not defined
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter source_variable The source variable name
# @parameter default_value The default value to use if source_variable is not defined
#
# @class_prefix variable_string_default
# @class_parameter variable_name
Expand Down
2 changes: 1 addition & 1 deletion tree/30_generic_methods/variable_string_escaped.cf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# ````
#
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
#
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_\.]+$"
# @class_prefix variable_string_escaped
# @class_parameter variable_name

Expand Down
12 changes: 7 additions & 5 deletions tree/30_generic_methods/variable_string_from_augeas.cf
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@
# variable_string_from_augeas("label","value","/etc/hosts/1/ipaddr","Hosts","/etc/hosts");
# ```
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter path The path to the file and node label
# @parameter lens The lens specified by the user in case he wants to load a specified lens associated with its file
# @parameter file The file specified by the user in case he wants to load a specified file associated with its lens
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter path The path to the file and node label
# @parameter lens The lens specified by the user in case he wants to load a specified lens associated with its file
# @parameter file The file specified by the user in case he wants to load a specified file associated with its lens
# @parameter_constraint file "allow_empty_string" : true
# @parameter_constraint lens "allow_empty_string" : true
# @class_prefix variable_string_from_augeas
Expand Down
8 changes: 5 additions & 3 deletions tree/30_generic_methods/variable_string_from_command.cf
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
# report an error otherwise.
# * The command will be executed even in *Audit mode*
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter command The command to execute
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter command The command to execute
#
# @class_prefix variable_string_from_command
# @class_parameter variable_name
Expand Down
8 changes: 5 additions & 3 deletions tree/30_generic_methods/variable_string_from_file.cf
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
# Be careful that using a global variable can lead to unpredictable content in case of multiple definition, which is implicitly the case when a technique has more than one instance (directive).
# Please note that only global variables are available within templates.
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter file_name The path of the file
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter file_name The path of the file
#
# @class_prefix variable_string_from_file
# @class_parameter variable_name
Expand Down
10 changes: 6 additions & 4 deletions tree/30_generic_methods/variable_string_from_math_expression.cf
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@
#
# The `prefix.sum` string variable will contain `5` and `prefix.product` will contain `30`.
#
# @parameter variable_prefix The prefix of the variable name
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter expression The mathematical expression to evaluate
# @parameter format The format string to use
# @parameter variable_prefix The prefix of the variable name
# @parameter_constraint variable_prefix "regex" : "^[A-Za-z0-9_]+$"
# @parameter variable_name The variable to define, the full name will be variable_prefix.variable_name
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_]+$"
# @parameter expression The mathematical expression to evaluate
# @parameter format The format string to use
#
# @class_prefix variable_string_from_math_expression
# @class_parameter variable_name
Expand Down
1 change: 1 addition & 0 deletions tree/30_generic_methods/variable_string_match.cf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# is it recommended to use instead condition_from_variable_match which is designed for it.
#
# @parameter variable_name Complete name of the variable being tested, like my_prefix.my_variable
# @parameter_constraint variable_name "regex" : "^[A-Za-z0-9_\.]+$"
# @parameter expected_match Regex to use to test if the variable content is compliant
#
# @class_prefix variable_string_match
Expand Down