Repository navigation
Sign plugin pushes and remove the lock feature gate #6438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
fbdb8be
Sign plugin pushes and remove the lock gate
samuv 8ba82e5
Document the plugins trust model
samuv 54d0ca5
Address review on plugin push signing
samuv 1c286d6
Link the key-signing gap issue from the trust doc
samuv 1fc2a7d
Drop --key from plugin push
samuv 92a8a70
Harden the plugin push contract
samuv 9b9023b
Withhold identity tokens from plaintext HTTP
samuv 46bee1c
Persist a freshly verified bundle over a stale one
samuv 63c2921
Treat lock entries with no trust decision as drift
samuv da59199
Offer only flags the push command defines
samuv 41b6a33
Return silently from a user-scope plugin install
samuv b9bb412
Cover plugin push signing in E2E tests
samuv 9a3a22a
Correct the plugins trust model documentation
samuv a64acfb
Refuse redirects on token-bearing pushes
samuv 70f35c3
Require consent to migrate an unsigned lock entry
samuv 807d43b
Show when a lock entry records no trust decision
samuv 47dbc23
Document consent in the lock entry migration
samuv 182ecd5
Rematerialize when an install first locks a record
samuv 24cea9c
Describe both uses of sync --allow-unsigned
samuv 83780e5
Refuse signed pushes to digest-pinned references
samuv 406ccb6
Bind stored bundles to the artifact digest
samuv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| // SPDX-FileCopyrightText: Copyright 2025 Stacklok, Inc. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package app | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/stacklok/toolhive/pkg/plugins" | ||
| ) | ||
|
|
||
| // TestAIPluginPushSigningFlags pins the signed-by-default publish surface: | ||
| // the keyless flags must exist, the opt-out must not be preset (a defaulted | ||
| // --no-sign would publish unsigned artifacts silently), and --key must NOT be | ||
| // offered — ToolHive cannot verify key-signed artifacts at install time, so | ||
| // the flag would only produce uninstallable plugins (#6442). Re-add it in the | ||
| // change that makes key verification work. | ||
| func TestAIPluginPushSigningFlags(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| for _, name := range []string{"identity-token", "no-sign"} { | ||
| flag := aiPluginPushCmd.Flags().Lookup(name) | ||
| require.NotNil(t, flag, "thv ai-plugin push must expose --%s", name) | ||
| } | ||
| assert.Nil(t, aiPluginPushCmd.Flags().Lookup("key"), | ||
| "plugin signing is keyless-only; --key must not be advertised until install can verify it") | ||
| assert.Equal(t, "false", aiPluginPushCmd.Flags().Lookup("no-sign").DefValue, | ||
| "pushing unsigned must always be an explicit choice") | ||
| assert.Empty(t, aiPluginPushCmd.Flags().Lookup("identity-token").DefValue) | ||
| } | ||
|
|
||
| // TestPrintAIPluginInfoTextTrustStates covers each trust state the info | ||
| // command renders. RFC THV-0080 wants the pinned identity visible at read | ||
| // time, so a state that silently renders as "no trust block" is a bug. | ||
| // | ||
| //nolint:paralleltest // captures os.Stdout, which cannot be done in parallel | ||
| func TestPrintAIPluginInfoTextTrustStates(t *testing.T) { | ||
| signed := &plugins.ProvenanceInfo{ | ||
| SignerIdentity: "/.github/workflows/release.yml", | ||
| CertIssuer: "https://token.actions.githubusercontent.com", | ||
| } | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| info plugins.PluginInfo | ||
| wantLines []string | ||
| wantAbsent []string | ||
| }{ | ||
| { | ||
| name: "signed", | ||
| info: plugins.PluginInfo{Provenance: signed}, | ||
| wantLines: []string{ | ||
| "Signed by: /.github/workflows/release.yml", | ||
| "Cert issuer: https://token.actions.githubusercontent.com", | ||
| }, | ||
| wantAbsent: []string{"provisional", "unsigned"}, | ||
| }, | ||
| { | ||
| name: "provisional", | ||
| info: plugins.PluginInfo{Provenance: &plugins.ProvenanceInfo{ | ||
| SignerIdentity: signed.SignerIdentity, | ||
| CertIssuer: signed.CertIssuer, | ||
| Provisional: true, | ||
| }}, | ||
| wantLines: []string{"Signed by: /.github/workflows/release.yml (provisional)"}, | ||
| }, | ||
| { | ||
| name: "unsigned exception", | ||
| info: plugins.PluginInfo{Unsigned: true}, | ||
| wantLines: []string{"Signed by: (unsigned — explicit exception)"}, | ||
| wantAbsent: []string{"Cert issuer"}, | ||
| }, | ||
| { | ||
| // The state sync reports as drift. It must read differently from | ||
| // "no lock entry", which prints no trust line at all, and it has | ||
| // to name the command that repairs it. | ||
| name: "trust unrecorded", | ||
| info: plugins.PluginInfo{TrustUnrecorded: true}, | ||
| wantLines: []string{"Signed by: (trust unrecorded — run 'thv ai-plugin sync')"}, | ||
| wantAbsent: []string{"Cert issuer", "explicit exception"}, | ||
| }, | ||
| { | ||
| name: "no lock entry", | ||
| info: plugins.PluginInfo{}, | ||
| wantAbsent: []string{"Signed by", "Cert issuer"}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| tt.info.Metadata = plugins.PluginMetadata{Name: "my-plugin", Version: "1.0.0"} | ||
|
|
||
| // The tabwriter pads labels to the widest one in the block, which | ||
| // differs per case; collapse runs of spaces so the assertions | ||
| // pin the content rather than the alignment. | ||
| out := strings.Join(strings.Fields( | ||
| captureStdout(t, func() { printAIPluginInfoText(&tt.info) }), | ||
| ), " ") | ||
|
|
||
| for _, want := range tt.wantLines { | ||
| assert.Contains(t, out, want) | ||
| } | ||
| for _, absent := range tt.wantAbsent { | ||
| assert.NotContains(t, out, absent) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| // TestPrintPluginInstallTrust proves install reports the trust state it | ||
| // recorded, rather than leaving the user to discover the pinned identity | ||
| // weeks later inside a signer-mismatch error. | ||
| // | ||
| //nolint:paralleltest // captures os.Stdout, which cannot be done in parallel | ||
| func TestPrintPluginInstallTrust(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| result *plugins.InstallResult | ||
| want string | ||
| }{ | ||
| { | ||
| name: "signed", | ||
| result: &plugins.InstallResult{ | ||
| Plugin: plugins.InstalledPlugin{Metadata: plugins.PluginMetadata{Name: "my-plugin"}}, | ||
| Provenance: &plugins.ProvenanceInfo{SignerIdentity: "/.github/workflows/release.yml"}, | ||
| }, | ||
| want: "Installed my-plugin (signed by /.github/workflows/release.yml)\n", | ||
| }, | ||
| { | ||
| name: "provisional", | ||
| result: &plugins.InstallResult{ | ||
| Plugin: plugins.InstalledPlugin{Metadata: plugins.PluginMetadata{Name: "my-plugin"}}, | ||
| Provenance: &plugins.ProvenanceInfo{ | ||
| SignerIdentity: "/.github/workflows/release.yml", | ||
| Provisional: true, | ||
| }, | ||
| }, | ||
| want: "Installed my-plugin (signed by /.github/workflows/release.yml; " + | ||
| "verification provisional — see lock file)\n", | ||
| }, | ||
| { | ||
| name: "unsigned exception", | ||
| result: &plugins.InstallResult{ | ||
| Plugin: plugins.InstalledPlugin{Metadata: plugins.PluginMetadata{Name: "my-plugin"}}, | ||
| Unsigned: true, | ||
| }, | ||
| want: "Installed my-plugin (unsigned — recorded as an explicit exception in the lock file)\n", | ||
| }, | ||
| { | ||
| // A user-scope install records no lock trust decision, so there | ||
| // is nothing trust-related to report and the CLI's silent-success | ||
| // rule applies: a bare "Installed my-plugin" would turn every | ||
| // previously quiet install into output while saying nothing about | ||
| // trust. | ||
| name: "user scope, no trust state, prints nothing", | ||
| result: &plugins.InstallResult{ | ||
| Plugin: plugins.InstalledPlugin{Metadata: plugins.PluginMetadata{Name: "my-plugin"}}, | ||
| }, | ||
| want: "", | ||
| }, | ||
| {name: "nil result prints nothing", result: nil, want: ""}, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| assert.Equal(t, tt.want, captureStdout(t, func() { printPluginInstallTrust(tt.result) })) | ||
| }) | ||
| } | ||
| } |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.