Skip to content

Commit 4336bbf

Browse files
committed
Bump SCAI predicate version to v0.3
Signed-off-by: Marcela Melara <[email protected]>
1 parent 6a1d308 commit 4336bbf

File tree

5 files changed

+46
-5
lines changed

5 files changed

+46
-5
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
2121
with:
22-
go-version: '1.21.x'
22+
go-version: '1.22.x'
2323
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
2424
- name: golangci-lint
2525
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86

.github/workflows/test-e2e-flow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install Go
1919
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
2020
with:
21-
go-version: 1.21.x
21+
go-version: 1.22.x
2222

2323
- name: Checkout updated scai-gen CLI tools
2424
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module github.com/in-toto/scai-demos
22

3-
go 1.21
3+
go 1.22.5
4+
5+
toolchain go1.22.6
6+
47
require (
58
github.com/google/cel-go v0.21.0
69
github.com/in-toto/attestation v1.1.0

scai-gen/cmd/check.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io/fs"
77
"os"
88
"path/filepath"
9+
"slices"
910
"strings"
1011

1112
"github.com/in-toto/scai-demos/scai-gen/pkg/fileio"
@@ -156,7 +157,7 @@ func checkEvidence(_ *cobra.Command, args []string) error {
156157
return fmt.Errorf("failed read evidence files in directory %s: %w", evidenceDir, err)
157158
}
158159

159-
if statement.GetPredicateType() != "https://in-toto.io/attestation/scai/attribute-report/v0.2" {
160+
if !isSupportedPredicateType(statement.GetPredicateType()) {
160161
return fmt.Errorf("evidence checking only supported for SCAI attestations")
161162
}
162163

@@ -282,3 +283,22 @@ func getAllEvidenceFiles(evidenceDir string) (map[string][]byte, error) {
282283

283284
return evidenceMap, nil
284285
}
286+
287+
func isSupportedPredicateType(predicateType string) bool {
288+
supportedTypes := []string{"attribute-report/v0.2", "v0.3"}
289+
290+
// TODO: a future version of the scai Go package will have a const for this URI
291+
version, found := strings.CutPrefix(predicateType, "https://in-toto.io/attestation/scai/")
292+
293+
if found {
294+
idx := slices.IndexFunc(supportedTypes, func(v string) bool {
295+
return v == version
296+
})
297+
298+
if idx > -1 {
299+
return true
300+
}
301+
return false
302+
}
303+
return false
304+
}

scai-gen/cmd/report.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var reportCmd = &cobra.Command{
2323
var (
2424
subjectFile string
2525
producerFile string
26+
version string
2627
)
2728

2829
func init() {
@@ -52,6 +53,14 @@ func init() {
5253
"The filename of the JSON-encoded producer resource descriptor",
5354
)
5455

56+
reportCmd.Flags().StringVarP(
57+
&version,
58+
"version",
59+
"v",
60+
"v0.3",
61+
"The spec version to generate for the generated attribute report",
62+
)
63+
5564
reportCmd.Flags().BoolVarP(
5665
&prettyPrint,
5766
"pretty-print",
@@ -115,7 +124,16 @@ func genAttrReport(_ *cobra.Command, args []string) error {
115124
return err
116125
}
117126

118-
statement, err := generators.NewStatement([]*ita.ResourceDescriptor{subject}, "https://in-toto.io/attestation/scai/attribute-report/v0.2", reportStruct)
127+
// TODO: a future version of the scai Go package will have a const for this URI
128+
predicateType := "https://in-toto.io/attestation/scai/"
129+
if version == "v0.2" {
130+
suffix := "attribute-report/v0.2"
131+
predicateType += suffix
132+
} else {
133+
predicateType += version
134+
}
135+
136+
statement, err := generators.NewStatement([]*ita.ResourceDescriptor{subject}, predicateType, reportStruct)
119137
if err != nil {
120138
return fmt.Errorf("unable to generate in-toto Statement: %w", err)
121139
}

0 commit comments

Comments
 (0)