Repository navigation
fix(verify): structural SLSA level + honest missing-tool handling (closes #14, #16) - #18
Merged
Merged
Conversation
…oses #14, #16) #14 — replace the SLSA-level regex (which matched a non-existent 'slsa level' field and always fell back to a hardcoded L2 on any 'verified' text) with structural parsing of 'gh attestation verify --format json'. gh has no explicit level field, so the level is derived honestly: a verified slsa.dev/provenance/v1 attestation is L2; a builder id from slsa-framework/slsa-github-generator (the isolated reusable-workflow builder) is L3. Garbage/prose no longer yields a false L2; a non-provenance predicate yields 0. #16 — surface a missing external tool distinctly instead of a silent level 0: - verifySLSA returns a sentinel errGHMissing when gh is absent (vs gh-ran-and-found- nothing). Verify sets result.SLSAToolMissing and, under --min-slsa-level, fails closed with a clear reason rather than reporting level 0. - Document the required tools (cosign, gh, syft) and the fail-closed behavior in the verify CLI help and the README (+ a Required external tools table). README copyright prose also corrected to Playground Logic LLC. - internal/sbom went from zero tests to covered: Generate runs syft, --attest runs cosign (image only, skipped for local files), missing-syft errors, CycloneDX format. Tests: slsaLevelFromGH (L2 hosted / L3 generator / wrong-predicate / garbage-no-false-L2); toolAvailable for a missing tool; the sbom generator suite. go build/vet/test green; no new deps.
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.
Closes #14 and #16 — the two deferred verify follow-ups.
#14 — SLSA level was a hardcoded heuristic
The old
extractSLSALevelregex matched aslsa levelfield that does not exist ingh attestation verify --format json, so it always fell through toreturn 2on any output containing "verified". Replaced with structural parsing: gh returns an array of verified attestations carrying astatement.predicateType+ provenancepredicate. The level is derived honestly:slsa.dev/provenance/v1attestation → L2;builder.idfromslsa-framework/slsa-github-generator(the isolated reusable-workflow builder) → L3;#16 — silent failures + undocumented deps
verifySLSAnow returns a sentinelerrGHMissingwhenghis absent (distinct from gh-ran-and-found-nothing).VerifysetsSLSAToolMissingand, under--min-slsa-level, fails closed with a clear reason instead of silently reporting level 0. CLI prints "gh CLI not installed" distinctly.vet verifyhelp and a new README Required external tools table.internal/sbomtest coverage (was zero): syft invocation,--attest→cosign (image-only, skipped for local files), missing-syft error, CycloneDX format.Scott Friedman→Playground Logic LLC) the earlier sweep missed.Tests
slsaLevelFromGH(L2 hosted / L3 generator / wrong-predicate / garbage-no-false-L2),toolAvailablemissing-tool, and the sbom generator suite.go build/vet/test ./...green; no new deps.Completes the verify-hardening arc (after #17 closed #13/#15).