Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Go
bin/
attestor
/stamp
*.exe
*.exe~
*.dll
Expand Down
29 changes: 29 additions & 0 deletions cmd/stamp/container.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2025 Thomson Reuters
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package stamp

import (
"github.com/spf13/cobra"
)

var containerCmd = &cobra.Command{
Use: "container",
Short: "Operations on container images",
Long: `Container image operations such as signing.`,
}

func init() {
rootCmd.AddCommand(containerCmd)
}
90 changes: 90 additions & 0 deletions cmd/stamp/container_sign.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright 2025 Thomson Reuters
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package stamp

import (
"github.com/spf13/cobra"
"github.com/thomsonreuters/stamp/pkg/config/flags"
"github.com/thomsonreuters/stamp/pkg/errors"
"github.com/thomsonreuters/stamp/pkg/operations"
plugincobra "github.com/thomsonreuters/stamp/plugins/cobra"
)

var containerSignCmd = &cobra.Command{
Use: "sign <image-reference>",
Short: "Sign a container image and emit a sigstore Bundle v0.3",
Long: `Sign a container image and emit a sigstore Bundle v0.3.

The image reference is resolved to a manifest digest, wrapped in a
cosign-shaped in-toto Statement, and signed via sigstore-go's sign.Bundle.
Fulcio keyless signing is supported via --signer fulcio.

Transparency:
Pass --rekor to upload the signed bundle to a transparency log
(--rekor-url overrides the default endpoint).

Registry authentication:
Set REGISTRY_USERNAME and REGISTRY_PASSWORD in the environment for
authenticated registries; leaving them unset falls back to the Docker
keychain (which covers anonymous pulls of public images).`,
Example: ` # Key-based signing (no Rekor upload)
stamp container sign registry.example.com/app:v1 \
--signer key --private-key ./cosign.key \
--bundle-output ./bundle.json

# Encrypted key: prompt for the password at runtime and overwrite any
# existing bundle file at --bundle-output.
stamp container sign registry.example.com/app:v1 \
--signer key --private-key ./cosign.key --prompt \
--bundle-output ./bundle.json --overwrite

# Keyless signing with a custom Rekor instance
stamp container sign registry.example.com/app:v1 \
--signer fulcio --oidc-token-file ./token \
--rekor --rekor-url https://rekor.example.com \
--bundle-output ./bundle.json

# Signing an ECR image using AWS-derived static credentials
export REGISTRY_USERNAME=AWS
export REGISTRY_PASSWORD=$(aws ecr get-login-password --region us-east-1)
stamp container sign \
123456789012.dkr.ecr.us-east-1.amazonaws.com/app:v1 \
--signer key --private-key ./cosign.key --bundle-output bundle.json`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return errors.NewUsageError("exactly one image reference required",
"Example: stamp container sign registry.example.com/app:v1")
}

op := operations.NewContainerSignOp(rootConfig, rootLogger, rootOutput)
if err := op.Validate(args[0]); err != nil {
return err
}
return op.Execute(cmd.Context(), args[0])
},
}

func init() {
_ = plugincobra.ApplyFlagGroup(containerSignCmd, flags.SigningFlags)
_ = plugincobra.ApplyFlagGroup(containerSignCmd, flags.FulcioServerFlags)
_ = plugincobra.ApplyFlagGroup(containerSignCmd, flags.PrivateKeyFlags)
_ = plugincobra.ApplyFlagGroup(containerSignCmd, flags.PasswordFlags)
_ = plugincobra.ApplyFlagGroup(containerSignCmd, flags.RekorEnableFlags)
_ = plugincobra.ApplyFlagGroup(containerSignCmd, flags.RekorServerFlags)
_ = plugincobra.ApplyFlagGroup(containerSignCmd, flags.ContainerSignFlags)

containerCmd.AddCommand(containerSignCmd)
}
91 changes: 76 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ require (
github.com/CycloneDX/cyclonedx-go v0.11.0
github.com/bmatcuk/doublestar/v4 v4.10.0
github.com/golang-jwt/jwt/v5 v5.3.1
github.com/google/go-containerregistry v0.21.6
github.com/google/uuid v1.6.0
github.com/invopop/jsonschema v0.14.0
github.com/klauspost/compress v1.18.6
github.com/lestrrat-go/jwx/v2 v2.1.6
github.com/sigstore/protobuf-specs v0.5.1
github.com/sigstore/sigstore v1.10.8
github.com/sigstore/sigstore-go v1.2.1
github.com/spdx/tools-golang v0.5.7
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
Expand All @@ -19,56 +22,114 @@ require (
github.com/stretchr/testify v1.11.1
github.com/transparency-dev/merkle v0.0.2
github.com/zeebo/blake3 v0.2.4
go.step.sm/crypto v0.83.0
golang.org/x/sync v0.21.0
golang.org/x/sys v0.46.0
golang.org/x/term v0.44.0
go.step.sm/crypto v0.81.0
golang.org/x/sync v0.20.0
golang.org/x/sys v0.45.0
golang.org/x/term v0.43.0
google.golang.org/protobuf v1.36.11
gopkg.in/yaml.v3 v3.0.1
)

require (
filippo.io/edwards25519 v1.2.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/anchore/go-struct-converter v0.1.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/buger/jsonparser v1.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coreos/go-oidc/v3 v3.17.0 // indirect
github.com/cyberphone/json-canonicalization v0.0.0-20241213102144-19d51d7fe467 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 // indirect
github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 // indirect
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect
github.com/docker/cli v29.4.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.9.3 // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.25.2 // indirect
github.com/go-openapi/errors v0.22.7 // indirect
github.com/go-openapi/jsonpointer v0.23.1 // indirect
github.com/go-openapi/jsonreference v0.21.6 // indirect
github.com/go-openapi/loads v0.23.3 // indirect
github.com/go-openapi/runtime v0.32.3 // indirect
github.com/go-openapi/runtime/server-middleware v0.30.0 // indirect
github.com/go-openapi/spec v0.22.5 // indirect
github.com/go-openapi/strfmt v0.26.3 // indirect
github.com/go-openapi/swag v0.26.0 // indirect
github.com/go-openapi/swag/cmdutils v0.26.0 // indirect
github.com/go-openapi/swag/conv v0.26.0 // indirect
github.com/go-openapi/swag/fileutils v0.26.0 // indirect
github.com/go-openapi/swag/jsonname v0.26.0 // indirect
github.com/go-openapi/swag/jsonutils v0.26.0 // indirect
github.com/go-openapi/swag/loading v0.26.0 // indirect
github.com/go-openapi/swag/mangling v0.26.0 // indirect
github.com/go-openapi/swag/netutils v0.26.0 // indirect
github.com/go-openapi/swag/stringutils v0.26.0 // indirect
github.com/go-openapi/swag/typeutils v0.26.0 // indirect
github.com/go-openapi/swag/yamlutils v0.26.0 // indirect
github.com/go-openapi/validate v0.25.3 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/goccy/go-json v0.10.6 // indirect
github.com/google/go-containerregistry v0.21.6 // indirect
github.com/google/certificate-transparency-go v1.3.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
github.com/in-toto/attestation v1.2.0 // indirect
github.com/in-toto/in-toto-golang v0.11.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.4 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.6 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/oklog/ulid/v2 v2.1.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/pb33f/ordered-map/v2 v2.3.1 // indirect
github.com/pelletier/go-toml/v2 v2.3.1 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rogpeppe/go-internal v1.15.0 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/sassoftware/relic v7.2.1+incompatible // indirect
github.com/secure-systems-lab/go-securesystemslib v0.11.0 // indirect
github.com/segmentio/asm v1.2.1 // indirect
github.com/sigstore/protobuf-specs v0.5.1 // indirect
github.com/shibumi/go-pathspec v1.3.0 // indirect
github.com/sigstore/rekor v1.5.2 // indirect
github.com/sigstore/rekor-tiles/v2 v2.2.2-0.20260601073857-5d098a2b6443 // indirect
github.com/sigstore/timestamp-authority/v2 v2.1.2 // indirect
github.com/sirupsen/logrus v1.9.4 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/stretchr/objx v0.5.3 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/theupdateframework/go-tuf v0.7.0 // indirect
github.com/theupdateframework/go-tuf/v2 v2.4.2-0.20260407074541-7e8f69f906ef // indirect
github.com/transparency-dev/formats v0.1.1 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel v1.44.0 // indirect
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
go.yaml.in/yaml/v4 v4.0.0-rc.5 // indirect
golang.org/x/crypto v0.53.0 // indirect
golang.org/x/net v0.56.0 // indirect
golang.org/x/text v0.38.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect
go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect
golang.org/x/crypto v0.52.0 // indirect
golang.org/x/mod v0.36.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/text v0.37.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260523011958-0a33c5d7ca68 // indirect
google.golang.org/grpc v1.81.1 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gotest.tools/v3 v3.5.2 // indirect
k8s.io/klog/v2 v2.140.0 // indirect
)
Loading
Loading