Skip to content

fix(monitor): count a file Semgrep labels "Other syntax error" - #23

Open
Portll wants to merge 1 commit into
mainfrom
fix/sarif-other-syntax-error-case
Open

Portll wants to merge 1 commit into
mainfrom
fix/sarif-other-syntax-error-case

Conversation

@Portll

@Portll Portll commented Dec 6, 2026

Copy link
Copy Markdown
Owner

The fault

FILE_OF in monitor/sarif-read.mjs resolves a partial-analysis notice's file from its message text when the notice carries no location, and the main invocation's notices carry none. The syntax/lexical pattern required a capital S:

/^(?:Other )?(?:Syntax|Lexical) error at line (.+?):\d+:/

Semgrep writes Other syntax error with a lower-case s. The pattern did not match, the notice yielded no uri, and fileNotice returned null. The file was dropped from the coverage count entirely.

That is the silent-clean class the list exists to close: a file read only in part, reported as nothing at all.

Measured

On the SDL Hercules-390 sweep (cw-hercules-scan-20261129, develop @ 8ab5c3f1):

before after
file-partial notices 424 424
unattributed 1 0
files read only in part 233 234
syntax-error files 222 223

The one unattributed notice was machdep.h:

Other syntax error at line machdep.h:1:
 Failure: found invalid inline assembler statement as expression

The descriptor id already matched FILE_PARTIAL_IDS, so the reason was known and the file was not. Only the text pattern was case-sensitive.

The fix

A case-insensitive flag on that one pattern. The capitalised form still matches, and both directions are pinned by a test.

Tests

  • monitor/test/unit-sarif-read-partial-analysis.test.mjs — 10/10, including two new cases (lower-case resolves, capitalised still resolves)
  • monitor/test/unit-sarif-read-*.test.mjs + sarif-partial-and-copies, sarif-read-degraded, sarif-read, one-sarif-reader — 193/193
  • bin/test/semgrep-retry.test.mjs — 56/56

Relation to #22

#22 copies files the JSON errors[] names and the notices omit into the SARIF, which masks this symptom when --json is passed. It does not fix it: a SARIF-only run has no JSON, and the notice is still dropped. This is the underlying defect in the reader.

Refs: cw-hercules-scan-20261129 F6

FILE_OF resolves a partial-analysis notice's file from its message text when
the notice carries no location, and the main invocation's notices carry none.
The syntax/lexical pattern required a capital S, but Semgrep writes "Other
syntax error" with a lower-case s. That notice yielded no uri and the file was
dropped from the coverage count. A dropped file reads clean, which is the
silent-clean class the list exists to close.

Measured on the SDL Hercules-390 sweep (2026-11-29): 424 file-partial notices,
1 unattributed, machdep.h ("Other syntax error at line machdep.h:1: Failure:
found invalid inline assembler statement as expression"). The tree's count
moves 233 -> 234 files read only in part, 222 -> 223 syntax-error.

The descriptor id already matched FILE_PARTIAL_IDS. The reason was known and
the file was not. Only the text pattern was case-sensitive. A case-insensitive
flag fixes it without touching the capitalised form, and both directions are
pinned by a test.

Refs: cw-hercules-scan-20261129 F6
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