🐛 Token permission check was failing on non-yaml files

This commit is contained in:
Chris McGehee 2021-11-03 20:29:06 -07:00 committed by Naveen
parent 6562cc1f44
commit 2006be1819
2 changed files with 17 additions and 1 deletions

View File

@ -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 {

View File

@ -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()
}
})
}
}