Skip to content

ci: fix code scanning alerts in workflows - #929

Merged
milkshakeuk merged 3 commits into
masterfrom
ci/fix-code-scanning-alerts
Nov 16, 2026
Merged

milkshakeuk merged 3 commits into
masterfrom
ci/fix-code-scanning-alerts

Conversation

@milkshakeuk

@milkshakeuk milkshakeuk commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Addresses the 12 open code scanning alerts. Stacked on the Dependabot catch-up PR.

  • Alerts 147–153, missing workflow permissions (fixed): top-level permissions: contents: read. Grants are per job and only where needed. Publish jobs get actions: read, and the test-results job also gets checks: write and pull-requests: write.

  • Alerts 155–158, Sonar S8482 (fixed): replaces bash <(curl … get.sh) with a pinned codacy-coverage-reporter 14.1.3 download, checked with sha256sum --check. Bumping the reporter means updating the version and hash together.

  • Alert 154, artifact poisoning (mitigated): Codacy needs the PR's coverage XML, so the untrusted artifact still has to be read. The job now:

    • downloads to runner.temp with no checkout
    • executes nothing from it and skips symlinks
    • validates head_sha
    • passes paths as a quoted array (previously step outputs were interpolated into the script, which allowed injection)
    • passes the Codacy token through env

    If CodeQL still flags this, dismissing it as "won't fix" with that reasoning seems fair.

  • Bug fix: the workflow_run jobs used if: >. The trailing newline made the condition always true, so they ran for cancelled and non-PR runs. They now use >-.

Needs CI to confirm

  • Codacy partial and final upload with the pinned reporter
  • EnricoMi posting test results with the reduced permissions
  • Artifact extraction paths
  • Whether CodeQL closes alert 154

Possible follow-up: coverage final runs without --commit-uuid, so it may finalise against the wrong SHA.

@codacy-production

codacy-production Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage ∅ diff coverage · +0.00% coverage variation

Metric Results
Coverage variation ✅ +0.00% coverage variation
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (30df84c) 1020600 22935 2.25%
Head commit (542afff) 1020600 (+0) 22935 (+0) 2.25% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#929) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Unit Test Results

    5 files      5 suites   11s ⏱️
1 431 tests 1 343 ✅  88 💤 0 ❌
2 692 runs  2 588 ✅ 104 💤 0 ❌

Results for commit 542afff.

♻️ This comment has been updated with latest results.

@milkshakeuk
milkshakeuk force-pushed the chore/dependabot-catchup branch from 1ddc4ed to b0d2f1a Compare November 16, 2026 11:44
@milkshakeuk
milkshakeuk force-pushed the ci/fix-code-scanning-alerts branch from 2a9ec4f to 4c97b90 Compare November 16, 2026 11:44
Base automatically changed from chore/dependabot-catchup to master November 16, 2026 12:15
@milkshakeuk
milkshakeuk force-pushed the ci/fix-code-scanning-alerts branch from 4c97b90 to 79ca74d Compare November 16, 2026 12:17
Default every workflow to contents: read and grant per-job write scopes
only where needed: actions: read to fetch artifacts from the triggering
run, and checks/pull-requests write to publish unit test results.
Download artifacts from untrusted pull request runs outside the workspace,
read coverage files as data only and validate the head SHA before use.
Replace the piped Codacy get.sh script with a pinned reporter release
verified by SHA-256, and fix workflow_run if conditions that always
evaluated to true because of a trailing newline.
@milkshakeuk
milkshakeuk force-pushed the ci/fix-code-scanning-alerts branch from 054a79f to 542afff Compare November 16, 2026 12:26
@milkshakeuk
milkshakeuk merged commit 36f525e into master Nov 16, 2026
14 checks passed
@milkshakeuk
milkshakeuk deleted the ci/fix-code-scanning-alerts branch November 16, 2026 12:52
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants