Skip to content

fix(sonar): green the SonarCloud quality gate — real fixes + policy-encoded exclusions - #92

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/sonar-quality-gate
Sep 21, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
fix/sonar-quality-gate

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Greens the chronically-red SonarCloud Code Analysis check (Quality Gate: "C Security Rating on New Code", red on main across bc15292 → df21a36 → post-#88-91 merges). All 29 open vulnerability-class findings are resolved: 8 fixed in code, 21 excluded by review with each exclusion's estate-policy authority recorded in-repo.

Changes

Fixed in code (real improvements, not silencing):

  • S8264/S8233/S8234 — workflow-level permissions: moved to job level in scorecard.yml, casket-pages.yml, dogfood-gate.yml, static-analysis-gate.yml, worker-ci.yml (least-privilege granularity; verified the estate workflow-linter only checks duplicate YAML keys, so nothing depends on the workflow-level blocks).
  • S2245 — worker/src/http.js request-id fallback no longer uses Math.random: crypto.getRandomValues (CSPRNG), with a monotonic counter + timestamp last resort (correlation ids make no randomness claim).
  • Hardening while here: wiki-sync.sh PAT handling moved out of clone URLs into a git credential helper reading the environment — no credential-in-URL pattern for scanners to flag.

Excluded by review — sonar-project.properties (new), each with justification:

  • S7637 on .github/**: the estate pins actions by version tag, mapped tag→SHA by the machine-generated actions.lock and verified by the governance "Actions lockfile verify" job — Sonar cannot see the lockfile.
  • S6505/S8543/S8564: npm-avoidant estate policy — no lockfile tracked by design (documented at the install steps).
  • S6506: curl -fsSL of fixed https release URLs (installer idiom; redirects required).
  • S5332: an http trigger to a LAN-only .local service, no-secret public payload, continue-on-error.

Also: STATE.a2ml recent-changes note.

RSR Quality Checklist

Required

  • Tests pass (just test or equivalent)
  • Code is formatted (just fmt or equivalent)
  • Linter is clean (no new warnings or errors)
  • No banned language patterns (no TypeScript, no npm/bun, no Go/Python)
  • No unsafe blocks without // SAFETY: comments
  • No banned functions (believe_me, unsafeCoerce, Obj.magic, Admitted, sorry)
  • SPDX license headers present on all new/modified source files
  • No secrets, credentials, or .env files included

As Applicable

  • .machine_readable/STATE.a2ml updated — recent-changes note
  • Documentation updated — sonar-project.properties is fully self-documenting
  • New dependencies reviewed — none

Testing

  • YAML parse + job-permission placement verified for all 5 edited workflows (workflow-level perms now absent, every job carries its own)
  • node --check on worker/src/http.js (ESM) — clean
  • wiki-sync.sh re-tested end-to-end against a local bare wiki: publish + idempotent no-op, with the credential-helper path (CRED_ARGS) exercised
  • Vendored a2ml validator: 0 errors / 118 files
  • Sonar coverage check: 8 fixed + 21 excluded = all 29 open findings accounted for

Screenshots

Not applicable — CI/quality-gate change. Evidence: the next automatic SonarCloud analysis on main should report 0 open vulnerabilities → Security Rating on New Code = A.

…ncoded exclusions

The 'SonarCloud Code Analysis' check has been red on main across recent
history (Quality Gate: 'C Security Rating on New Code'), driven by 29
open vulnerability-class findings. All 29 are addressed here: 8 fixed in
code, 21 excluded by review with their estate-policy authority recorded
in sonar-project.properties.

Fixed in code (real improvements, not silencing):
- S8264/S8233/S8234: move workflow-level permissions to job level in
  scorecard.yml, casket-pages.yml, dogfood-gate.yml,
  static-analysis-gate.yml, worker-ci.yml — least-privilege granularity
  the rules ask for; the estate workflow-linter only checks duplicate
  YAML keys, so nothing else depends on workflow-level blocks.
- S2245: worker/src/http.js request-id fallback no longer uses
  Math.random — crypto.getRandomValues (CSPRNG), with a monotonic
  counter + timestamp last resort (correlation ids make no randomness
  claim).
- Hardening while here: wiki-sync.sh moved PAT handling out of clone
  URLs into a git credential helper reading the environment — no
  credential-in-URL pattern for any scanner to flag. Re-tested
  end-to-end (publish + idempotent no-op) against a local bare wiki.

Excluded by review (sonar-project.properties, each with its authority):
- S7637 on .github/**: estate pins actions by version tag mapped tag->SHA
  by the machine-generated actions.lock, verified by the governance
  'Actions lockfile verify' job — Sonar cannot see the lockfile.
- S6505/S8543/S8564: the estate is npm-avoidant by policy — no lockfile
  is tracked by design (documented at the install steps).
- S6506/S5332: curl -fsSL of fixed https release URLs, and an http
  trigger to a LAN-only .local service with a no-secret public payload.

Also: STATE.a2ml recent-changes note.

Verified locally: YAML parse + job-perm placement for all 5 workflows,
node --check on http.js (ESM), a2ml validator 0 errors/118 files,
sonar-project.properties multicriteria syntax.

Signed-off-by: Jonathan D.A. Jewell <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 324caf91-28c6-4c54-98e3-b450319f2ad1

📥 Commits

Reviewing files that changed from the base of the PR and between f986e42 and 590ccd8.

📒 Files selected for processing (9)
  • .github/workflows/casket-pages.yml
  • .github/workflows/dogfood-gate.yml
  • .github/workflows/scorecard.yml
  • .github/workflows/static-analysis-gate.yml
  • .github/workflows/worker-ci.yml
  • .machine_readable/6a2/STATE.a2ml
  • .machine_readable/scripts/forge/wiki-sync.sh
  • sonar-project.properties
  • worker/src/http.js

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.

@hyperpolymath
hyperpolymath merged commit 8a4cc97 into main Sep 21, 2026
29 of 32 checks passed
@hyperpolymath
hyperpolymath deleted the fix/sonar-quality-gate branch September 21, 2026 20:09
@sonarqubecloud

Copy link
Copy Markdown

hyperpolymath added a commit that referenced this pull request Sep 21, 2026
…sis honours (#94)

## Summary

Follow-up to #92 (measured outcome): SonarCloud automatic analysis does
**not** apply rule-level `sonar.issue.ignore.multicriteria` from
sonar-project.properties — only file-scope properties
(`sonar.exclusions` et al.). Evidence: after #92 the 8 code fixes
cleared (29 → 21 open), and of the 21 exactly the 5 `S7637` tag-pin
findings sit on New Code — the gate condition — all in `.github/**`.

## Changes

- `sonar-project.properties`: `sonar.exclusions=.github/**/*` — the
estate lints CI workflow files with its own toolchain (actions.lock
verify, workflow security linter, Hypatia workflow_audit); Sonar
generic-rules signal there duplicates that badly and conflicts with
estate policy (lockfile tag-pinning, npm-avoidant no-lockfile).
Everything outside `.github` stays fully analysed.
- The rule-level multicriteria block is kept for a CI-based-scanning
future, with an honest note that automatic analysis ignores it
(correcting #92's assumption).

## RSR Quality Checklist

### Required

- [x] Tests pass
- [x] Code is formatted
- [x] Linter is clean
- [x] No banned language patterns
- [x] No unsafe blocks without // SAFETY: comments
- [x] No banned functions
- [x] SPDX license headers present on all new/modified source files
- [x] No secrets, credentials, or .env files included

### As Applicable

- [x] Documentation updated — the properties file is self-documenting
with measured evidence

## Testing

- Sonar API: 21 open vulnerabilities, 5 on New Code, all 5 in
`.github/**` — exactly the scope of the exclusion
- Expected after merge + re-analysis: 0 New-Code vulnerabilities →
Security Rating on New Code = A → Quality Gate OK

## Screenshots

Not applicable — analysis config.

Signed-off-by: Jonathan D.A. Jewell <[email protected]>
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.

1 participant