Bind the semgrep-core binary into analyzer receipts#21
Merged
Conversation
Receipts already named the rules bytes via config_sha256, but the scanner that produced the findings was only an operator-set version string. Add tool_sha256 to AnalyzerIdentity: roomd hashes the binary named by ROOM_ANALYZER_TOOL_FILE into the analyzer identity (bytes are discarded, never retained), sends the digest in every provider request, and room-semgrep fails closed with tool_digest_mismatch unless the request names the binary it pinned at startup. The tool path is resolved through symlinks so pipx-style installs keep working, and re-resolved on every diff request so a swapped or upgraded binary fails until the adapter restarts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
config_sha256); the scanner itself was only an operator-set version string.AnalyzerIdentitygainstool_sha256(proto field 4, wire-safe), stamped onto every receipt and signal like the config digest.ROOM_ANALYZER_TOOL_FILEpoints roomd at thesemgrep-corebinary; its SHA-256 goes into the analyzer identity and every provider request (tool_sha256), and the bytes are discarded after hashing (a 204 MB binary never stays resident).room-semgreppins the binary at startup (symlinks resolved, so pipx-style installs keep working;O_NOFOLLOWregular-file read, fstat-checked) and fails closed withtool_digest_mismatchwhen the request digest is missing/wrong or the binary changed on disk since startup. Adapter restart required after upgrades; documented indocs/analyzer.md.internal/review) now rejects malformed tool digests in both the registry and compiler paths.Deployment note: with the stock
room-semgrepadapter,ROOM_ANALYZER_TOOL_FILEis effectively required — DIFF requests without a matching digest fail closed. PLAN-phasePARTIALbehavior is unchanged (no coverage claimed).Test plan
tool_digest_mismatch; symlinked tool accepted and bound to its regular target (dangling rejected); on-disk binary change after startup → fail closed; server-side identity/request stamping incl. tool-bytes discard; short-digest rejection in registry and compilergo test ./...,go vet,gofmtclean;buf format/lint/generateidempotentROOM_SEMGREP_CORE=… go test -tags=semgrep_integration ./cmd/room-semgrep— realsemgrep-core1.139.0 suite passes, including via the symlinked~/.local/bin/semgrep-corepath