Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed job-level permissions check for actions and packages #2367

Merged
merged 2 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions checks/evaluation/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ func calculateScore(result map[string]permissions) int {

// contents.
// Allows attacker to commit unreviewed code.
// Scoring does not apply to job-level permissions, as this is a common place to use third-party actions.
// High risk: -10
if permissionIsPresentInTopLevel(perms, "contents") {
score -= checker.MaxResultScore
Expand All @@ -250,14 +249,14 @@ func calculateScore(result map[string]permissions) int {
// packages: https://docs.github.com/en/packages/learn-github-packages/about-permissions-for-github-packages.
// Allows attacker to publish packages.
// High risk: -10
if permissionIsPresent(perms, "packages") {
if permissionIsPresentInTopLevel(perms, "packages") {
score -= checker.MaxResultScore
}

// actions.
// May allow an attacker to steal GitHub secrets by approving to run an action that needs approval.
// High risk: -10
if permissionIsPresent(perms, "actions") {
if permissionIsPresentInTopLevel(perms, "actions") {
score -= checker.MaxResultScore
}

Expand Down
4 changes: 2 additions & 2 deletions checks/permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestGithubTokenPermissions(t *testing.T) {
filenames: []string{"./testdata/.github/workflows/github-workflow-permissions-run-writes-2.yaml"},
expected: scut.TestReturn{
Error: nil,
Score: checker.MinResultScore,
Score: checker.MaxResultScore,
NumberOfWarn: 3,
NumberOfInfo: 2,
NumberOfDebug: 4,
Expand All @@ -86,7 +86,7 @@ func TestGithubTokenPermissions(t *testing.T) {
filenames: []string{"./testdata/.github/workflows/github-workflow-permissions-run-package-write.yaml"},
expected: scut.TestReturn{
Error: nil,
Score: checker.MinResultScore,
Score: checker.MaxResultScore,
NumberOfWarn: 1,
NumberOfInfo: 1,
NumberOfDebug: 4,
Expand Down