Ignore local actions that are not pinned (#1357)

* ignore local actions

* missing files
This commit is contained in:
laurentsimon 2021-12-06 08:36:42 -08:00 committed by GitHub
parent 38b5199e9e
commit 023eab671e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 0 deletions

View File

@ -606,6 +606,14 @@ func validateGitHubActionWorkflow(pathfn string, content []byte,
// Cannot check further, continue.
continue
}
// nolint:lll
// Check whether this is an action defined in the same repo,
// https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions#referencing-an-action-in-the-same-repository-where-a-workflow-file-uses-the-action.
if strings.HasPrefix(execAction.Uses.Value, "./") {
continue
}
// Ensure a hash at least as large as SHA1 is used (40 hex characters).
// Example: action-name@hash
match := hashRegex.Match([]byte(execAction.Uses.Value))

View File

@ -64,6 +64,17 @@ func TestGithubWorkflowPinning(t *testing.T) {
NumberOfDebug: 0,
},
},
{
name: "Local action workflow",
filename: "./testdata/workflow-local-action.yaml",
expected: scut.TestReturn{
Error: nil,
Score: checker.MaxResultScore,
NumberOfWarn: 0,
NumberOfInfo: 2,
NumberOfDebug: 0,
},
},
{
name: "Non-pinned workflow",
filename: "./testdata/workflow-not-pinned.yaml",

View File

@ -0,0 +1,42 @@
# Copyright 2021 Security Scorecard Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
on:
push:
paths:
- 'source/common/**'
pull_request:
jobs:
CodeQL-Build:
strategy:
fail-fast: false
# CodeQL runs on ubuntu-latest and windows-latest
runs-on: ubuntu-latest
steps:
- name: Local step 1
uses: ./myaction/file
with:
fetch-depth: 2
- name: Checkout repository
uses: actions/checkout@daadedc81d5f9d3c06d2c92f49202a3cc2b919ba
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
- name: Local action 2
uses: ./myaction/file2