Skip to content

Commit

Permalink
Bump SCAI predicate version to v0.3
Browse files Browse the repository at this point in the history
Signed-off-by: Marcela Melara <[email protected]>
  • Loading branch information
marcelamelara committed Aug 30, 2024
1 parent 6a1d308 commit 4336bbf
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: '1.21.x'
go-version: '1.22.x'
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-e2e-flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: 1.21.x
go-version: 1.22.x

- name: Checkout updated scai-gen CLI tools
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module github.com/in-toto/scai-demos

go 1.21
go 1.22.5

toolchain go1.22.6

require (
github.com/google/cel-go v0.21.0
github.com/in-toto/attestation v1.1.0
Expand Down
22 changes: 21 additions & 1 deletion scai-gen/cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/fs"
"os"
"path/filepath"
"slices"
"strings"

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

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

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

return evidenceMap, nil
}

func isSupportedPredicateType(predicateType string) bool {
supportedTypes := []string{"attribute-report/v0.2", "v0.3"}

// TODO: a future version of the scai Go package will have a const for this URI
version, found := strings.CutPrefix(predicateType, "https://in-toto.io/attestation/scai/")

if found {
idx := slices.IndexFunc(supportedTypes, func(v string) bool {
return v == version
})

if idx > -1 {
return true
}
return false
}
return false
}
20 changes: 19 additions & 1 deletion scai-gen/cmd/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var reportCmd = &cobra.Command{
var (
subjectFile string
producerFile string
version string
)

func init() {
Expand Down Expand Up @@ -52,6 +53,14 @@ func init() {
"The filename of the JSON-encoded producer resource descriptor",
)

reportCmd.Flags().StringVarP(
&version,
"version",
"v",
"v0.3",
"The spec version to generate for the generated attribute report",
)

reportCmd.Flags().BoolVarP(
&prettyPrint,
"pretty-print",
Expand Down Expand Up @@ -115,7 +124,16 @@ func genAttrReport(_ *cobra.Command, args []string) error {
return err
}

statement, err := generators.NewStatement([]*ita.ResourceDescriptor{subject}, "https://in-toto.io/attestation/scai/attribute-report/v0.2", reportStruct)
// TODO: a future version of the scai Go package will have a const for this URI
predicateType := "https://in-toto.io/attestation/scai/"
if version == "v0.2" {
suffix := "attribute-report/v0.2"
predicateType += suffix
} else {
predicateType += version
}

statement, err := generators.NewStatement([]*ita.ResourceDescriptor{subject}, predicateType, reportStruct)
if err != nil {
return fmt.Errorf("unable to generate in-toto Statement: %w", err)
}
Expand Down

0 comments on commit 4336bbf

Please sign in to comment.