9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/rules/unpinned_artifact.rb', line 9
def check(workflow)
findings = []
workflow.uses_actions.each do |action|
uses = action[:uses]
next unless uses&.match?(DOWNLOAD_ARTIFACT_PATTERN)
step = action[:step]
with_block = step["with"]
has_name = with_block.is_a?(Hash) && with_block.key?("name") && !with_block["name"].nil? && with_block["name"].to_s.strip != ""
unless has_name
findings << finding(workflow,
line: action[:line] || 0,
code: "uses: #{uses}",
message: "download-artifact without specific name downloads ALL artifacts — may include untrusted content",
fix: "Specify artifact name: in download-artifact to avoid downloading unintended artifacts"
)
end
end
findings
end
|