Skip to content

Commit aefe44a

Browse files
add check for empty github workflow uses
The value isn't actually empty in the testcase which triggered the panic, but our GitHub workflow library doesn't currently support parsing GitHub's new YAML anchors/aliases. https://github.blog/changelog/2025-09-18-actions-yaml-anchors-and-non-public-workflow-templates/ Signed-off-by: Spencer Schrock <[email protected]>
1 parent e1a0614 commit aefe44a

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

checks/raw/pinned_dependencies.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ var validateGitHubActionWorkflow fileparser.DoWhileTrueOnFileContent = func(
789789
fmt.Sprintf("unable to parse step '%v' for job '%v'", jobName, stepName))
790790
}
791791

792-
if execAction == nil || execAction.Uses == nil {
792+
if execAction == nil || execAction.Uses == nil || execAction.Uses.Value == "" {
793793
// Cannot check further, continue.
794794
continue
795795
}

checks/raw/pinned_dependencies_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ func TestGithubWorkflowPinning(t *testing.T) {
7777
filename: "./testdata/.github/workflows/github-workflow-unknown-os.yaml",
7878
warns: 2, // 1 in job with unknown OS, 1 in job with known OS
7979
},
80+
{
81+
name: "YAML anchor usage doesn't panic",
82+
filename: "./testdata/.github/workflows/workflow-anchor.yaml",
83+
warns: 1, // anchor definition is unpinned, but alias isn't supported by actionlint
84+
},
8085
}
8186
for _, tt := range tests {
8287
t.Run(tt.name, func(t *testing.T) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2025 OpenSSF Scorecard Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
name: CI
15+
16+
on:
17+
push:
18+
19+
jobs:
20+
yaml-anchor:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Upload coverage artifact
24+
uses: &actions-upload-artifact actions/[email protected]
25+
26+
yaml-alias:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Upload coverage artifact
30+
uses: *actions-upload-artifact

0 commit comments

Comments
 (0)