Skip to content

Commit

Permalink
feat: mock in-toto attestations query
Browse files Browse the repository at this point in the history
Signed-off-by: felipecruz91 <[email protected]>
  • Loading branch information
felipecruz91 committed Jan 30, 2024
1 parent 3ec056d commit 9cb2e00
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions policy/policy_handler/legacy/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func BuildLocalEvalMocks(sb *types.SBOM) map[edn.Keyword]edn.RawMessage {
m[GetUserQueryName], _ = edn.Marshal(MockGetUserForLocalEval(sb.Source.Image.Config.Config.User))
}

if sb.Source.Provenance != nil {
m[GetInTotoAttestationsQueryName], _ = edn.Marshal(MockGetInTotoAttestationsForLocalEval(sb))
}

return m
}

Expand Down
25 changes: 25 additions & 0 deletions policy/policy_handler/legacy/ssc_metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package legacy

import "github.com/atomist-skills/go-skill/policy/types"

const (
GetInTotoAttestationsQueryName = "get-intoto-attestations"
)

type ImageAttestationQueryResult struct {
Digest *string `edn:"docker.image/digest"`
Subjects []Subject `edn:"intoto.attestation/_subject"`
}

type Subject struct {
PredicateType *string `edn:"intoto.predicate/type"`
Predicates []Predicate `edn:"intoto.predicate/_attestation"`
}

type Predicate struct {
StartLine *int `edn:"slsa.provenance.from/start-line"` // if field is present then provenance is max-mode
}

func MockGetInTotoAttestationsForLocalEval(sb *types.SBOM) ImageAttestationQueryResult {
return ImageAttestationQueryResult{} // incompatible with local evaluation until SBOM includes the raw attestations
}

0 comments on commit 9cb2e00

Please sign in to comment.