Skip to content

Sonar pass 2: clear the 12 new findings and make coverage count - #21

Merged
dgunter merged 1 commit into
mainfrom
chore/sonar-pass-2
Sep 4, 2026
Merged

dgunter merged 1 commit into
mainfrom
chore/sonar-pass-2

Conversation

@dgunter

@dgunter dgunter commented Sep 4, 2026

Copy link
Copy Markdown
Owner

What

Second SonarCloud pass on main. PRs #15 to #20 landed 12 new findings; this clears all of them and fixes the reason the coverage gate has been red.

Findings

  • prompts.py: the delimiter-scrubbing regex is rewritten as <\s*(?:/\s*)?(rule|analysis)\s*> so its two whitespace runs cannot backtrack against each other (S8786, super-linear). Same match set, verified exhaustively over 111k generated strings; 20 KB of whitespace drops from 2.3 s to instant. The input is attacker-supplied rule text up to 64 KB, so this was a real slow-input vector.
  • test_prompt_injection.py: nine composite asserts split (S9073).
  • index.html: the theme bootstrap's empty catch now says why it is empty (S2486).
  • AccessGate.tsx: title text wrapped in a <span> so the spacing after the logo is explicit (S6772).

Coverage gate (was 76.3% on new code against 80%)

  • Frontend tests were invisible to SonarCloud: nothing ever produced an lcov file, so every .ts file scored 0% even where tests exist. vitest run --coverage (v8 provider, new dev dependency) now writes frontend/coverage/lcov.info in CI and sonar-project.properties points at it.
  • backend/tests/conftest.py is now classified as test code rather than uncovered source.
  • New test_llm_client.py drives AnthropicLlmClient against a stubbed SDK: request shape, refusal, JSON output config, effort and timeout forwarding, every SDK-error-to-LlmError mapping, and streaming (deltas, final-message refusal, mid-stream failure). client.py goes from 52% to 100%; backend total 93% to 96%.

Verification

  • Backend: 241 tests pass.
  • Frontend: typecheck clean, 23 tests pass, lcov produced with 34 files.
  • The SonarCloud comment below is the real check: expect zero open issues on new code and the coverage condition to clear.

🤖 Generated with Claude Code

Findings (all 12 open on main after PRs #15-#20):
- prompts.py: delimiter-scrubbing regex rewritten as
  `<\s*(?:/\s*)?(rule|analysis)\s*>` so the two whitespace runs cannot
  backtrack against each other (S8786). Same match set, verified
  exhaustively over short alphabets; 20 KB of whitespace drops from
  2.3 s to instant. The rule text is attacker-supplied and up to 64 KB.
- test_prompt_injection.py: nine composite asserts split (S9073).
- index.html: the theme bootstrap's empty catch says why it is empty
  (S2486). AccessGate: title text wrapped in a span so the JSX spacing
  after the logo is explicit (S6772).

Coverage gate (76.3% on new code vs 80%):
- Frontend tests were invisible to SonarCloud: no lcov file was ever
  produced, so every .ts file scored 0%. vitest now runs with the v8
  coverage provider in CI and sonar-project.properties points at
  frontend/coverage/lcov.info.
- backend/tests/conftest.py is classified as test code, not source.
- New test_llm_client.py drives AnthropicLlmClient against a stubbed
  SDK: request shape, refusal, JSON output config, effort/timeout
  forwarding, every SDK-error-to-LlmError mapping, and streaming
  (deltas, final-message refusal, mid-stream failure). client.py goes
  from 52% to 100%; backend total 93% -> 96%.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

SonarCloud analysis · PR #21

Quality gate: ✅ Passed · Open in SonarCloud

Condition Actual Required Status
Reliability rating (new code) A ≤ A ✅
Security rating (new code) A ≤ A ✅
Maintainability rating (new code) A ≤ A ✅
Coverage (new code) 100.0% ≥ 80.0% ✅
Duplication (new code) 0.0% ≤ 3.0% ✅
Security hotspots reviewed 100.0% ≥ 100.0% ✅

Open issues on new code: 0

No open issues on the changed code. 🎉

Commit 3964b8e6db7b · analysis task · posted by the Build workflow; edited in place on every push.

@dgunter
dgunter merged commit 0bb7201 into main Sep 4, 2026
1 check passed
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