Class: Rules::JqArgEscape
Constant Summary collapse
- PATTERN =
/jq\s.*--arg\s+\w+\s+"[^"]*\\[nt\\][^"]*"/
Instance Method Summary collapse
Instance Method Details
#check(workflow) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rules/jq_arg_escape.rb', line 9 def check(workflow) findings = [] workflow.raw_lines.each_with_index do |line, i| next if line.strip.start_with?("#") next unless line.match?(PATTERN) findings << finding(workflow, line: i + 1, code: line.strip, message: "jq --arg treats values as raw literals — \\n becomes literal backslash-n, not a newline", fix: "Use real newlines via $'\\n' or multi-line variable, or use --argjson with pre-escaped JSON" ) end findings end |
#description ⇒ Object
4 |
# File 'lib/rules/jq_arg_escape.rb', line 4 def description = "jq --arg value contains backslash escape sequences that won't be interpreted" |
#name ⇒ Object
3 |
# File 'lib/rules/jq_arg_escape.rb', line 3 def name = "jq-arg-escape-sequences" |
#severity ⇒ Object
5 |
# File 'lib/rules/jq_arg_escape.rb', line 5 def severity = :medium |