Skip to content

Commit cd3e36b

Browse files
author
Jake Sanders
authored
move verify-manifest to manifest verify (#712)
Signed-off-by: Jake Sanders <[email protected]>
1 parent 210f7ee commit cd3e36b

File tree

5 files changed

+63
-21
lines changed

5 files changed

+63
-21
lines changed

Diff for: cmd/cosign/cli/manifest/manifest.go

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2021 The Sigstore Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package manifest
16+
17+
import (
18+
"context"
19+
"flag"
20+
21+
"github.com/peterbourgon/ff/v3/ffcli"
22+
)
23+
24+
func Manifest() *ffcli.Command {
25+
var (
26+
flagset = flag.NewFlagSet("cosign manifest", flag.ExitOnError)
27+
)
28+
29+
return &ffcli.Command{
30+
Name: "manifest",
31+
ShortUsage: "cosign manifest",
32+
ShortHelp: "Provides utilities for discovering images in and performing operations on Kubernetes manifests",
33+
FlagSet: flagset,
34+
Subcommands: []*ffcli.Command{VerifyManifest()},
35+
Exec: func(ctx context.Context, args []string) error {
36+
return flag.ErrHelp
37+
},
38+
}
39+
}

Diff for: cmd/cosign/cli/verify_manifest.go renamed to cmd/cosign/cli/manifest/verify.go

+17-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package cli
15+
package manifest
1616

1717
import (
1818
"bytes"
@@ -27,54 +27,55 @@ import (
2727

2828
"github.com/peterbourgon/ff/v3/ffcli"
2929
"github.com/pkg/errors"
30+
"github.com/sigstore/cosign/cmd/cosign/cli"
3031
"k8s.io/apimachinery/pkg/util/yaml"
3132
)
3233

3334
// VerifyManifestCommand verifies all image signatures on a supplied k8s resource
3435
type VerifyManifestCommand struct {
35-
VerifyCommand
36+
cli.VerifyCommand
3637
}
3738

3839
// VerifyManifest builds and returns an ffcli command
3940
func VerifyManifest() *ffcli.Command {
40-
cmd := VerifyManifestCommand{VerifyCommand: VerifyCommand{}}
41-
flagset := flag.NewFlagSet("cosign verify-manifest", flag.ExitOnError)
42-
ApplyVerifyFlags(&cmd.VerifyCommand, flagset)
41+
cmd := VerifyManifestCommand{}
42+
flagset := flag.NewFlagSet("cosign manifest verify", flag.ExitOnError)
43+
cli.ApplyVerifyFlags(&cmd.VerifyCommand, flagset)
4344

4445
return &ffcli.Command{
45-
Name: "verify-manifest",
46-
ShortUsage: "cosign verify-manifest -key <key path>|<key url>|<kms uri> <path/to/manifest>",
46+
Name: "verify",
47+
ShortUsage: "cosign manifest verify -key <key path>|<key url>|<kms uri> <path/to/manifest>",
4748
ShortHelp: "Verify all signatures of images specified in the manifest",
4849
LongHelp: `Verify all signature of images in a Kubernetes resource manifest by checking claims
4950
against the transparency log.
5051
5152
EXAMPLES
5253
# verify cosign claims and signing certificates on images in the manifest
53-
cosign verify-manifest <path/to/my-deployment.yaml>
54+
cosign manifest verify <path/to/my-deployment.yaml>
5455
5556
# additionally verify specified annotations
56-
cosign verify-manifest -a key1=val1 -a key2=val2 <path/to/my-deployment.yaml>
57+
cosign manifest verify -a key1=val1 -a key2=val2 <path/to/my-deployment.yaml>
5758
5859
# (experimental) additionally, verify with the transparency log
59-
COSIGN_EXPERIMENTAL=1 cosign verify-manifest <path/to/my-deployment.yaml>
60+
COSIGN_EXPERIMENTAL=1 cosign manifest verify <path/to/my-deployment.yaml>
6061
6162
# verify images with public key
62-
cosign verify-manifest -key cosign.pub <path/to/my-deployment.yaml>
63+
cosign manifest verify -key cosign.pub <path/to/my-deployment.yaml>
6364
6465
# verify images with public key provided by URL
65-
cosign verify-manifest -key https://host.for/<FILE> <path/to/my-deployment.yaml>
66+
cosign manifest verify -key https://host.for/<FILE> <path/to/my-deployment.yaml>
6667
6768
# verify images with public key stored in Azure Key Vault
68-
cosign verify-manifest -key azurekms://[VAULT_NAME][VAULT_URI]/[KEY] <path/to/my-deployment.yaml>
69+
cosign manifest verify -key azurekms://[VAULT_NAME][VAULT_URI]/[KEY] <path/to/my-deployment.yaml>
6970
7071
# verify images with public key stored in AWS KMS
71-
cosign verify-manifest -key awskms://[ENDPOINT]/[ID/ALIAS/ARN] <path/to/my-deployment.yaml>
72+
cosign manifest verify -key awskms://[ENDPOINT]/[ID/ALIAS/ARN] <path/to/my-deployment.yaml>
7273
7374
# verify images with public key stored in Google Cloud KMS
74-
cosign verify-manifest -key gcpkms://projects/[PROJECT]/locations/global/keyRings/[KEYRING]/cryptoKeys/[KEY] <path/to/my-deployment.yaml>
75+
cosign manifest verify -key gcpkms://projects/[PROJECT]/locations/global/keyRings/[KEYRING]/cryptoKeys/[KEY] <path/to/my-deployment.yaml>
7576
7677
# verify images with public key stored in Hashicorp Vault
77-
cosign verify-manifest -key hashivault://[KEY] <path/to/my-deployment.yaml>`,
78+
cosign manifest verify -key hashivault://[KEY] <path/to/my-deployment.yaml>`,
7879

7980
FlagSet: flagset,
8081
Exec: cmd.Exec,

Diff for: cmd/cosign/cli/verify_manifest_test.go renamed to cmd/cosign/cli/manifest/verify_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package cli
15+
package manifest
1616

1717
import (
1818
"reflect"

Diff for: cmd/cosign/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/sigstore/cosign/cmd/cosign/cli/attach"
3131
"github.com/sigstore/cosign/cmd/cosign/cli/dockerfile"
3232
"github.com/sigstore/cosign/cmd/cosign/cli/download"
33+
"github.com/sigstore/cosign/cmd/cosign/cli/manifest"
3334
"github.com/sigstore/cosign/cmd/cosign/cli/pivcli"
3435
"github.com/sigstore/cosign/cmd/cosign/cli/upload"
3536
)
@@ -56,7 +57,8 @@ func main() {
5657
cli.SignBlob(),
5758
cli.VerifyAttestation(),
5859
cli.VerifyBlob(),
59-
cli.VerifyManifest(),
60+
// Manifest sub-tree
61+
manifest.Manifest(),
6062
// Upload sub-tree
6163
upload.Upload(),
6264
// Download sub-tree

Diff for: test/e2e_test.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ test_image="gcr.io/distroless/base" ./cosign dockerfile verify -key ${DISTROLESS
5858
if (test_image="ubuntu" ./cosign dockerfile verify -key ${DISTROLESS_PUB_KEY} ./test/testdata/with_arg.Dockerfile); then false; fi
5959
./cosign dockerfile verify -key ${DISTROLESS_PUB_KEY} ./test/testdata/with_lowercase.Dockerfile
6060

61-
# Test `cosign verify-manifest`
62-
./cosign verify-manifest -key ${DISTROLESS_PUB_KEY} ./test/testdata/signed_manifest.yaml
63-
if (./cosign verify-manifest -key ${DISTROLESS_PUB_KEY} ./test/testdata/unsigned_manifest.yaml); then false; fi
61+
# Test `cosign manifest verify`
62+
./cosign manifest verify -key ${DISTROLESS_PUB_KEY} ./test/testdata/signed_manifest.yaml
63+
if (./cosign manifest verify -key ${DISTROLESS_PUB_KEY} ./test/testdata/unsigned_manifest.yaml); then false; fi
6464

6565
# Run the built container to make sure it doesn't crash
6666
make ko-local

0 commit comments

Comments
 (0)