Skip to content

chore: fix sonar findings and restrict the publish workflow to pushes of this repo - #194

Merged
thegdsks merged 2 commits into
mainfrom
chore/sonar-cleanup
Oct 10, 2026
Merged

thegdsks merged 2 commits into
mainfrom
chore/sonar-cleanup

Conversation

@thegdsks

Copy link
Copy Markdown
Member

Clears the SonarCloud findings that were real and verifies the rest.

Publish workflow guard

publish.yml runs on workflow_run of CI with secrets and id-token: write, and checks out workflow_run.head_sha. The branches: [main] filter matches the head branch name, so a fork PR from a branch named main that passes CI could have started Publish on fork code. The job now also requires workflow_run.event == 'push' and head_repository.full_name == github.repository. Legitimate publishes (push to main, manual dispatch) are unchanged. All recent Publish runs came from this repository, so there is no sign this was used. Also worth checking in repo settings: require approval for all outside contributors' workflow runs.

Code

  • Sorts without a comparator now use compareCodeUnits, which is exactly the default code unit order written out. It is deliberately not localeCompare, because the audit hash chain, SigV4 canonical headers and permission fingerprints depend on a stable, locale independent order. compare.test.ts proves equality with the bare sort() over mixed case, accents, CJK and astral keys and pins canonicalJson output to the old implementation.
  • federated-logout.ts: the ternary only selected between two jwtVerify overloads. A static key is wrapped as a resolver and there is one call. That file had no tests, so federated-logout.test.ts covers a static key, a resolver key and a wrong key being rejected.
  • oauth-proxy.ts and password-reset.ts: cond ? 400 : 400 collapsed to 400. Behavior is unchanged. Whether some of those errors should be 403 or 5xx was never implemented and is not decided here.
  • simulate.ts: explicit index argument, same behavior. rate-limit.test.ts: the async assertion is now awaited and passes.

Workflows

  • codeql.yml, scorecard.yml: top level permissions: contents: read, jobs keep their least privilege blocks. scorecard-action pinned to a commit SHA.
  • release-python.yml: write permission moved to the job that needs it, pip install --only-binary :all:.
  • publish-mcp-registry.yml: curl --proto '=https' --tlsv1.2.

Not changed

Findings that are test data, UI strings, dev scripts or sampling randomness are not suppressed in code. They are listed for a decision in the SonarCloud UI.

Verified

Targeted core tests (9 files, 170 tests), lint and core typecheck pass. The workflow changes run on the next push to main.

…drop dead branches

Sorting keys without a comparator is flagged because the default order is
implicit. Use an explicit UTF-16 code unit comparator that gives the same order
(never localeCompare), so audit hash chains and SigV4 headers are unchanged.
Also collapse same-value conditionals, avoid passing a callback straight to
map, and await the rejects assertion in the rate limit test.
…ish to main pushes

Replace read-all with contents: read, pin ossf/scorecard-action to a commit
SHA, move the release-python write permission to the release job, install
python tooling binary-only, force https on the mcp-publisher download, and only
publish from CI runs of a push to main in this repository.
@thegdsks
thegdsks requested a review from a team as a code owner October 10, 2026 18:03
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your first pull request. CI will run shortly. If the change touches package source, please add a changeset with pnpm changeset.

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@thegdsks
thegdsks merged commit 7c5da5d into main Oct 10, 2026
12 of 13 checks passed
@thegdsks
thegdsks deleted the chore/sonar-cleanup branch October 10, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant