Skip to content
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

feat: Rename verifySubjectDigest function #712

Merged
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
4 changes: 2 additions & 2 deletions cli/slsa-verifier/main_regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1674,15 +1674,15 @@ func Test_runVerifyNpmPackage(t *testing.T) {
name: "invalid signature provenance npm CLI",
artifact: "provenance-npm-test-cli-v02-prega-invalidsigprov.tgz",
source: "github.com/laurentsimon/provenance-npm-test",
pkgName: PointerTo("@laurentsimon/provenance-npm-test2"),
pkgName: PointerTo("@laurentsimon/provenance-npm-test"),
trishankatdatadog marked this conversation as resolved.
Show resolved Hide resolved
builderID: PointerTo("https://github.com/actions/runner/github-hosted"),
err: serrors.ErrorInvalidSignature,
},
{
name: "invalid signature publish npm CLI",
artifact: "provenance-npm-test-cli-v02-prega-invalidsigpub.tgz",
source: "github.com/laurentsimon/provenance-npm-test",
pkgName: PointerTo("@laurentsimon/provenance-npm-test2"),
pkgName: PointerTo("@laurentsimon/provenance-npm-test"),
builderID: PointerTo("https://github.com/actions/runner/github-hosted"),
err: serrors.ErrorInvalidSignature,
},
Expand Down
2 changes: 1 addition & 1 deletion verifiers/internal/gha/npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func verifyProvenanceSubjectVersion(b *utils.TrustedBuilderID, att *SignedAttest
return nil
}

func (n *Npm) verifySubjectDigest(expectedHash string) error {
func (n *Npm) verifyPublishAttestationSubjectDigest(expectedHash string) error {
publishSubjects, err := subjectsFromAttestation(n.verifiedPublishAtt)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions verifiers/internal/gha/npm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ func Test_verifyPackageName(t *testing.T) {
}
}

func Test_verifySubjectDigest(t *testing.T) {
func Test_verifyPublishAttestationSubjectDigest(t *testing.T) {
t.Parallel()
ctx := context.Background()

Expand Down Expand Up @@ -868,7 +868,7 @@ func Test_verifySubjectDigest(t *testing.T) {
Envelope: env,
}

err = npm.verifySubjectDigest(tt.hash)
err = npm.verifyPublishAttestationSubjectDigest(tt.hash)
if !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err))
}
Expand Down
4 changes: 2 additions & 2 deletions verifiers/internal/gha/provenance_forgeable.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func verifyProvenanceMatchesCertificate(prov iface.Provenance, workflow *Workflo
}

// Verify subjects.
if err := verifySubjectDigestName(prov, "sha512"); err != nil {
if err := verifyPublishAttestationSubjectDigestName(prov, "sha512"); err != nil {
return err
}

Expand Down Expand Up @@ -63,7 +63,7 @@ func verifyProvenanceMatchesCertificate(prov iface.Provenance, workflow *Workflo
return nil
}

func verifySubjectDigestName(prov iface.Provenance, digestName string) error {
func verifyPublishAttestationSubjectDigestName(prov iface.Provenance, digestName string) error {
subjects, err := prov.Subjects()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions verifiers/internal/gha/provenance_forgeable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
serrors "github.com/slsa-framework/slsa-verifier/v2/errors"
)

func Test_verifySubjectDigestName(t *testing.T) {
func Test_verifyPublishAttestationSubjectDigestName(t *testing.T) {
t.Parallel()
tests := []struct {
name string
Expand Down Expand Up @@ -66,7 +66,7 @@ func Test_verifySubjectDigestName(t *testing.T) {
prov := &testProvenance{
subjects: tt.subject,
}
if err := verifySubjectDigestName(prov, tt.digestName); !errCmp(err, tt.err) {
if err := verifyPublishAttestationSubjectDigestName(prov, tt.digestName); !errCmp(err, tt.err) {
t.Errorf(cmp.Diff(err, tt.err))
}
})
Expand Down
2 changes: 1 addition & 1 deletion verifiers/internal/gha/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (v *GHAVerifier) VerifyNpmPackage(ctx context.Context,
}

// Verify publish subject digest.
if err := npm.verifySubjectDigest(provenanceOpts.ExpectedDigest); err != nil {
if err := npm.verifyPublishAttestationSubjectDigest(provenanceOpts.ExpectedDigest); err != nil {
return nil, nil, err
}

Expand Down
Loading