Skip to content

[FEA]: Distinguish Semgrep file-level parse errors from a failed scan in Code Risk Analysis #463

Closed

Description

@enes-alatas

Problem to solve

When Semgrep reports a syntax error for a file, Code Risk Analysis marks Semgrep as an incomplete scan, even when Semgrep returns results and the other scanners complete.

In validators/code_risk.py, any nonempty Semgrep errors list causes mark_scan_incomplete("semgrep"). The validator keeps Semgrep findings, but it reports only the first three errors and truncates each message to 100 characters. That makes it hard to identify every affected file, and to tell a partial scan from a Semgrep invocation that failed entirely.

I hit this with public skills containing shell or JavaScript files that Semgrep failed to parse:

In a catalog of 166 public skills, nine reported Semgrep as incomplete. For all nine, the Semgrep errors shown (up to the first three per check) were syntax errors. Six Code Risk Analysis checks had the status incomplete. The other three had the status failed, because Bandit reported findings.

Proposed approach

An unparsed executable file can be a genuine security coverage gap, so keeping the check incomplete may be intentional. Either way, it would help to:

  • Distinguish a partial scan caused by file-level parse errors from an invocation that failed entirely.
  • Report the affected paths, with enough detail to investigate them, including when there are more than three errors.
  • Document the intended status, and suggest how users can resolve the parse errors or check whether they come from Semgrep or its rule configuration.

PR #453 made reference-only caveats visible when SkillSpector's file and analyzer coverage was otherwise complete. A Semgrep parse error may be a real coverage gap, so I'm not assuming it should get the same status. I'm asking whether a similar distinction in reporting would be useful.

Additional context

To reproduce:

  1. Check out trailofbits/skills at e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff.

  2. Copy the plugins/static-analysis/skills/semgrep folder out of the checkout.

  3. Run Tier 1 on the copy, in the Tier 1 image pinned by the 0.8.0 bundle:

    skillevaluator tier1 <copy-of-semgrep-skill> --no-llm -r json -o <reports-dir>
  4. Inspect the Code Risk Analysis result. Semgrep is listed in incomplete_scans, with a syntax error for scripts/run-scans.sh.

I saw the same behaviour with and without network access. I haven't tested running it inside the full repository checkout.

Version: the Tier 1 image pinned by the 0.8.0 bundle.

ghcr.io/nvidia/skillevaluator-tier1@sha256:9d5483243918937be4f2178f74cf7c622a531dee41e3176906994d52fa14950a
Semgrep 1.182.0

The error handling described above is unchanged on main at 43a66115.

Before submitting

Activity

  1. added
    enhancement
    on Nov 12, 2026
  2. self-assigned this
    on Nov 12, 2026
  3. added a commit that references this issue on Nov 13, 2026
    9f068de
  4. lucas-saldanha-werneck commented on Nov 13, 2026

    @lucas-saldanha-werneck
    Contributor

    A second public repro, this time for a valid bash construct that Semgrep's bash parser does not accept.

    skills/web-unlock/bin/chrome-real.sh in https://github.com/lucas-saldanha-werneck/web-unlock contains exec 3<>"/dev/tcp/127.0.0.1/$PORT". bash -n and ShellCheck accept the script. With Semgrep 1.182.0 (the version in the 0.8.0 Tier 1 image) and the repository's semgrep_rules.yaml, the JSON errors list has one entry:

    {"code": 3, "level": "warn",
     "type": ["PartialParsing", [{"path": "...", "start": {"line": 3, "col": 8}, "end": {"line": 3, "col": 9}}]],
     "message": "Syntax error at line ...:3:\n `>` was unexpected"}

    Two details from this output that may help the design:

    So a PartialParsing entry can be reported as a coverage warning naming the file and span, while other error types can keep the scan incomplete. I'm preparing a small PR along those lines.

  5. chrisknvidia commented on Nov 13, 2026

    @chrisknvidia
    Collaborator

    Thanks for the reports and the extra repro. #475 is merged: Semgrep file-level parse errors, including the PartialParsing entries where type is a list, are now reported as one partial-scan message that names every unparsed file and line, and the full list is kept in the report metadata. The check stays incomplete because those files were not scanned. If you think PartialParsing alone should be a warning instead, say so here and we can look at it.

  6. chrisknvidia commented on Nov 13, 2026

    @chrisknvidia
    Collaborator

    The fix is merged in #475 and will ship with the next release. File-level Semgrep parse errors now give one partial-scan error that names up to 20 unparsed files, relative to the skill and with the line of the first error. The JSON report lists every file in semgrep_unparsed_files (up to 1,000, with semgrep_unparsed_files_omitted counting the rest). The check stays incomplete, because Semgrep skips the code it cannot parse, and findings for the other files are kept.

    @enes-alatas, could you check it against the public skills you hit this with? I reopened this (it closed automatically when the PR merged) and will leave it open for a day or two so you can confirm. If it works for you I'll close it.

  7. added a commit that references this issue on Nov 13, 2026
    957e8ff
  8. rng1995 commented on Nov 13, 2026

    @rng1995
    Collaborator

    Addressed on main by #475 (957e8ff6).

    Code Risk Analysis now reports Semgrep file-level parse errors as a single partial-scan error that names up to 20 unparsed files, each relative to the skill and carrying the line of its first error, instead of the first three messages truncated to 100 characters. That makes every affected file identifiable, which was the core of this request.

    On the part of the request about telling a partial scan from a failed invocation: the check still reports incomplete, deliberately. Semgrep genuinely skips the code it cannot parse, so the scan did not cover everything, and reporting it as complete would overstate the coverage. What changed is that the record now says which files were skipped and why, so a partial scan is distinguishable from a Semgrep run that failed outright by reading the error rather than by the status alone.

    Closing as resolved. If the incomplete status itself is still a problem for your workflow — for example if it blocks a gate you need to pass — that is worth a separate issue, since it is a policy question rather than a reporting one.

  9. enes-alatas commented on Nov 14, 2026

    @enes-alatas
    Author

    @chrisknvidia Thanks for the quick solution! I confirmed #475 on main against both skills from the report, running skillevaluator tier1 <skill> --no-llm with Semgrep 1.182.0:

    • trailofbits/skills plugins/static-analysis/skills/semgrep at e4dd0bb5: one partial-scan message naming scripts/run-scans.sh:6, and semgrep_unparsed_files lists it. 0.8.0 gave a truncated message with an absolute path.
    • Leonxlnx/taste-skill skills/taste-skill at f6b76575: one message naming scripts/copy-lint.mjs:85 and scripts/moments.mjs:484, and both are in semgrep_unparsed_files.

    @rng1995 Keeping the check incomplete sounds fair enough to me. Those files really weren't scanned, and the record now says which ones and why, which is what I needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions