A scanner that fails but prints parseable JSON is reported as a clean run

Open
#180 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go

Research direction

Read internal/seed/external.go around Run and semgrepReport, then inspect internal/seed/subprocess_test.go and the recorded fixture under internal/seed/testdata/real/. Add the missing valid-empty-report/non-zero-exit case and cover Semgrep error entries and its findings-present exit code. Run make test-short (or .\make.ps1 test-short on Windows) and make lint; done means all acceptance criteria pass.

Written by the indexing model from the issue text.

Description

help wanted reliability severity: medium

Summary

The external scanner adapter looks at the exit status only when the report cannot be decoded. A scanner that exits with a fatal error while still printing an empty, valid report is recorded as available with zero leads and no error.

Where

  • internal/seed/external.go:382-392 (Run: runErr dropped when the report decodes)
  • internal/seed/external.go:628-649 (semgrepReport decodes only results)
  • internal/seed/subprocess_test.go:88 (no case for non-zero exit with a valid empty report)

Details

The comment says scanners exit non-zero when they find something, so the exit status is only consulted when the report cannot be read. When the report decodes, the run error is dropped whatever the exit code. Semgrep's top-level errors array (present in the recorded fixture under internal/seed/testdata/real/) is not read.

Assumption (not run during the audit): on a fatal error such as a rule pack that cannot be downloaded or a rule file that does not parse, semgrep prints a report with errors and empty results and exits with a failure code.

Impact

Spackle records semgrep: available, leads 0 with no error, which reads exactly like a scan that found nothing. Per-file scanner errors (timeouts, parse failures) are lost the same way. This contradicts the adapter's own stated rule that dropping results is reported, never silent. Any adapter whose tool exits non-zero for a real failure while writing an empty report has the same hole.

Suggested fix

Give each adapter the exit codes that mean "ran to the end" and return an error, with the scrubbed stderr, for any other code even when stdout decodes. Decode semgrep's errors and count them in the parse statistics so partial failures appear in the seeder note.

Acceptance criteria

  • Each adapter declares its success exit codes
  • Table case: valid empty report with a failure exit code returns an error
  • Semgrep errors entries appear in the seeder note
  • A scanner that exits with its "findings present" code still succeeds

Related: #95, #39

Getting started

  • Relevant files: internal/seed/external.go, internal/seed/subprocess_test.go
  • How to run tests: make test-short (Unix) or .\make.ps1 test-short (Windows PowerShell); make lint before you call it done
  • Related docs: CONTRIBUTING.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at 50e92ec. Severity: medium. Effort: M. audit-key: reliability|internal/seed/external.go|external.Run-exit-status

Dominant language
Go
Stars
0
Forks
1
Avg merge
8h 14m
Merged PRs (30d)
3

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TMHSDigital/Spackle

All issues in TMHSDigital/Spackle

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.