Skip to content

Commit

Permalink
Stop using deprecated in_toto.ProvenanceStatement (#3243)
Browse files Browse the repository at this point in the history
The struct `in_toto.ProvenanceStatement` is marked as deprecated.
Instead, it is recommened to use a version-specific struct. The
`in_toto.ProvenanceStatementSLSA02` is the equivalent.

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
  • Loading branch information
lcarva committed Sep 18, 2023
1 parent d5b8c35 commit 44f7703
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/cosign/attestation/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func generateSLSAProvenanceStatementSLSA02(rawPayload []byte, digest string, rep
if err != nil {
return "", fmt.Errorf("unmarshal Provenance predicate: %w", err)
}
return in_toto.ProvenanceStatement{
return in_toto.ProvenanceStatementSLSA02{
StatementHeader: generateStatementHeader(digest, repo, slsa02.PredicateSLSAProvenance),
Predicate: predicate,
}, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/cosign/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func appendSlices(slices [][]byte) []byte {
}

func Test_verifyOCIAttestation(t *testing.T) {
stmt, err := json.Marshal(in_toto.ProvenanceStatement{})
stmt, err := json.Marshal(in_toto.ProvenanceStatementSLSA02{})
if err != nil {
t.Fatal(err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/policy/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ func AttestationToPayloadJSON(_ context.Context, predicateType string, verifiedA
return nil, statement.PredicateType, fmt.Errorf("marshaling LinkStatement: %w", err)
}
case options.PredicateSLSA:
var slsaProvenanceStatement in_toto.ProvenanceStatement
var slsaProvenanceStatement in_toto.ProvenanceStatementSLSA02
if err := json.Unmarshal(decodedPayload, &slsaProvenanceStatement); err != nil {
return nil, statement.PredicateType, fmt.Errorf("unmarshaling ProvenanceStatement): %w", err)
return nil, statement.PredicateType, fmt.Errorf("unmarshaling ProvenanceStatementSLSA02): %w", err)
}
payload, err = json.Marshal(slsaProvenanceStatement)
if err != nil {
return nil, statement.PredicateType, fmt.Errorf("marshaling ProvenanceStatement: %w", err)
return nil, statement.PredicateType, fmt.Errorf("marshaling ProvenanceStatementSLSA02: %w", err)
}
case options.PredicateSPDX, options.PredicateSPDXJSON:
var spdxStatement in_toto.SPDXStatement
Expand Down

0 comments on commit 44f7703

Please sign in to comment.