7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/rules/unscoped_app_token.rb', line 7
def check(workflow)
findings = []
workflow.jobs.each do |_job_id, job|
workflow.steps(job).each do |step|
next unless step["uses"]&.include?("create-github-app-token")
with = step["with"] || {}
has_permissions = with.keys.any? { |k| k.start_with?("permission-") }
unless has_permissions
line = workflow.line_of(/create-github-app-token/)
findings << finding(workflow,
line: line || 0,
message: "App token inherits blanket installation permissions",
fix: "Add permission-<name>: write inputs to scope the token"
)
end
end
end
findings
end
|