From 5ef4b4e8bdb55f5182982fe48bd5fd083e7b0fb9 Mon Sep 17 00:00:00 2001 From: Chris McGehee Date: Wed, 13 Oct 2021 19:47:49 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixing=20parsing=20errors=20for?= =?UTF-8?q?=20github=20workflows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- checks/pinned_dependencies.go | 4 ++++ checks/pinned_dependencies_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/checks/pinned_dependencies.go b/checks/pinned_dependencies.go index a9dd79d1eb2..f897d307498 100644 --- a/checks/pinned_dependencies.go +++ b/checks/pinned_dependencies.go @@ -670,6 +670,10 @@ func testIsGitHubActionsWorkflowPinned(pathfn string, content []byte, dl checker // should continue executing after this file. func validateGitHubActionWorkflow(pathfn string, content []byte, dl checker.DetailLogger, data FileCbData) (bool, error) { + if !isWorkflowFile(pathfn) { + return true, nil + } + pdata := dataAsWorkflowResultPointer(data) if !CheckFileContainsCommands(content, "#") { diff --git a/checks/pinned_dependencies_test.go b/checks/pinned_dependencies_test.go index 03682439976..b908845536f 100644 --- a/checks/pinned_dependencies_test.go +++ b/checks/pinned_dependencies_test.go @@ -79,6 +79,17 @@ func TestGithubWorkflowPinning(t *testing.T) { NumberOfDebug: 0, }, }, + { + name: "Non-yaml file", + filename: "./testdata/script.sh", + expected: scut.TestReturn{ + Error: nil, + Score: checker.MaxResultScore, + NumberOfWarn: 0, + NumberOfInfo: 2, + NumberOfDebug: 0, + }, + }, } for _, tt := range tests { tt := tt // Re-initializing variable so it is not changed while executing the closure below