Skip to content

fix(spec-009): clear sonar reliability rating + harden subprocess calls#15

Merged
zenprocess merged 1 commit intomasterfrom
sonar-cleanup-spec009
Apr 8, 2026
Merged

fix(spec-009): clear sonar reliability rating + harden subprocess calls#15
zenprocess merged 1 commit intomasterfrom
sonar-cleanup-spec009

Conversation

@zenprocess
Copy link
Copy Markdown
Owner

Follow-up to #14 to clear the SonarCloud quality gate on master.

Changes

  • orchestration._run_parallel: replace assert isinstance(item, AgentResult) with an explicit elif/else fallback. Asserts get stripped under python -O so they're not load-bearing in production — Sonar flagged this as a real bug.
  • quality._run: add a security review docstring documenting why these subprocess.run calls are safe (shell=False, argv-list, no user-controlled tokens reach argv, fixed scratch cwd, bounded timeout, capture_output=True). Adds # nosec marker for the desired form.
  • quality._materialize: lift root.resolve() out of the loop and clarify the path-escape rejection comment.

Why

After #14 merged, the SonarCloud Code Analysis check went red on master:

  • Reliability Rating C on New Code (gate requires ≥ A)
  • 11 security hotspots (all subprocess invocations from quality.py)

The hotspots are not actual vulnerabilities — they're Sonar conservatively asking a reviewer to confirm subprocess use is safe. The new code paths and docstrings explain why; the # nosec marker stops Sonar from re-flagging the same lines.

Test plan

  • pytest tests/test_spec009_*.py — 53/53 green
  • ruff check src/ tests/ — clean
  • ruff format --check src/ tests/ — clean
  • CI test (3.10/3.11/3.12) green
  • Sonar gate clears (verify post-merge)

Follow-up to #14 to clear the sonar quality gate on master.

- orchestration._run_parallel: replace `assert isinstance(item, AgentResult)`
  with explicit elif/else fallback. Asserts are stripped under python -O,
  so they're not load-bearing in production. Sonar flagged this as a bug.

- quality._run: add a security review docstring documenting why these
  subprocess.run calls are safe (shell=False by default, argv-list, no
  user-controlled tokens reach argv, fixed scratch cwd, bounded timeout,
  capture_output=True). Add # nosec marker for B603 (subprocess-without-
  shell-equals-true is the desired form, not a finding).

- quality._materialize: lift root.resolve() out of the loop and clarify
  the path-escape rejection comment.

No behavior change. Same 53 spec-009 tests pass; ruff + format clean.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 8, 2026

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pawbench/quality.py 0.00% 6 Missing ⚠️
src/pawbench/orchestration.py 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@zenprocess zenprocess merged commit 5a29eb2 into master Apr 8, 2026
7 checks passed
@zenprocess zenprocess deleted the sonar-cleanup-spec009 branch April 8, 2026 07:38
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