Skip to content

Commit

Permalink
Fix jar e2e test by retrieving sig/key from JAR
Browse files Browse the repository at this point in the history
Signed-off-by: Riccardo Schirone <[email protected]>
  • Loading branch information
ret2libc committed Feb 29, 2024
1 parent 1659155 commit 34f31c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,7 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
<<<<<<< HEAD
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
=======
>>>>>>> 4bb3336 (Update sigstore/sigstore with PublicKeyDetails)
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down
24 changes: 21 additions & 3 deletions pkg/types/jar/v0.0.1/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,30 @@ func (v *V001Entry) CreateFromArtifactProperties(ctx context.Context, props type
}
re.JARModel.Archive.Content = (strfmt.Base64)(artifactBytes)

if err := re.validate(); err != nil {
keyObj, sigObj, err := re.fetchExternalEntities(ctx)
if err != nil {
return nil, fmt.Errorf("error retrieving external entities: %v", err)
}

// need to canonicalize key content
keyContent, err := keyObj.CanonicalValue()
if err != nil {
return nil, err
}
sigContent, err := sigObj.CanonicalValue()
if err != nil {
return nil, err
}

if _, _, err := re.fetchExternalEntities(ctx); err != nil {
return nil, fmt.Errorf("error retrieving external entities: %v", err)
re.JARModel.Signature = &models.JarV001SchemaSignature{
PublicKey: &models.JarV001SchemaSignaturePublicKey{
Content: (*strfmt.Base64)(&keyContent),
},
Content: sigContent,
}

if err := re.validate(); err != nil {
return nil, err
}

returnVal.APIVersion = swag.String(re.APIVersion())
Expand Down

0 comments on commit 34f31c3

Please sign in to comment.