Skip to content

Commit c408592

Browse files
author
Eddie Knight
authored
Adjusted to max score with warning if job content are set to write (#2355)
Signed-off-by: Eddie Knight <[email protected]> Signed-off-by: Eddie Knight <[email protected]>
1 parent 78c7e83 commit c408592

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

checks/evaluation/permissions.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,9 @@ func calculateScore(result map[string]permissions) int {
241241

242242
// contents.
243243
// Allows attacker to commit unreviewed code.
244+
// Scoring does not apply to job-level permissions, as this is a common place to use third-party actions.
244245
// High risk: -10
245-
if permissionIsPresent(perms, "contents") {
246+
if permissionIsPresentInTopLevel(perms, "contents") {
246247
score -= checker.MaxResultScore
247248
}
248249

checks/permissions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func TestGithubTokenPermissions(t *testing.T) {
251251
filenames: []string{"./testdata/.github/workflows/github-workflow-permissions-contents-writes-no-release.yaml"},
252252
expected: scut.TestReturn{
253253
Error: nil,
254-
Score: checker.MinResultScore,
254+
Score: checker.MaxResultScore,
255255
NumberOfWarn: 1,
256256
NumberOfInfo: 1,
257257
NumberOfDebug: 4,

0 commit comments

Comments
 (0)