Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into conf_main_pin
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Callaway <[email protected]>
  • Loading branch information
bobcallaway committed Dec 16, 2024
2 parents 394eb00 + 3837f01 commit 79dedae
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

- uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0

- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
persist-credentials: false

- name: Utilize Go Module Cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/go/pkg/mod
Expand All @@ -66,7 +66,7 @@ jobs:
${{ runner.os }}-go-
- name: Set correct version of Golang to use during CodeQL run
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand All @@ -57,7 +57,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
- name: setup vault
uses: cpanato/vault-installer@e7c1d664fa15219e89e43739e39a9df11ba00849 # v1.2.0

- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-with-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/github-oidc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand All @@ -55,7 +55,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/kind-verify-attestation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand All @@ -62,7 +62,7 @@ jobs:
- uses: ko-build/setup-ko@3aebd0597dc1e9d1a26bcfdb7cbeb19c131d3037 # v0.7

- name: Install yq
uses: mikefarah/yq@bc5b54cb1d1f720db16c9f75c5b45384d00e5cbf # v4.44.5
uses: mikefarah/yq@4839dbbf80445070a31c7a9c1055da527db2d5ee # v4.44.6

- name: build cosign
run: |
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
with:
persist-credentials: false
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
# In order:
# * Module download cache
Expand All @@ -60,7 +60,7 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand All @@ -70,7 +70,7 @@ jobs:
GODEBUG: x509sha1=1
run: go test -tags=sct -covermode atomic -coverprofile coverage.txt $(go list ./... | grep -v third_party/)
- name: Upload Coverage Report
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1
with:
env_vars: OS
- name: Run Go tests w/ `-race`
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
- name: check disk space
run: df -h
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
# In order:
# * Module download cache
Expand All @@ -159,7 +159,7 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand All @@ -186,13 +186,13 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true

# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
# In order:
# * Module download cache
Expand All @@ -216,7 +216,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-docgen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: 'go.mod'
check-latest: true
Expand Down
18 changes: 14 additions & 4 deletions cmd/cosign/cli/copy/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ func CopyCmd(ctx context.Context, regOpts options.RegistryOptions, srcImg, dstIm
}

onlyFlagSet := false
tags := parseOnlyOpt(copyOnly, sigOnly)
tags, err := parseOnlyOpt(copyOnly, sigOnly)
if err != nil {
return err
}
if len(tags) > 0 {
onlyFlagSet = true
} else {
Expand Down Expand Up @@ -180,13 +183,20 @@ func remoteCopy(ctx context.Context, pusher *remote.Pusher, src, dest name.Refer
return pusher.Push(ctx, dest, got)
}

func parseOnlyOpt(onlyFlag string, sigOnly bool) []tagMap {
func parseOnlyOpt(onlyFlag string, sigOnly bool) ([]tagMap, error) {
var tags []tagMap
tagSet := sets.New(strings.Split(onlyFlag, ",")...)

if sigOnly {
fmt.Fprintf(os.Stderr, "--sig-only is deprecated, use --only=sig instead")
tagSet.Insert("sign")
tagSet.Insert("sig")
}

validTags := sets.New("sig", "sbom", "att")
for tag := range tagSet {
if !validTags.Has(tag) {
return nil, fmt.Errorf("invalid value for --only: %s, only following values are supported, %s", tag, validTags)
}
}

if tagSet.Has("sig") {
Expand All @@ -198,5 +208,5 @@ func parseOnlyOpt(onlyFlag string, sigOnly bool) []tagMap {
if tagSet.Has("att") {
tags = append(tags, ociremote.AttestationTag)
}
return tags
return tags, nil
}
2 changes: 1 addition & 1 deletion cmd/cosign/cli/options/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (o *CopyOptions) AddFlags(cmd *cobra.Command) {
o.Registry.AddFlags(cmd)

cmd.Flags().StringVar(&o.CopyOnly, "only", "",
"custom string array to only copy specific items, this flag is comma delimited. ex: --only=sbom,sign,att")
"custom string array to only copy specific items, this flag is comma delimited. ex: --only=sig,att,sbom")

cmd.Flags().BoolVar(&o.SignatureOnly, "sig-only", false,
"[DEPRECATED] only copy the image signature")
Expand Down
12 changes: 6 additions & 6 deletions cmd/cosign/cli/pivcli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"os"
"strings"

"github.com/go-piv/piv-go/piv"
"github.com/go-piv/piv-go/v2/piv"
"github.com/manifoldco/promptui"

"github.com/sigstore/cosign/v2/pkg/cosign/pivkey"
Expand All @@ -46,7 +46,7 @@ func SetManagementKeyCmd(_ context.Context, oldKey, newKey string, randomKey boo
if err != nil {
return err
}
var newBytes *[24]byte
var newBytes *[]byte
if randomKey {
if !Confirm("Resetting management key to random value. You must factory reset the device to change this value") {
return nil
Expand Down Expand Up @@ -286,14 +286,14 @@ func ResetKeyCmd(ctx context.Context) error {
return yk.Reset()
}

func keyBytes(s string) (*[24]byte, error) {
func keyBytes(s string) (*[]byte, error) {
if s == "" {
return &piv.DefaultManagementKey, nil
}
if len(s) > 24 {
return nil, errors.New("key too long, must be <24 characters")
}
ret := [24]byte{}
ret := []byte{}
copy(ret[:], s)
return &ret, nil
}
Expand All @@ -312,8 +312,8 @@ var Confirm = func(p string) bool {
return strings.ToLower(result) == "y"
}

func randomManagementKey() (*[24]byte, error) {
var newKeyBytes [24]byte
func randomManagementKey() (*[]byte, error) {
var newKeyBytes []byte
n, err := io.ReadFull(rand.Reader, newKeyBytes[:])
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion doc/cosign_copy.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/go-openapi/runtime v0.28.0
github.com/go-openapi/strfmt v0.23.0
github.com/go-openapi/swag v0.23.0
github.com/go-piv/piv-go v1.11.0
github.com/go-piv/piv-go/v2 v2.3.0
github.com/google/certificate-transparency-go v1.3.0
github.com/google/go-cmp v0.6.0
github.com/google/go-containerregistry v0.20.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+Gr
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/go-openapi/validate v0.24.0 h1:LdfDKwNbpB6Vn40xhTdNZAnfLECL81w+VX3BumrGD58=
github.com/go-openapi/validate v0.24.0/go.mod h1:iyeX1sEufmv3nPbBdX3ieNviWnOZaJ1+zquzJEf2BAQ=
github.com/go-piv/piv-go v1.11.0 h1:5vAaCdRTFSIW4PeqMbnsDlUZ7odMYWnHBDGdmtU/Zhg=
github.com/go-piv/piv-go v1.11.0/go.mod h1:NZ2zmjVkfFaL/CF8cVQ/pXdXtuj110zEKGdJM6fJZZM=
github.com/go-piv/piv-go/v2 v2.3.0 h1:kKkrYlgLQTMPA6BiSL25A7/x4CEh2YCG7rtb/aTkx+g=
github.com/go-piv/piv-go/v2 v2.3.0/go.mod h1:ShZi74nnrWNQEdWzRUd/3cSig3uNOcEZp+EWl0oewnI=
github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI=
github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
github.com/go-rod/rod v0.116.2 h1:A5t2Ky2A+5eD/ZJQr1EfsQSe5rms5Xof/qj296e+ZqA=
Expand Down
6 changes: 3 additions & 3 deletions pkg/cosign/pivkey/pivkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"os"
"syscall"

"github.com/go-piv/piv-go/piv"
"github.com/go-piv/piv-go/v2/piv"
"golang.org/x/term"

"github.com/sigstore/sigstore/pkg/signature"
Expand Down Expand Up @@ -113,7 +113,7 @@ func (k *Key) GetAttestationCertificate() (*x509.Certificate, error) {
return k.card.AttestationCertificate()
}

func (k *Key) SetManagementKey(old, new [24]byte) error {
func (k *Key) SetManagementKey(old, new []byte) error {
if k.card == nil {
return KeyNotInitialized
}
Expand Down Expand Up @@ -153,7 +153,7 @@ func (k *Key) Unblock(puk, newPIN string) error {
return k.card.Unblock(puk, newPIN)
}

func (k *Key) GenerateKey(mgmtKey [24]byte, slot piv.Slot, opts piv.Key) (crypto.PublicKey, error) {
func (k *Key) GenerateKey(mgmtKey []byte, slot piv.Slot, opts piv.Key) (crypto.PublicKey, error) {
if k.card == nil {
return nil, KeyNotInitialized
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cosign/pivkey/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package pivkey

import (
"github.com/go-piv/piv-go/piv"
"github.com/go-piv/piv-go/v2/piv"
)

func SlotForName(slotName string) *piv.Slot {
Expand Down

0 comments on commit 79dedae

Please sign in to comment.