Skip to content

feat: implement issue #842 — SonarCloud: GitHub Actions / dependency hardening - #843

Merged
don-petry merged 5 commits into
mainfrom
dev-lead/issue-842-20260721-1842
Jul 21, 2026
Merged

feat: implement issue #842 — SonarCloud: GitHub Actions / dependency hardening#843
don-petry merged 5 commits into
mainfrom
dev-lead/issue-842-20260721-1842

Conversation

@don-petry

@don-petry don-petry commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Closes #842

Implemented by dev-lead agent. Please review.

Summary by CodeRabbit

  • Chores
    • Improved dependency-audit workflow compliance checks for Go tool installations.
    • Added validation to ensure workflow-installed Go tools use pinned versions and required security annotations.
    • Existing audit behavior and tool versions remain unchanged.

Copilot AI review requested due to automatic review settings July 21, 2026 18:56
@don-petry
don-petry requested a review from a team as a code owner July 21, 2026 18:56
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The dependency-audit workflows annotate pinned govulncheck installations with SonarCloud suppression markers. A Bats regression test verifies that workflow go install commands are version-pinned and include the required marker.

Changes

Go audit hardening

Layer / File(s) Summary
Pinned Go audit commands and regression guard
.github/workflows/dependency-audit*.yml, test/workflows/dependency-hardening.bats
Both govulncheck@v1.1.4 commands add # NOSONAR(githubactions:S8545). The Bats test requires workflow go install commands to include an @v version suffix and the same marker.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • petry-projects/.github#87: Introduces or centralizes the reusable workflow containing the pinned govulncheck installation command.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the SonarCloud GitHub Actions hardening work.
Linked Issues check ✅ Passed The workflow edits and regression test address the two S8545 findings with pinned installs and inline documented suppressions.
Out of Scope Changes check ✅ Passed The added test supports the same hardening goal and no unrelated code paths were modified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-842-20260721-1842

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) July 21, 2026 18:57
@don-petry
don-petry disabled auto-merge July 21, 2026 18:57

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new BATS test to verify that all 'go install' commands in workflows are version-pinned and contain the 'NOSONAR(githubactions:S8545)' exemption marker. Feedback on this change highlights that the pattern matching used to detect 'go install' is fragile and can be bypassed if the command appears at the start of a line or within quotes. A more robust pattern-matching suggestion has been provided to ensure all instances are reliably caught without triggering false positives on similar commands like 'cargo install'.

Comment thread test/workflows/dependency-hardening.bats
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
Issues addressed: 0
- Quality gate passed with zero findings — no actionable issues
Files changed: none
Skipped (informational): 0
```
**No changes needed.** The PR's code quality meets all SonarCloud standards. The quality gate passing means the PR is ready from a code quality perspective.

@don-petry
don-petry enabled auto-merge (squash) July 21, 2026 18:58
@don-petry
don-petry disabled auto-merge July 21, 2026 18:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Resolves SonarCloud rule githubactions:S8545 findings in the dependency audit workflows by documenting an inline suppression for go install (as a confirmed false positive when version-pinned) and adding a Bats regression guard to prevent future unpinned installs or missing suppressions.

Changes:

  • Add a Bats test that enforces go install usage in workflows is version-pinned and includes an inline NOSONAR(githubactions:S8545) marker.
  • Add inline NOSONAR(githubactions:S8545) comments to the govulncheck install steps in both dependency audit workflows.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
test/workflows/dependency-hardening.bats Adds a regression guard for version-pinned go install plus required Sonar suppression marker.
.github/workflows/dependency-audit.yml Adds inline Sonar suppression comment for the pinned govulncheck install.
.github/workflows/dependency-audit-reusable.yml Adds inline Sonar suppression comment for the pinned govulncheck install.

Comment thread test/workflows/dependency-hardening.bats Outdated
Comment thread test/workflows/dependency-hardening.bats Outdated
Comment thread .github/workflows/dependency-audit.yml Outdated
Comment thread .github/workflows/dependency-audit-reusable.yml Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 21, 2026
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-reviews (applied)

Changes committed and pushed.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 21, 2026
@don-petry
don-petry disabled auto-merge July 21, 2026 19:03
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-reviews (applied)

Changes committed and pushed.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) July 21, 2026 19:08
@don-petry
don-petry disabled auto-merge July 21, 2026 19:09
@donpetry-bot

Copy link
Copy Markdown
Contributor

CI checks on this PR are still running. Once they complete, re-mention @donpetry-bot to trigger a fresh review.

Posted by the donpetry-bot PR-review cascade.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) July 21, 2026 19:14

@donpetry-bot donpetry-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review — APPROVED ✓

Risk: LOW
Reviewed commit: e441bdf07046d302d5f7adaa683edcb70230f315
Review mode: triage-approved (single reviewer)

Summary

Resolves SonarCloud S8545 findings in the two dependency-audit workflows via inline NOSONAR suppressions (confirmed false positive: go install @vX.Y.Z is fully pinned and verified via the Go checksum DB; Go has no --locked equivalent) and adds a bats regression guard requiring any future 'go install' in workflows to be version-pinned and carry the suppression marker. The workflow changes are YAML-comment-only — the executed command is unchanged and remains pinned at govulncheck@v1.1.4.

Linked issue analysis

Closes #842 (SonarCloud: GitHub Actions / dependency hardening, 2x githubactions:S8545). The issue's acceptance criteria explicitly allow inline NOSONAR for confirmed false positives noted inline — exactly what this PR does, with the justification documented both in the workflow comments and in the new bats test. SonarCloud quality gate on this PR passed with 0 new issues and 0 security hotspots. Substantively addressed.

Findings

  • No blocking findings.
  • Workflow diff is comment-only: the trailing '# NOSONAR(...)' is a YAML comment, so the run command executed by the shell is byte-identical to before (no behavior change).
  • New bats test correctly excludes near-matches like 'cargo install' (word-char-prefix guard) and fails loud on unpinned installs or missing markers; it passed in CI (Dependency Hardening Tests / bats: SUCCESS).
  • Prior bot review comments (Gemini pattern fragility, Copilot @v-prefix looseness and justification wording) were addressed in follow-up commits; all 5 review threads are resolved.
  • Secret-scanning MCP tool unavailable in this environment; gitleaks CI check passed (SUCCESS).

CI status

All checks green: Lint, ShellCheck, Agent Security Scan, Secret scan (gitleaks), CodeQL (Analyze actions), SonarCloud + SonarCloud Code Analysis (quality gate passed), Dependency Hardening Tests (bats), Dependency audit (npm audit; ecosystem-specific jobs skipped as expected), AgentShield, CodeRabbit. No failures; skipped jobs are conditional ecosystem audits.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

@sonarqubecloud

Copy link
Copy Markdown

@don-petry
don-petry disabled auto-merge July 21, 2026 19:18
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
Issues addressed: 0
- Quality gate passed with 0 new issues, 0 security hotspots
Files changed: None
Skipped (informational): 0
Status: ✅ No action required — PR passes all checks and quality gate
```
The PR is in good standing. The SonarCloud quality gate passed successfully, there are no new issues to address, and all CI checks are passing. The PR is approved and ready.

@don-petry
don-petry enabled auto-merge (squash) July 21, 2026 19:19
@don-petry
don-petry merged commit c7054dd into main Jul 21, 2026
21 of 22 checks passed
@don-petry
don-petry deleted the dev-lead/issue-842-20260721-1842 branch July 21, 2026 19:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with 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.

Inline comments:
In `@test/workflows/dependency-hardening.bats`:
- Around line 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.
- Around line 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.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a4a039cb-321e-43e3-ad39-3aa9a365515b

📥 Commits

Reviewing files that changed from the base of the PR and between 48e1d57 and 0461e89.

📒 Files selected for processing (3)
  • .github/workflows/dependency-audit-reusable.yml
  • .github/workflows/dependency-audit.yml
  • test/workflows/dependency-hardening.bats

Comment on lines +60 to +66
@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.

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

Comment on lines +74 to +79
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

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.

@donpetry-bot

Copy link
Copy Markdown
Contributor

Review — fix requested (cycle 1/3)

The automated review identified the following issues. Please address each one:

Findings to fix

Automated review — NEEDS HUMAN REVIEW

Risk: LOW
Reviewed commit: 0461e89f075e308348743715c049a6776ee35ade
Cascade: triage → deep (triage: haiku 4.5 → deep: opus 4.8 + duck: o4-mini → audit: fable 5)

Summary

PR adds inline NOSONAR(githubactions:S8545) suppressions to two dependency-audit workflows (comment-only; the pinned go install govulncheck@v1.1.4 command is byte-identical) plus a bats guard requiring future go install steps to be @vX.Y.Z-pinned and carry the marker. Risk is LOW and the triage HIGH signal (gemini's fragile-pattern finding) is already fixed at head — the guard now uses *"go install"* with a word-char-prefix exclusion as gemini suggested. Not approving only because reviewDecision is CHANGES_REQUESTED from coderabbit at the current head (2 unresolved, minor test-hardening findings). Note: dependency-audit-reusable.yml is pinned by 7 downstream consumers, but the change is a non-interface-breaking comment (informational).

Downstream impact

This change is consumed by 7 downstream repo(s) that pin the affected reusable workflow / lib / prompt. Impacted consumers:

Impacted shared surfaces:
  - .github/workflows/dependency-audit-reusable.yml

Impacted consumers (7, fetching up to 10):
  - petry-projects/.github-private (pins .github/workflows/dependency-audit-reusable.yml)
      .github/workflows/dependency-audit.yml
  - petry-projects/ContentTwin (pins .github/workflows/dependency-audit-reusable.yml)
      .github/workflows/dependency-audit.yml
  - petry-projects/TalkTerm (pins .github/workflows/dependency-audit-reusable.yml)
      .github/workflows/dependency-audit.yml
  - petry-projects/bmad-bgreat-suite (pins .github/workflows/dependency-audit-reusable.yml)
      .github/workflows/dependency-audit.yml
  - petry-projects/broodly (pins .github/workflows/dependency-audit-reusable.yml)
      .github/workflows/dependency-audit.yml
  - petry-projects/google-app-scripts (pins .github/workflows/dependency-audit-reusable.yml)
      .github/workflows/dependency-audit.yml
  - petry-projects/markets (pins .github/workflows/dependency-audit-reusable.yml)
      .github/workflows/dependency-audit.yml

Findings

  • major: reviewDecision is CHANGES_REQUESTED: coderabbitai submitted a CHANGES_REQUESTED review at the current head (0461e89) with 2 unresolved actionable comments. Unresolved-thread gate fails, so the PR cannot be auto-approved until these are addressed or dismissed.
  • minor: coderabbit Addressing PR comments #1: workflow_command_lines() globs only .github/workflows/*.yml, not *.yaml. A workflow using the .yaml extension would evade ALL guards in this file (pip/npx/go install). Pre-existing gap (not introduced by this PR; repo currently uses .yml only) — low practical risk, worth hardening.
  • minor: coderabbit Add multi-agent isolation strategy using git worktrees #2: the go-install guard validates the @v[0-9] pin and the NOSONAR marker against the entire line ($cmd), including the inline comment. A comment mentioning a version (e.g. @v1.x) could mask an unpinned @latest command (false negative). Current content is safe because the marker text uses literal @vX.Y.Z (X is not a digit), but splitting command text vs. comment suffix before validating would remove the fragility.
  • info: Triage HIGH signal resolved: the gemini fragile-pattern finding (at prior SHA fca210e) is fixed at head — the guard matches *"go install"* and excludes a word-char prefix, exactly gemini's recommendation. Workflow diff is comment-only, command still pinned @v1.1.4. SonarCloud quality gate passed (0 new issues), gitleaks green, all CI checks green (skipped jobs are conditional ecosystem audits). Secret-scanning MCP tool unavailable in this environment (not blocking).

Reviewed by the PR-review cascade (triage: haiku 4.5 → deep: opus 4.8 + duck: o4-mini → audit: fable 5). Reply if you need a human review.

Additional tasks

  1. Resolve all unresolved review thread comments from other reviewers
  2. Ensure all CI checks pass after your changes
  3. Rebase on the target branch if behind
  4. Do NOT modify files unrelated to the findings above

The review cascade will automatically re-review after new commits are pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SonarCloud: GitHub Actions / dependency hardening

3 participants