Skip to content

Commit

Permalink
feat: Rename verifySubjectDigest function (#712)
Browse files Browse the repository at this point in the history
closes #711

Signed-off-by: laurentsimon <laurentsimon@google.com>
  • Loading branch information
laurentsimon authored Oct 9, 2023
1 parent 0e5b3a3 commit 417b7aa
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
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"),
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

0 comments on commit 417b7aa

Please sign in to comment.