Skip to content

fix: resolve Sonar security gate (ReDoS + workflow supply-chain hardening) - #85

Merged
anchildress1 merged 7 commits into
mainfrom
fix/sonar-security-and-redos
Jun 27, 2026
Merged

anchildress1 merged 7 commits into
mainfrom
fix/sonar-security-and-redos

Conversation

@anchildress1

Copy link
Copy Markdown
Owner

What 🔧

Resolves the failing SonarCloud quality gate (new_security_rating=3) and the ReDoS code smell, plus hardens GitHub Actions supply-chain commands.

Code

  • typescript:S8786 (ReDoS) — rai-footer-exists.ts attribution regexes used [^<]+\s+<, where \s ⊂ [^<] → adjacent overlapping quantifiers with super-linear backtracking. Folded whitespace into the single [^<]+ run. Linear now; all tests + 100% coverage retained.

Workflows

  • S8232 — dropped forgeable github.actor == 'anchildress1' checks from workflow_dispatch conditions in lockfile-refresh.yml. Manual dispatch is already gated to write-access users by GitHub, so this removes the finding without weakening real protection.
  • S6505 / S8543 — npx tools now run with --ignore-scripts and pinned exact versions (@cyclonedx/cyclonedx-npm@5.0.0, license-checker@25.0.1).
  • S8544 — uv run enforces the lockfile (--frozen); uvx --from cyclonedx-bom==7.1.0 pinned.
  • S8541 — --no-build added to uvx invocations.

Known gaps 🚧

Test 🧪

  • make ai-checks green (clean/install/format/lint/test/benchmark/build).
  • actionlint clean (only pre-existing info-level shellcheck notes on untouched lines).
  • Local probes: uvx --no-build --from cyclonedx-bom==7.1.0 ✅, uv run --frozen ✅, uv sync --no-build ❌ (documented above).

Generated-by: Claude Opus 4.8 noreply@anthropic.com

The AI attribution patterns used `[^<]+\s+<` where `\s` is a subset of
`[^<]`, creating adjacent overlapping quantifiers with super-linear
backtracking (Sonar typescript:S8786). Fold the whitespace into the
single `[^<]+` run before `<` so each pattern matches in linear time.

Generated-by: Claude Opus 4.8 <noreply@anthropic.com>
Address Sonar GitHub Actions security findings:

- S8232: drop forgeable `github.actor` checks from workflow_dispatch
  conditions in lockfile-refresh.yml; manual dispatch is already
  restricted to write-access users by GitHub.
- S6505/S8543: run npx tools with `--ignore-scripts` and pinned exact
  versions (@cyclonedx/cyclonedx-npm@5.0.0, license-checker@25.0.1).
- S8544: enforce the lockfile on `uv run` (`--frozen`) and pin the
  `uvx --from cyclonedx-bom==7.1.0` tool version.
- S8541: add `--no-build` to `uvx` invocations (no local project to
  build). `uv sync`/`uv run` keep building the local editable
  workspace package, so `--no-build` is not applied there.

Generated-by: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 26, 2026 23:48
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@anchildress1

Copy link
Copy Markdown
Owner Author

@codex review

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

This PR addresses SonarCloud security findings by tightening potentially vulnerable regex usage in the Node commitlint rule and hardening CI workflows against supply-chain/script-execution risks, while also enforcing lockfile fidelity for Python steps.

Changes:

  • Updates the Node commitlint AI-attribution footer regex patterns to remove the overlapping-quantifier ReDoS smell.
  • Hardens GitHub Actions workflows by pinning npx tool versions, adding --ignore-scripts, and pinning/locking uv / uvx behavior (--frozen, --no-build).
  • Simplifies lockfile-refresh.yml workflow_dispatch gating by removing the actor equality check.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/node-commitlint/src/rules/rai-footer-exists.ts Adjusts AI attribution footer regex patterns to address ReDoS finding.
.github/workflows/test-and-build.yml Runs Python tooling/tests via uv run --frozen to enforce lockfile usage.
.github/workflows/security-audit.yml Pins and hardens SBOM/license tooling and uses uv sync --frozen for lockfile enforcement.
.github/workflows/release-please.yml Hardens release workflow commands (uv run --frozen, pinned npx/uvx with --ignore-scripts / --no-build).
.github/workflows/lockfile-refresh.yml Removes forgeable github.actor checks from workflow_dispatch conditions.

Comment thread packages/node-commitlint/src/rules/rai-footer-exists.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f3c59f4f9a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/node-commitlint/src/rules/rai-footer-exists.ts Outdated
The previous ReDoS fix over-loosened the patterns: `[^<]+` absorbed all
separators, so footers with no name (`Generated-by: <a@b>`), no space
before the email (`Generated-by: AI<a@b>`), or values spanning multiple
lines passed validation, diverging from the Python rule's
`^[^<]+ <[^>]+>$` contract.

Require a non-empty name and whitespace before `<email>`, and exclude
`\r`/`\n` from the name/email runs so a footer cannot match across lines.
The pattern stays linear: no two adjacent quantifiers share a character
class. Adds regression tests for the three cases above.

Generated-by: Claude Opus 4.8 <noreply@anthropic.com>
@anchildress1
anchildress1 requested a review from Copilot June 26, 2026 23:59
@anchildress1

Copy link
Copy Markdown
Owner Author

@codex review

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread .github/workflows/release-please.yml Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 2a0f01249a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

`npx @cyclonedx/cyclonedx-npm@5.0.0` is not installed in the workspace,
so modern npm prompts before downloading and would hang the release job.
Add `--yes`, matching the license-checker invocation.

Generated-by: Claude Opus 4.8 <noreply@anthropic.com>
@anchildress1
anchildress1 requested a review from Copilot June 27, 2026 00:04
@anchildress1

Copy link
Copy Markdown
Owner Author

@codex review

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread packages/node-commitlint/src/rules/rai-footer-exists.ts Outdated
Comment thread packages/node-commitlint/tests/rai-footer-exists.test.ts

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b75ca092f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/security-audit.yml Outdated
The patterns allowed a missing space after the colon (e.g.
`Generated-by:AI <ai@example.com>`), which contradicts the documented
`Key: Value` footer format and the rule's own error-message examples.
Require at least one non-newline whitespace after the colon and add a
regression test for the no-space-after-colon case.

Generated-by: Claude Opus 4.8 <noreply@anthropic.com>
@anchildress1
anchildress1 requested a review from Copilot June 27, 2026 00:11
@anchildress1

Copy link
Copy Markdown
Owner Author

@codex review

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 8e89166075

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The license audit's `uv sync --frozen` would install from a possibly
stale `uv.lock`, so newly declared production dependencies could be
omitted from the CycloneDX license report scanned from `.venv`. Use
`--locked` to fail the audit if the lock is out of date with
`pyproject.toml`; this still satisfies the lockfile-enforcement check.

Generated-by: Claude Opus 4.8 <noreply@anthropic.com>
@anchildress1
anchildress1 requested a review from Copilot June 27, 2026 00:17
@anchildress1

Copy link
Copy Markdown
Owner Author

@codex review

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 59f8eda99e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Fold in the open Dependabot dependency PRs and regenerate the lockfile:

- root dev deps: @commitlint/cli & config-conventional 21.0.1 -> 21.0.2,
  @typescript-eslint/eslint-plugin 8.59.4 -> 8.61.1, eslint 10.4 -> 10.5,
  lefthook 2.1.7 -> 2.1.9, prettier 3.8.3 -> 3.8.4, vitest 4.1.6 -> 4.1.9
  (PR #83); @types/node 25.9 -> 26.0 in node-commitlint (PR #84)
- transitive vite resolves to 8.1.0, clearing the high-severity
  server.fs.deny bypass and the launch-editor NTLM advisories (PR #81)
- override js-yaml ^4.2.0 and markdown-it ^14.2.0 so markdownlint-cli2's
  pinned transitives pick up the quadratic-DoS fixes; linkify-it and
  brace-expansion resolved via the regenerated lock

`npm audit` now reports 0 vulnerabilities; lint, tests, and build pass.

Generated-by: Claude Opus 4.8 <noreply@anthropic.com>
@anchildress1
anchildress1 force-pushed the fix/sonar-security-and-redos branch from 6f41d8c to 9cdb0a5 Compare June 27, 2026 01:21
@anchildress1
anchildress1 merged commit 1438d26 into main Jun 27, 2026
9 checks passed
@anchildress1
anchildress1 deleted the fix/sonar-security-and-redos branch June 27, 2026 03:32
@github-actions github-actions Bot mentioned this pull request Jul 6, 2026
@github-actions github-actions Bot mentioned this pull request Jul 31, 2026
@github-actions github-actions Bot mentioned this pull request Sep 14, 2026
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