mirror of
https://github.com/ossf/scorecard.git
synced 2024-11-05 05:17:00 +03:00
✨ Ignore local actions that are not pinned (#1357)
* ignore local actions * missing files
This commit is contained in:
parent
38b5199e9e
commit
023eab671e
@ -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))
|
||||
|
@ -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",
|
||||
|
42
checks/testdata/workflow-local-action.yaml
vendored
Normal file
42
checks/testdata/workflow-local-action.yaml
vendored
Normal 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
|
Loading…
Reference in New Issue
Block a user