7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/rules/docker_build_arg_secrets.rb', line 7
def check(workflow)
findings = []
workflow.lines_of(/build-args:/).each do |line_num|
(line_num..(line_num + 20)).each do |i|
break if i > workflow.raw_lines.length
line = workflow.line_content(i)
break if line&.match?(/^\s*\w+:/) && !line.match?(/^\s+["']?[A-Z_]+=/)
if line&.match?(/secrets\./)
findings << finding(workflow,
line: i,
code: line.strip,
message: "Secret in Docker build-arg — extractable via docker history",
fix: "Use --secret flag or RUN --mount=type=secret instead of build-arg"
)
end
end
end
findings
end
|