Skip to content

fix(security): annotate reviewed Semgrep p/default false-positives - #16

Merged
seonghobae merged 2 commits into
mainfrom
claude/contextualwisdomlab-audit-governance-fb7470
Aug 3, 2026
Merged

fix(security): annotate reviewed Semgrep p/default false-positives#16
seonghobae merged 2 commits into
mainfrom
claude/contextualwisdomlab-audit-governance-fb7470

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Why

The central Semgrep (multi-language SAST) required gate (semgrep scan --config=p/default --severity=WARNING --severity=ERROR --error) reports 15 Medium+ findings on the base code and fails, blocking the open dependabot PRs #10, #11, #12, #13 (and the newer #14/#15) in the merge queue.

Every one of the 15 findings is a reviewed false positive or an intentional, default-secure design. This PR annotates each with the sanctioned # nosemgrep suppression the gate already supports — its suppression step strips nosemgrep-annotated findings from the SARIF before evaluating the result. The gate itself is not weakened, disabled, or edited, and no genuine finding is suppressed.

Pattern mirrors the proven approach used in contextual-orchestrator#75: a # nosemgrep -- <rule>: <justification> comment on the exact reported line, placed after any pre-existing # nosec so Bandit's marker stays first.

Findings suppressed (all reviewed safe)

pg_llm_batch/config.py — SQL rules (sqlalchemy-execute-raw-query ERROR + formatted-sql-query WARNING)

Reported on the cur.execute( calls at lines 158, 172, 189, 201, 219, 287, 320. In every one, the only value interpolated into the f-string is the fixed class constant TABLE_NAME ("com_config" / "com_secrets") — a hard-coded identifier that never derives from user input — and all data values are bound via %s DB-API placeholders. No string concatenation of untrusted input occurs. Textbook false positive for parameterized queries with a constant table name.

pg_llm_batch/config.py:301python-logger-credential-disclosure (WARNING)

The message template contains the word "secret", which trips the heuristic, but the only logged argument is the literal mask "***" — the code deliberately logs a mask precisely to avoid leaking. No secret value is logged.

pg_llm_batch/token_counter.py:119, 149python-logger-credential-disclosure (WARNING)

  • 119: logs the model name (e.g. an encoding identifier) at debug level — not a credential.
  • 149: logs a generic pg_tiktoken query exception (exc) at debug level — not a credential.

docker/postgres/Dockerfilemissing-user-entrypoint / missing-user (ERROR)

Reported on the ENTRYPOINT/CMD of the postgres-base intermediate build stage, which is never run directly. Both deployable targets that consume it — with-tiktoken and runtime — end with an explicit USER postgres. The suppressions are placed on the preceding line because exec-form (JSON-array) ENTRYPOINT/CMD cannot carry an inline # comment without Docker folding it into the instruction and breaking the build; Semgrep honours nosemgrep on the line directly above a finding.

No genuine issues found

All 15 findings were individually reviewed; none is a real vulnerability (no untrusted input reaches a sink, no insecure default), so nothing is flagged for follow-up.

Verification

  • python -m py_compile pg_llm_batch/config.py pg_llm_batch/token_counter.py — passes.
  • Ran semgrep 1.172.0 locally against the edited files; every annotated line is marked suppressions: [{ "kind": "inSource" }] in the SARIF, including the two Dockerfile lines via the preceding-line placement. (The org p/default ruleset itself couldn't be fetched from the sandbox — registry egress is blocked — so an equivalent local rule set matching the same lines was used to confirm the suppression mechanism.)

Unblocks pg-llm-batch #10#13.


Generated by Claude Code

claude and others added 2 commits July 29, 2026 21:27
Suppress the 15 Medium+ findings from the central "Semgrep
(multi-language SAST)" gate that are reviewed false positives, using the
sanctioned `# nosemgrep` mechanism (the gate strips nosemgrep-annotated
findings from the SARIF). No gate is weakened; only documented
false-positives are annotated.

- pg_llm_batch/config.py: 7 sqlalchemy-execute-raw-query /
  formatted-sql-query findings on cur.execute() calls where the only
  interpolated token is the fixed class constant TABLE_NAME
  ("com_config"/"com_secrets") and every value is bound via %s
  placeholders; 1 python-logger-credential-disclosure where the only
  logged argument is the literal mask "***".
- pg_llm_batch/token_counter.py: 2 python-logger-credential-disclosure
  findings that log a model name / a generic pg_tiktoken exception at
  debug level, never a credential.
- docker/postgres/Dockerfile: 2 missing-user findings on the
  postgres-base intermediate build stage, which is never run directly;
  both deployable targets (with-tiktoken, runtime) end with an explicit
  USER postgres. Placed on the preceding line because exec-form
  ENTRYPOINT/CMD cannot carry an inline comment.

Verified with semgrep 1.172.0 that each annotated line is marked
suppressed (inSource) in the SARIF. Unblocks pg-llm-batch #10-13.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wtuYFp4E22QnEU1bFMhsr
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fa6a2607-aa6d-4a1a-9b16-cde0e569de3c

📥 Commits

Reviewing files that changed from the base of the PR and between 29559da and de0cea0.

📒 Files selected for processing (3)
  • docker/postgres/Dockerfile
  • pg_llm_batch/config.py
  • pg_llm_batch/token_counter.py

Comment @coderabbitai help to get the list of available commands.

@opencode-agent opencode-agent Bot 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

OpenCode cannot approve yet because required coverage evidence did not pass.

Review outcome

1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence

  • Problem: The required coverage-evidence job result was failure, so OpenCode cannot establish approval sufficiency for this head.

  • Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.

  • Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present.

  • Result: REQUEST_CHANGES

  • Reason: coverage-evidence result was failure, so required test/docstring evidence was not proven for current head ebca495b28510cf695dcc92cf7b200de643d7efb.

  • Head SHA: ebca495b28510cf695dcc92cf7b200de643d7efb

  • Workflow run: 30494851566

  • Workflow attempt: 1

Coverage evidence

Coverage Decision

  • Result: FAIL
  • Test evidence: not proven passing
  • Docstring evidence: not proven passing when configured
  • Failure count: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (3 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (3 files)"]
  R1 --> V1["required checks"]
Loading

@opencode-agent

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: ebca495b28510cf695dcc92cf7b200de643d7efb
  • Workflow run: 30494851566
  • Workflow attempt: 1
  • Gate result: REQUEST_CHANGES (approval step)

Pull request overview

OpenCode cannot approve yet because required coverage evidence did not pass.

Review outcome

1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence

  • Problem: The required coverage-evidence job result was failure, so OpenCode cannot establish approval sufficiency for this head.

  • Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.

  • Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present.

  • Result: REQUEST_CHANGES

  • Reason: coverage-evidence result was failure, so required test/docstring evidence was not proven for current head ebca495b28510cf695dcc92cf7b200de643d7efb.

  • Head SHA: ebca495b28510cf695dcc92cf7b200de643d7efb

  • Workflow run: 30494851566

  • Workflow attempt: 1

Coverage evidence

Coverage Decision

  • Result: FAIL
  • Test evidence: not proven passing
  • Docstring evidence: not proven passing when configured
  • Failure count: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (3 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (3 files)"]
  R1 --> V1["required checks"]
Loading

@seonghobae
seonghobae enabled auto-merge (squash) August 3, 2026 01:22
@seonghobae
seonghobae dismissed opencode-agent[bot]’s stale review August 3, 2026 01:26

Superseded by the current head de0cea0. The requested change was generated for old head ebca495 because the then-current central coverage-evidence workflow failed; the central workflow was subsequently repaired. The current head is a no-tree-change merge refresh (compare shows zero changed files versus ebca495), and exact-tree Semgrep and Security Scan evidence on ebca495 passed. Fresh current-head checks remain queued for revalidation.

@seonghobae
seonghobae merged commit d8d1889 into main Aug 3, 2026
19 checks passed
@seonghobae
seonghobae deleted the claude/contextualwisdomlab-audit-governance-fb7470 branch August 3, 2026 01:27
seonghobae pushed a commit that referenced this pull request Aug 3, 2026
Refresh both builder and runtime python:3.14-slim image digests to d3400aa. The branch was integrated with current main and the effective diff was verified as Dockerfile-only. The stale old-head review referenced Semgrep findings resolved by #16; fresh current-head security workflows were triggered and remained in the repository Actions queue.
seonghobae pushed a commit that referenced this pull request Aug 3, 2026
Refresh the immutable Rust toolchain image digest to 6d220bf. The branch was integrated with current main and the effective diff verified as a single Dockerfile digest replacement. The stale old-head review referenced repository Semgrep findings resolved by #16; fresh current-head security workflows were triggered and remained queued.
seonghobae pushed a commit that referenced this pull request Aug 3, 2026
Update the immutable uv image from 0.11.28 to 0.12.0. The existing-project Docker workflow uses supported sync flags, and the lockfile contains no source archives rejected by uv 0.12. The current-main effective diff is a single Dockerfile tag/digest replacement. The stale old-head review referenced Semgrep findings resolved by #16; fresh current-head security workflows were triggered and remained queued.
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