Skip to content

Commit 7923108

Browse files
Add cosign registry opts for provenance registry
triggered on specification of COSIGN_REPOSITORY env Signed-off-by: saisatishkarra <[email protected]>
1 parent fcc8bf3 commit 7923108

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

verifiers/internal/gha/verifier.go

+22-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"github.com/slsa-framework/slsa-verifier/v2/verifiers/internal/gha/slsaprovenance/common"
2020
"github.com/slsa-framework/slsa-verifier/v2/verifiers/utils"
2121
"github.com/slsa-framework/slsa-verifier/v2/verifiers/utils/container"
22+
23+
ociremote "github.com/sigstore/cosign/v2/pkg/oci/remote"
2224
)
2325

2426
const VerifierName = "GHA"
@@ -252,11 +254,27 @@ func (v *GHAVerifier) VerifyImage(ctx context.Context,
252254
if err != nil {
253255
return nil, nil, err
254256
}
257+
258+
// Parse any provenance target repository set using environment variable COSIGN_REPOSITORY
259+
provenanceTargetRepository, err := ociremote.GetEnvTargetRepository()
260+
if err != nil {
261+
return nil, nil, err
262+
}
263+
264+
registryClientOpts := []ociremote.Option{}
265+
266+
// Append target repository to OCI Registry opts
267+
// Must be authenticated against the specified target repository externally
268+
if provenanceTargetRepository.Name() != "" {
269+
registryClientOpts = append(registryClientOpts, ociremote.WithTargetRepository(provenanceTargetRepository))
270+
}
271+
255272
opts := &cosign.CheckOpts{
256-
RootCerts: trustedRoot.FulcioRoot,
257-
IntermediateCerts: trustedRoot.FulcioIntermediates,
258-
RekorPubKeys: trustedRoot.RekorPubKeys,
259-
CTLogPubKeys: trustedRoot.CTPubKeys,
273+
RegistryClientOpts: registryClientOpts,
274+
RootCerts: trustedRoot.FulcioRoot,
275+
IntermediateCerts: trustedRoot.FulcioIntermediates,
276+
RekorPubKeys: trustedRoot.RekorPubKeys,
277+
CTLogPubKeys: trustedRoot.CTPubKeys,
260278
}
261279
atts, _, err := container.RunCosignImageVerification(ctx,
262280
artifactImage, opts)

0 commit comments

Comments
 (0)