Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dependency-audit-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
go-version: "stable"

- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
run: go install golang.org/x/vuln/cmd/govulncheck@v1.1.4 # NOSONAR(githubactions:S8545) pinned @vX.Y.Z is reproducible (verified via Go checksum DB); no --locked equivalent

- name: Audit Go dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
go-version: "stable"

- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
run: go install golang.org/x/vuln/cmd/govulncheck@v1.1.4 # NOSONAR(githubactions:S8545) pinned @vX.Y.Z is reproducible (verified via Go checksum DB); no --locked equivalent

- name: Audit Go dependencies
run: |
Expand Down
28 changes: 28 additions & 0 deletions test/workflows/dependency-hardening.bats
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,34 @@ workflow_command_lines() {
[ "$fail" -eq 0 ]
}

@test "every 'go install' in a workflow is version-pinned and S8545-exempted" {
# S8545 flags `go install` as non-lockfile-enforcing. Go has no --locked /
# --require-hashes equivalent: a pinned `@vX.Y.Z` is the reproducible install
# (verified via the Go checksum DB, sum.golang.org), so the finding is a confirmed
# false positive suppressed with an inline `# NOSONAR(githubactions:S8545)`
# marker. This guard fails loud if a new `go install` is added unpinned
# (@latest/@main) or without the marker.
Comment on lines +60 to +66

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Cover .yaml workflows too.

workflow_command_lines only enumerates .yml files, so this “every workflow” guard will miss unpinned go install commands in .yaml workflows. Extend the helper to scan both extensions.

As per coding guidelines, workflow checks must cover both .yml and .yaml files.

Proposed fix
-  for f in "$REPO_ROOT"/.github/workflows/*.yml; do
+  for f in "$REPO_ROOT"/.github/workflows/*.yml \
+           "$REPO_ROOT"/.github/workflows/*.yaml; do
+    [ -f "$f" ] || continue
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/workflows/dependency-hardening.bats` around lines 60 - 66, Update the
workflow file enumeration used by workflow_command_lines to include both .yml
and .yaml files, preserving the existing command scanning and validation
behavior so the go install guard covers every workflow extension.

Source: Coding guidelines

local fail=0 file cmd
while IFS=$'\t' read -r file cmd || [ -n "$file" ]; do
case "$cmd" in
*"go install"*)
case "$cmd" in
*[a-zA-Z0-9_-]go\ install*) : ;;
*)
case "$cmd" in *"@v"[0-9]*) : ;; *)
echo "UNPINNED go install (needs @vX.Y.Z): ${file##*/}: $cmd"; fail=1 ;;
esac
case "$cmd" in *"NOSONAR(githubactions:S8545)"*) : ;; *)
echo "MISSING # NOSONAR(githubactions:S8545): ${file##*/}: $cmd"; fail=1 ;;
esac
Comment on lines +74 to +79

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Validate command tokens, not arbitrary line text.

The checks search the complete raw line, so an unpinned command such as go install ...@latest # @v1 NOSONAR(githubactions:S8545) would pass. Strip the inline comment before validating the package version, and verify the NOSONAR marker specifically in the comment suffix.

Proposed validation shape
-            case "$cmd" in *"`@v`"[0-9]*) : ;; *)
+            cmd_without_comment=${cmd%%#*}
+            if [[ "$cmd_without_comment" =~ (^|[[:space:]])go[[:space:]]+install[[:space:]]+[^[:space:]]+@v[0-9]+(\.[0-9]+){2}([[:space:]]|$) ]]; then
+              :
+            else
               echo "UNPINNED go install (needs `@vX.Y.Z`): ${file##*/}: $cmd"; fail=1 ;;
-            esac
+            fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/workflows/dependency-hardening.bats` around lines 74 - 79, Update the
command validation in the dependency-hardening workflow to split each line into
command text and inline comment suffix before checking it. Validate the go
install version against only the command tokens, and require
NOSONAR(githubactions:S8545) specifically within the comment suffix, preserving
the existing failure reporting and fail flag behavior.

;;
esac
;;
esac
Comment thread
don-petry marked this conversation as resolved.
done < <(workflow_command_lines)
[ "$fail" -eq 0 ]
}

@test "each hash-locked requirements file referenced by a workflow exists" {
local fail=0 file cmd path
while IFS=$'\t' read -r file cmd || [ -n "$file" ]; do
Expand Down
Loading