Add Sigstore signer package for skill OCI artifacts - #6023
Open
samuv wants to merge 2 commits into
Open
Conversation
Skills pushed to OCI registries need signatures so installs can be verified against the lock file's recorded provenance (RFC THV-0080). This adds pkg/skills/signer: cosign key-pair signing that signs the simple-signing payload (binding the artifact's manifest digest), pushes the classic cosign signature manifest at the sha256-<hex>.sig tag for interop with `cosign verify --key`, and returns the serialized Sigstore bundle for durable storage and offline re-verification. The signature is computed once over the payload and reused for both the registry manifest annotation and the returned bundle, so a verifier reconstructing the bundle from the registry checks exactly the signature that was attached. Encrypted keys are decrypted via COSIGN_PASSWORD, matching the cosign CLI. Key paths are canonicalized (absolute, symlinks resolved, regular-file check) before opening. Part of #5899; consumed by the push-signing and install-verification PRs in this stack. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6023 +/- ##
==========================================
+ Coverage 72.14% 72.17% +0.02%
==========================================
Files 720 724 +4
Lines 74772 75129 +357
==========================================
+ Hits 53945 54221 +276
- Misses 16953 17027 +74
- Partials 3874 3881 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Cover input-validation failures (garbage key, bad reference, malformed digest), bare-hex digest normalization, the payload's digest/repository binding, and the sigstore Keypair metadata accessors, raising patch coverage flagged by codecov. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Note
Stack 2 of RFC THV-0080 (tracking issue #5899) — PR 9 of the Sigstore signing/verification series. Follows #6015 (provenance schema, merged). Parallel with the verifier wrapper PR, which blocks on stacklok/toolhive-core#192. This package has no consumers yet; push-signing and install-verification PRs later in the stack wire it in.
Summary
Skills pushed to OCI registries need signatures so installs can be verified against the lock file's recorded provenance (RFC THV-0080). This PR adds
pkg/skills/signer, the signing half of that trust model:COSIGN_PASSWORDhonored for encrypted keys, matching the cosign CLI), signs the artifact via sigstore-go.cosign verify --keyand toolhive-core's bundle reconstruction both expect. The POC (Add project-level skills lock file (POC) #5715) signed the manifest-digest bytes directly and produced two different signatures (attached vs. bundled); here the signature is computed once and reused for both representations, so a verifier reconstructing the bundle from the registry checks exactly the signature that was attached.sha256-<hex>.sigtag with the simple-signing payload as its single layer and the signature in the layer annotation — a deliberate interop choice so existing Sigstore registry tooling can discover and verify it.resolveKeyPathcanonicalizes the user-supplied--keypath (absolute, cleaned, symlinks resolved, regular-file check) before opening — no#nosec/string-inspection shortcuts.Keyless (OIDC) signing is intentionally not implemented (
ErrKeyRequired); it is a tracked follow-up per the Stack 1 review decision.Type of change
Test plan
task test)task lint-fix, 0 issues)httptest+registry.New(), zero network) proving the returned bundle verifies against the signing public key over the payload digest, the.sigmanifest layer is the exact signed payload, and the annotation signature equals the bundle's message signature; wrong-key rejection; encrypted-key decryption viaCOSIGN_PASSWORD(right and wrong password);ErrKeyRequired;resolveKeyPathmatrix (regular file / directory / missing / empty).Does this introduce a user-facing change?
No — the package has no callers yet. The
thv skill push --keyflag lands with the push-signing PR at the end of the stack.Special notes for reviewers
verifyKeyBundlehelper mirrors toolhive-core's upcomingVerifyBundleWithKey(Export Sigstore bundle retrieval, offline verification, and identity API toolhive-core#192) using sigstore-go directly; once the core release lands and the verifier wrapper PR bumps go.mod, that helper is the contract the install-verification E2E relies on.sigstore-go,sigstore, andprotobuf-specspromoted from indirect to direct (already in the dependency graph via toolhive-core — no new modules).Generated with Claude Code