mirror of
https://github.com/slsa-framework/slsa-verifier.git
synced 2026-05-21 07:52:50 +00:00
singular attestation path
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
This commit is contained in:
@@ -1802,7 +1802,7 @@ func Test_runVerifyVSA(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
attestationsPath *string
|
||||
AttestationPath *string
|
||||
subjectDigests *[]string
|
||||
verifierID *string
|
||||
resourceURI *string
|
||||
@@ -1814,7 +1814,7 @@ func Test_runVerifyVSA(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "success: gke",
|
||||
attestationsPath: PointerTo("gce/v1/gke-gce-pre.bcid-vsa.jsonl"),
|
||||
AttestationPath: PointerTo("gce/v1/gke-gce-pre.bcid-vsa.jsonl"),
|
||||
subjectDigests: PointerTo([]string{"gce_image_id:8970095005306000053"}),
|
||||
verifierID: PointerTo("https://bcid.corp.google.com/verifier/bcid_package_enforcer/v0.1"),
|
||||
resourceURI: PointerTo("gce_image://gke-node-images:gke-12615-gke1418000-cos-101-17162-463-29-c-cgpv1-pre"),
|
||||
@@ -1825,7 +1825,7 @@ func Test_runVerifyVSA(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "success: gke, default public key hash algo",
|
||||
attestationsPath: PointerTo("gce/v1/gke-gce-pre.bcid-vsa.jsonl"),
|
||||
AttestationPath: PointerTo("gce/v1/gke-gce-pre.bcid-vsa.jsonl"),
|
||||
subjectDigests: PointerTo([]string{"gce_image_id:8970095005306000053"}),
|
||||
verifierID: PointerTo("https://bcid.corp.google.com/verifier/bcid_package_enforcer/v0.1"),
|
||||
resourceURI: PointerTo("gce_image://gke-node-images:gke-12615-gke1418000-cos-101-17162-463-29-c-cgpv1-pre"),
|
||||
@@ -1836,14 +1836,14 @@ func Test_runVerifyVSA(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "fail: gke, unsupported public key hash algo",
|
||||
attestationsPath: PointerTo("gce/v1/gke-gce-pre.bcid-vsa.jsonl"),
|
||||
AttestationPath: PointerTo("gce/v1/gke-gce-pre.bcid-vsa.jsonl"),
|
||||
publicKeyPath: PointerTo("gce/v1/vsa_signing_public_key.pem"),
|
||||
publicKeyHashAlgo: PointerTo("SHA123"),
|
||||
err: serrors.ErrorInvalidHashAlgo,
|
||||
},
|
||||
{
|
||||
name: "fail: gke, wrong public key hash algo",
|
||||
attestationsPath: PointerTo("gce/v1/gke-gce-pre.bcid-vsa.jsonl"),
|
||||
AttestationPath: PointerTo("gce/v1/gke-gce-pre.bcid-vsa.jsonl"),
|
||||
publicKeyPath: PointerTo("gce/v1/vsa_signing_public_key.pem"),
|
||||
publicKeyID: PointerTo(""),
|
||||
publicKeyHashAlgo: PointerTo("SHA512"),
|
||||
@@ -1851,7 +1851,7 @@ func Test_runVerifyVSA(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "fail: gke, wrong key id",
|
||||
attestationsPath: PointerTo("gce/v1/gke-gce-pre.bcid-vsa.jsonl"),
|
||||
AttestationPath: PointerTo("gce/v1/gke-gce-pre.bcid-vsa.jsonl"),
|
||||
publicKeyPath: PointerTo("gce/v1/vsa_signing_public_key.pem"),
|
||||
publicKeyID: PointerTo("my_key_id"),
|
||||
publicKeyHashAlgo: PointerTo("SHA256"),
|
||||
@@ -1865,11 +1865,11 @@ func Test_runVerifyVSA(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
attestationsPath := filepath.Clean(filepath.Join(TEST_DIR, "vsa", *tt.attestationsPath))
|
||||
AttestationPath := filepath.Clean(filepath.Join(TEST_DIR, "vsa", *tt.AttestationPath))
|
||||
publicKeyPath := filepath.Clean(filepath.Join(TEST_DIR, "vsa", *tt.publicKeyPath))
|
||||
|
||||
cmd := verify.VerifyVSACommand{
|
||||
AttestationsPath: &attestationsPath,
|
||||
AttestationPath: &AttestationPath,
|
||||
SubjectDigests: tt.subjectDigests,
|
||||
VerifierID: tt.verifierID,
|
||||
ResourceURI: tt.resourceURI,
|
||||
|
||||
@@ -195,7 +195,7 @@ func verifyVSACmd() *cobra.Command {
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
v := verify.VerifyVSACommand{
|
||||
SubjectDigests: &o.SubjectDigests,
|
||||
AttestationsPath: &o.AttestationsPath,
|
||||
AttestationPath: &o.AttestationPath,
|
||||
VerifierID: &o.VerifierID,
|
||||
ResourceURI: &o.ResourceURI,
|
||||
VerifiedLevels: &o.VerifiedLevels,
|
||||
|
||||
@@ -130,7 +130,7 @@ func (o *VerifyNpmOptions) AddFlags(cmd *cobra.Command) {
|
||||
// VerifyVSAOptions is the top-level options for the `verifyVSA` command.
|
||||
type VerifyVSAOptions struct {
|
||||
SubjectDigests []string
|
||||
AttestationsPath string
|
||||
AttestationPath string
|
||||
VerifierID string
|
||||
ResourceURI string
|
||||
VerifiedLevels []string
|
||||
@@ -147,7 +147,7 @@ func (o *VerifyVSAOptions) AddFlags(cmd *cobra.Command) {
|
||||
cmd.Flags().StringArrayVar(&o.SubjectDigests, "subject-digest", []string{},
|
||||
"the digests to be verified. Pass multiple digests by repeating the flag. e.g. <digest type>:<digest value>")
|
||||
|
||||
cmd.Flags().StringVar(&o.AttestationsPath, "attestations-path", "",
|
||||
cmd.Flags().StringVar(&o.AttestationPath, "attestations-path", "",
|
||||
"path to a file containing the attestations")
|
||||
|
||||
cmd.Flags().StringVar(&o.VerifierID, "verifier-id", "",
|
||||
|
||||
@@ -31,7 +31,7 @@ import (
|
||||
// VerifyVSACommand contains the parameters for the verify-vsa command.
|
||||
type VerifyVSACommand struct {
|
||||
SubjectDigests *[]string
|
||||
AttestationsPath *string
|
||||
AttestationPath *string
|
||||
VerifierID *string
|
||||
ResourceURI *string
|
||||
VerifiedLevels *[]string
|
||||
@@ -83,7 +83,7 @@ func (c *VerifyVSACommand) Exec(ctx context.Context) (*utils.TrustedAttesterID,
|
||||
PublicKeyID: c.PublicKeyID,
|
||||
PublicKeyHashAlgo: hashAlgo,
|
||||
}
|
||||
attestations, err := os.ReadFile(*c.AttestationsPath)
|
||||
attestations, err := os.ReadFile(*c.AttestationPath)
|
||||
if err != nil {
|
||||
printFailed(err)
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user