Skip to content

Commit b38f9d6

Browse files
modularize the fulcio and rekor URLs
Signed-off-by: Ramon Petgrave <[email protected]> Signed-off-by: Ramon Petgrave <[email protected]>
1 parent 777f1fc commit b38f9d6

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

internal/builders/go/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ func runBuild(dry bool, configFile, evalEnvs string) error {
7676
}
7777

7878
func runProvenanceGeneration(subject, digest, commands, envs, workingDir, rekor string) error {
79-
s := sigstore.NewDefaultBundleSigner()
79+
s := sigstore.NewBundleSigner(sigstore.DefaultFulcioAddr, rekor)
80+
8081
attBytes, err := pkg.GenerateProvenance(subject, digest,
8182
commands, envs, workingDir, s, nil)
8283
if err != nil {

signing/sigstore/bundle.go

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import (
2626
)
2727

2828
// BundleSigner is used to produce Sigstore Bundles from provenance statements.
29-
type BundleSigner struct{}
29+
type BundleSigner struct {
30+
fulcioAddr string
31+
rekorAddr string
32+
}
3033

3134
type sigstoreBundleAtt struct {
3235
cert []byte
@@ -45,7 +48,14 @@ func (s *sigstoreBundleAtt) Bytes() []byte {
4548

4649
// NewDefaultBundleSigner creates a new BundleSigner instance.
4750
func NewDefaultBundleSigner() *BundleSigner {
48-
return &BundleSigner{}
51+
return NewBundleSigner(DefaultFulcioAddr, DefaultRekorAddr)
52+
}
53+
54+
func NewBundleSigner(fulcioAddr string, rekorAddr string) *BundleSigner {
55+
return &BundleSigner{
56+
fulcioAddr: fulcioAddr,
57+
rekorAddr: rekorAddr,
58+
}
4959
}
5060

5161
// Sign signs the given provenance statement and returns the signed Sigstore Bundle.
@@ -78,7 +88,11 @@ func (s *BundleSigner) Sign(ctx context.Context, statement *intoto.Statement) (s
7888
rawToken := TokenStruct.RawToken
7989

8090
// signing opts.
81-
bundleOpts, err := getDefaultBundleOptsWithIdentityToken(&rawToken)
91+
bundleOpts, err := getBundleOpts(
92+
&s.fulcioAddr,
93+
&s.rekorAddr,
94+
&rawToken,
95+
)
8296
if err != nil {
8397
return nil, err
8498
}
@@ -104,20 +118,24 @@ func (s *BundleSigner) Sign(ctx context.Context, statement *intoto.Statement) (s
104118
return bundleAtt, nil
105119
}
106120

107-
// getDefaultBundleOptsWithIdentityToken provides the default opts for sigstoreSign.Bundle().
108-
func getDefaultBundleOptsWithIdentityToken(identityToken *string) (*sigstoreSign.BundleOptions, error) {
121+
// getBundleOpts provides the opts for sigstoreSign.Bundle().
122+
func getBundleOpts(
123+
fulcioAddr *string,
124+
rekorAddr *string,
125+
identityToken *string,
126+
) (*sigstoreSign.BundleOptions, error) {
109127
bundleOpts := &sigstoreSign.BundleOptions{}
110128

111129
fulcioOpts := &sigstoreSign.FulcioOptions{
112-
BaseURL: "https://fulcio.sigstore.dev",
130+
BaseURL: *fulcioAddr,
113131
}
114132
bundleOpts.CertificateProvider = sigstoreSign.NewFulcio(fulcioOpts)
115133
bundleOpts.CertificateProviderOptions = &sigstoreSign.CertificateProviderOptions{
116134
IDToken: *identityToken,
117135
}
118136

119137
rekorOpts := &sigstoreSign.RekorOptions{
120-
BaseURL: "https://rekor.sigstore.dev",
138+
BaseURL: *rekorAddr,
121139
}
122140
bundleOpts.TransparencyLogs = append(bundleOpts.TransparencyLogs, sigstoreSign.NewRekor(rekorOpts))
123141
return bundleOpts, nil

signing/sigstore/fulcio.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
const (
35-
defaultFulcioAddr = options.DefaultFulcioURL
35+
DefaultFulcioAddr = options.DefaultFulcioURL
3636
defaultOIDCIssuer = options.DefaultOIDCIssuerURL
3737
defaultOIDCClientID = "sigstore"
3838
)
@@ -63,7 +63,7 @@ func (a *attestation) Cert() []byte {
6363
// NewDefaultFulcio creates a new Fulcio instance using the public Fulcio
6464
// server and public sigstore OIDC issuer.
6565
func NewDefaultFulcio() *Fulcio {
66-
return NewFulcio(defaultFulcioAddr, defaultOIDCIssuer, defaultOIDCClientID)
66+
return NewFulcio(DefaultFulcioAddr, defaultOIDCIssuer, defaultOIDCClientID)
6767
}
6868

6969
// NewFulcio creates a new Fulcio instance.

0 commit comments

Comments
 (0)