Skip to content

Commit 6aca8e1

Browse files
authored
Update verifier paths, bridge ID migration (#256)
* Fix tag check updating URIs This commit fixes the broken tag verification by updating the paths and URIs for the verification IDs to those of the new repos. Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]> * Use constants in default signer IDs Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]> * COMPAT: Support old+new signers This commits adds a compatibility hack to support both the old and new actions repository signer identities while we migrate to the new source-actions repos. This commit is inteded to be reverted once all repos have signed their VSAs using the new identity. For more see: #255 Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]> --------- Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
1 parent c686446 commit 6aca8e1

File tree

5 files changed

+42
-10
lines changed

5 files changed

+42
-10
lines changed

internal/cmd/checktag.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ func doCheckTag(args *checkTagOptions) error {
7070
pa := attest.NewProvenanceAttestor(ghconnection, verifier)
7171
prov, err := pa.CreateTagProvenance(ctx, args.commit, ghcontrol.TagToFullRef(args.tagName), args.actor)
7272
if err != nil {
73-
return err
73+
return fmt.Errorf("creating tag provenance metadata: %w", err)
7474
}
7575

7676
// check p against policy
7777
pe := policy.NewPolicyEvaluator()
7878
pe.UseLocalPolicy = args.useLocalPolicy
7979
verifiedLevels, policyPath, err := pe.EvaluateTagProv(ctx, args.GetRepository(), prov)
8080
if err != nil {
81-
return err
81+
return fmt.Errorf("evaluating the tag provenance metadata: %w", err)
8282
}
8383

8484
// create vsa

pkg/attest/statement.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"errors"
99
"fmt"
1010
"io"
11+
"strings"
1112

1213
spb "github.com/in-toto/attestation/go/v1"
1314
"google.golang.org/protobuf/encoding/protojson"
@@ -31,12 +32,27 @@ func (br *BundleReader) convertLineToStatement(line string) (*spb.Statement, err
3132
if err == nil {
3233
// This is it.
3334
return vr.Statement, nil
34-
} else {
35-
// We ignore errors because there could be other stuff in the
36-
// bundle this line came from.
37-
Debugf("Line '%s' failed verification: %v", line, err)
3835
}
3936

37+
// Compatibility hack bridgind identities for repository migration
38+
// See here for more info and when to drop:
39+
//
40+
// https://github.com/slsa-framework/slsa-source-poc/issues/255
41+
if strings.Contains(err.Error(), "no matching CertificateIdentity") && strings.Contains(err.Error(), OldExpectedSan) {
42+
ver, err := (&BndVerifier{
43+
Options: VerificationOptions{
44+
ExpectedIssuer: ExpectedIssuer,
45+
ExpectedSan: OldExpectedSan,
46+
},
47+
}).Verify(line)
48+
if err == nil {
49+
Debugf("found statement signed with old identity")
50+
return ver.Statement, nil
51+
}
52+
}
53+
54+
Debugf("Line '%s' failed verification: %v", line, err)
55+
4056
// TODO: add support for 'regular' DSSEs.
4157

4258
return nil, fmt.Errorf("could not convert line to statement: '%s'", line)

pkg/attest/verify.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,27 @@ type VerificationOptions struct {
1313
ExpectedSan string
1414
}
1515

16+
const (
17+
// ExpectedIssuer is the OIDC issuer found in the sigstore bundles
18+
ExpectedIssuer = "https://token.actions.githubusercontent.com"
19+
20+
// Expected SAN is the expected identity of the workflow signing the
21+
// provenance and VSAs.
22+
ExpectedSan = "https://github.com/slsa-framework/source-actions/.github/workflows/compute_slsa_source.yml@refs/heads/main"
23+
24+
// OldExpectedSan is the old singer identity before splitting out the actions to their own repo
25+
// this constant is part of a compatibility hack that should be reverted once the latests attestations
26+
// of the repos are signed with the new identity.
27+
//
28+
// See https://github.com/slsa-framework/slsa-source-poc/issues/255
29+
OldExpectedSan = "https://github.com/slsa-framework/slsa-source-poc/.github/workflows/compute_slsa_source.yml@refs/heads/main"
30+
)
31+
1632
// TODO: Update ExpectedSan to support regex so we can get the branches/tags we really think
1733
// folks should be using (they won't all run from main).
1834
var DefaultVerifierOptions = VerificationOptions{
19-
ExpectedIssuer: "https://token.actions.githubusercontent.com",
20-
ExpectedSan: "https://github.com/slsa-framework/slsa-source-poc/.github/workflows/compute_slsa_source.yml@refs/heads/main",
35+
ExpectedIssuer: ExpectedIssuer,
36+
ExpectedSan: ExpectedSan,
2137
}
2238

2339
type Verifier interface {

pkg/attest/vsa.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
const (
2323
VsaPredicateType = "https://slsa.dev/verification_summary/v1"
24-
VsaVerifierId = "https://github.com/slsa-framework/slsa-source-poc"
24+
VsaVerifierId = "https://github.com/slsa-framework/source-actions"
2525
)
2626

2727
func CreateUnsignedSourceVsa(repoUri, ref, commit string, verifiedLevels slsa.SourceVerifiedLevels, policy string) (string, error) {

pkg/policy/policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
const (
35-
SourcePolicyUri = "github.com/slsa-framework/slsa-source-poc"
35+
SourcePolicyUri = "github.com/slsa-framework/source-policies"
3636
SourcePolicyRepoOwner = "slsa-framework"
3737
SourcePolicyRepo = "source-policies"
3838
)

0 commit comments

Comments
 (0)