diff --git a/checks/permissions.go b/checks/permissions.go index 1bf9b3fc..8fcd8974 100644 --- a/checks/permissions.go +++ b/checks/permissions.go @@ -360,6 +360,9 @@ func testValidateGitHubActionTokenPermissions(pathfn string, // Check file content. func validateGitHubActionTokenPermissions(path string, content []byte, dl checker.DetailLogger, data FileCbData) (bool, error) { + if !isWorkflowFile(path) { + return true, nil + } // Verify the type of the data. pdata, ok := data.(*permissionCbData) if !ok { diff --git a/checks/permissions_test.go b/checks/permissions_test.go index d9bf494d..2e02ef4d 100644 --- a/checks/permissions_test.go +++ b/checks/permissions_test.go @@ -230,6 +230,17 @@ func TestGithubTokenPermissions(t *testing.T) { NumberOfDebug: 4, }, }, + { + name: "Non-yaml file", + filename: "./testdata/script.sh", + expected: scut.TestReturn{ + Error: nil, + Score: checker.MaxResultScore, + NumberOfWarn: 0, + NumberOfInfo: 0, + NumberOfDebug: 0, + }, + }, } for _, tt := range tests { tt := tt // Re-initializing variable so it is not changed while executing the closure below @@ -247,7 +258,9 @@ func TestGithubTokenPermissions(t *testing.T) { } dl := scut.TestDetailLogger{} r := testValidateGitHubActionTokenPermissions(tt.filename, content, &dl) - scut.ValidateTestReturn(t, tt.name, &tt.expected, &r, &dl) + if !scut.ValidateTestReturn(t, tt.name, &tt.expected, &r, &dl) { + t.Fail() + } }) } }