Skip to content

fix: $global scanner config correctly inherited by per-repo entries#76

Closed
Valyrian-Code wants to merge 4 commits into
RocketChat:developfrom
Valyrian-Code:develop
Closed

fix: $global scanner config correctly inherited by per-repo entries#76
Valyrian-Code wants to merge 4 commits into
RocketChat:developfrom
Valyrian-Code:develop

Conversation

@Valyrian-Code
Copy link
Copy Markdown

@Valyrian-Code Valyrian-Code commented May 21, 2026

Problem

$global scanner configs (semgrep, trufflehog, claude, piAgent) were silently ignored.

If a repo did not define its own scanner block, the code fell back to DEFAULT_CONFIG instead of inheriting from $global, despite the documented merge behavior and examples using $global.semgrep.extraArgs.

trigger and comment already supported global inheritance correctly. Scanner blocks did not. The issue has existed since the TypeScript migration (23f1b32).

Root Cause

globalConfig was extracted in src/config.ts but never included in scanner config merges.

Changes

  • Updated src/config.ts to include globalConfig as the middle merge layer for:

    • semgrep
    • trufflehog
    • claude
    • piAgent
  • Added tests for:

    • $global scanner inheritance
    • repo-level override precedence

Test Plan

  • npm test — 618 tests pass
  • npm run lint — no warnings
  • npm run build && npm run validate-config — config validates successfully

GIF

semgrep, trufflehog, claude, and piAgent blocks were merged from
DEFAULT_CONFIG + per-repo overrides only — globalConfig was extracted
but never spread into the scanner merges. trigger and comment handled
this correctly; scanner blocks did not.

Adds two tests covering global inheritance and per-repo override
precedence for semgrep.
Copilot AI review requested due to automatic review settings May 21, 2026 20:55
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 21, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Valyrian-Code
Copy link
Copy Markdown
Author

Hey @julio-rocketchat
Could you review this fix for $global scanner config inheritance and merge precedence? Added tests as well.

scanBatchWithPrompt used max_tokens: 1024 but never checked
stop_reason on the response. When the API hit the token limit,
extractFindings found no tool_use block and returned { findings: [] }
— identical to a clean empty result. No error was logged, errorCount
stayed at zero, and findings were silently dropped.

Added stop_reason check before extractFindings: a max_tokens response
now returns { error: true } and logs an error, so the batch is counted
as failed and the caller knows findings may be incomplete.
…emoveOnException

KNOWN_GLOBAL_KEYS was missing semgrep, trufflehog, claude, and piAgent,
so using \$global.semgrep (functional since the config-inheritance fix)
caused validate-config to report an unknown key error despite the config
being correct. Also wires their content validators inside validateGlobal.

validateLabels was also missing removeOnException from its checked key
list even though the worker reads and applies it for exception label cleanup.
…unconditional

Two independent fixes:

1. Semgrep adapter only captured start.line and left startLine/endLine
   unset, collapsing every multi-line finding to a single annotation
   line. Added end?: {line} to SemgrepRawResult and populate startLine
   and endLine in toFinding, falling back to startLine when end is absent.

2. The issue_comment confirmation comment always said "Re-running scan..."
   even when no scan was queued (check run was success/neutral/missing).
   The suffix is now conditional — only appended when enqueueScan actually
   resolves successfully.
@Valyrian-Code
Copy link
Copy Markdown
Author

Closing in favour of separate PRs per fix: #77 (global scanner config), #78 (claude max_tokens).

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.

3 participants