mirror of
https://github.com/ossf/scorecard.git
synced 2024-09-11 00:45:36 +03:00
🐛 Token permission check was failing on non-yaml files
This commit is contained in:
parent
6562cc1f44
commit
2006be1819
@ -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 {
|
||||
|
@ -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()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user