-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add KubeCon + CloudNativeCon NA '23 demo files #32
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"payloadType":"application/vnd.in-toto+json","payload":"eyJfdHlwZSI6Imh0dHBzOi8vaW4tdG90by5pby9TdGF0ZW1lbnQvdjEiLCJzdWJqZWN0IjpbeyJuYW1lIjoicGRvX2NsaWVudF93YXdha2EiLCJkaWdlc3QiOnsic2hhMjU2IjoiOWZiN2VmNTUyMjk4ZjhmYmFkODQ2MDRkMDYxMDBlNzYwYjdiOGM0Y2I0ZDZjNGI3Mjc4NjVmMWYyODVkMDZhYyJ9fV0sInByZWRpY2F0ZVR5cGUiOiJodHRwczovL2luLXRvdG8uaW8vYXR0ZXN0YXRpb24vc2NhaS9hdHRyaWJ1dGUtcmVwb3J0L3YwLjIiLCJwcmVkaWNhdGUiOnsiYXR0cmlidXRlcyI6W3siYXR0cmlidXRlIjoiSGFzU0JPTSIsImV2aWRlbmNlIjp7ImRpZ2VzdCI6eyJzaGEyNTYiOiJkOTVjMjAyZTBlNDAyMTQ0ZDYzNjM4MGU5ODJlYWZmNTRiZTU1OWI1NTU5OGZkMTgwNzFlOTZkNmYzYTdlYjAzIn0sImRvd25sb2FkTG9jYXRpb24iOiJodHRwczovL2dpdGh1Yi5jb20vbWFyY2VsYW1lbGFyYS9wcml2YXRlLWRhdGEtb2JqZWN0cy9zdWl0ZXMvMTU0MTc3MjYxNDIvYXJ0aWZhY3RzLzg4MDQwMzM5NSIsIm1lZGlhVHlwZSI6ImFwcGxpY2F0aW9uL3NwZHgranNvbiIsIm5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cJe912HFPPo8ZasQmFBcuBMhpu7NHU6yP/19"}]} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
attestationID: "f7dbd9211f8c9ee70313454ddba0ffacec91139ff325b3ef90eccf706bd06ecf" | ||
inspections: | ||
- name: "build.452e628a.json" | ||
expectedAttributes: | ||
- rule: "assertion.attribute == 'HasSLSA' && predicateType == 'https://slsa.dev/provenance/v0.2'" | ||
- rule: "predicate.buildType == 'https://github.com/slsa-framework/slsa-github-generator/generic@v1'" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
expires: "2024-10-10T12:23:22Z" | ||
functionaries: | ||
1f57509240de3e7921e29a896553e7cf912441e17fe8cbd675457c7ba45bcee6: | ||
keyType: "rsa" | ||
scheme: "rsassa-pss-sha256" | ||
keyIDHashAlgorithms: | ||
- "sha256" | ||
- "sha512" | ||
keyVal: | ||
public: "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA0o+jumXN3tE2Xqx1qKjC\ngzCCvAPoOlzQlg+7OLGHnJbQgDxOyhFYMNqJ6cztb26NettmEpPtLDSnM5fPvHuH\nPVoPctzLqE9MiXdD1C7RHbjeSaUBxJV6wSGdAGzNa+8oxxG1ex4H7KHOXD8Mo61o\nitzViEw8knQNDhKHA/JWMnnhX07J1wF+EBWHpBsquAxZMLwy9h4uSlJjbK6TVZS8\nzLEtChVHLqF71px3/rRLlx6gyvSfqsVUd86JDrZtC+MHiq72nnx6N7+4wmSFB6ZQ\naBJvEemP9f54KgSMPLH4fZ63noQKUj9dnOZ+N4f0SGRIIvhN03/LlVA9ifkJBQml\nLKbiNWGAk92+C6NEp2Tj7olNsQ1zOTLzC27CJSWlDq9hSiS7LuaZUy7Gb3acX6Zf\nGZkwYXpXQPp/vM66InJcr5/T1iW/XhtmCHiRd7T24R4qDvS+Xuqv9+pJtHemCUpz\nWhn7N5L7Hr/t0b0SIUNd1PZzD4+lKElcAt99vCVlKQmVAgMBAAE=\n-----END PUBLIC KEY-----" | ||
keyID: "1f57509240de3e7921e29a896553e7cf912441e17fe8cbd675457c7ba45bcee6" | ||
452e628a9a052784761275fe2eed15d7c0c8c8599bf1977879f130a568af5d8c: | ||
keyType: "ecdsa" | ||
scheme: "ecdsa-sha2-nistp256" | ||
keyIDHashAlgorithms: | ||
- "sha256" | ||
- "sha512" | ||
keyVal: | ||
public: "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEB0TVhLF/u/aDcn+3ncIW2lfOKFn4\niCY36NC3k/oPa8sJ8X25H//mhY8/6fNyUh4PzjIEyHPOcr8CAi8dWyuRFQ==\n-----END PUBLIC KEY-----" | ||
keyID: "452e628a9a052784761275fe2eed15d7c0c8c8599bf1977879f130a568af5d8c" | ||
steps: | ||
- name: "build" | ||
expectedMaterials: | ||
- "ALLOW git+https://github.com/marcelamelara/private-data-objects@refs/heads/generate-swsc-build-metadata" | ||
- "DISALLOW *" | ||
expectedProducts: | ||
- "CREATE pdo_client_wawaka" | ||
- "DISALLOW *" | ||
expectedPredicates: | ||
- predicateType: "https://slsa.dev/provenance/v0.2" | ||
expectedAttributes: | ||
- rule: "predicate.builder.id == 'https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@refs/tags/v1.7.0'" | ||
- rule: "predicate.invocation.configSource.uri == 'git+https://github.com/marcelamelara/private-data-objects@refs/heads/generate-swsc-build-metadata'" | ||
- rule: "predicate.invocation.configSource.digest.sha1 == '87b74378e8c9ccf335a27ffcdc16636990254e1e'" | ||
functionaries: | ||
- "452e628a9a052784761275fe2eed15d7c0c8c8599bf1977879f130a568af5d8c" | ||
- name: "evidence-collection" | ||
expectedMaterials: | ||
- "MATCH pdo_client_wawaka WITH products FROM build" | ||
- "DISALLOW *" | ||
expectedPredicates: | ||
- predicateType: "https://in-toto.io/attestation/scai/attribute-report/v0.2" | ||
expectedAttributes: | ||
- rule: "size(predicate.attributes) >= 2" | ||
- rule: "predicate.attributes.exists(a, a.attribute == 'HasSBOM')" | ||
- rule: "predicate.attributes.exists(a, a.attribute == 'HasSLSA')" | ||
functionaries: | ||
- "1f57509240de3e7921e29a896553e7cf912441e17fe8cbd675457c7ba45bcee6" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
printf "in-toto KubeCon + CloudNativeCon NA 2023 demo (verification flow only)\n\n" | ||
|
||
printf "DISCLAIMER: This verification flow is only for demo purposes.\n" | ||
printf "A production verification flow includes retrieving and validating the identities/keys of attestation signers, which is not shown in this demo.\n\n" | ||
|
||
printf "Verifying ITE-10 Layout\n\n" | ||
attestation-verifier --attestations-directory ./attestations --layout ./policies/layout.yml | ||
|
||
printf "\nVerifying SCAI evidence\n\n" | ||
scai-gen check evidence --policy-file ./policies/has-slsa.yml --evidence-dir ./evidence-files ./attestations/evidence-collection.1f575092.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// adapted from https://github.com/slsa-framework/slsa-github-generator/blob/main/signing/sigstore/fulcio.go | ||
// and https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/generic/attest.go | ||
package cmd | ||
|
||
import ( | ||
"bufio" | ||
"encoding/base64" | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/in-toto/scai-demos/scai-gen/fileio" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rekorCmd = &cobra.Command{ | ||
Use: "rekor", | ||
Args: cobra.ExactArgs(1), | ||
Short: "Parses a Rekor log entry to extract info needed to verify signed in-toto Attestations", | ||
RunE: parseRekorEntry, | ||
} | ||
|
||
func init() { | ||
rekorCmd.Flags().StringVarP( | ||
&outFile, | ||
"out-file", | ||
"o", | ||
"", | ||
"Filename to write out the JSON-encoded object", | ||
) | ||
reportCmd.MarkFlagRequired("out-file") //nolint:errcheck | ||
} | ||
|
||
func parseRekorEntry(_ *cobra.Command, args []string) error { | ||
fmt.Println("EXPERIMENTAL FEATURE. DO NOT USE IN PRODUCTION.") | ||
|
||
entryFile := args[0] | ||
readFile, err := os.Open(entryFile) | ||
if err != nil { | ||
return fmt.Errorf("error reading file: %w", err) | ||
} | ||
|
||
fileScanner := bufio.NewScanner(readFile) | ||
fileScanner.Split(bufio.ScanLines) | ||
var fileLines [][]byte | ||
|
||
for fileScanner.Scan() { | ||
fileLines = append(fileLines, fileScanner.Bytes()) | ||
} | ||
|
||
readFile.Close() | ||
|
||
for _, line := range fileLines { | ||
lineStr := string(line) | ||
if strings.Contains(lineStr, "publicKey") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
pkB64Raw := strings.TrimPrefix(lineStr, " \"publicKey\": ") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
pkB64 := strings.Trim(pkB64Raw, "\"") | ||
|
||
pkPem, err := base64.StdEncoding.DecodeString(pkB64) | ||
if err != nil { | ||
return fmt.Errorf("error decoding base64-encoded public key: %w", err) | ||
} | ||
|
||
// dedup | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you clarify this comment? |
||
// ensure the out directory exists | ||
if err = fileio.CreateOutDir(outFile); err != nil { | ||
return fmt.Errorf("error creating output directory for file %s: %w", outFile, err) | ||
} | ||
|
||
return os.WriteFile(outFile, pkPem, 0644) //nolint:gosec | ||
} | ||
} | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? This is the default, right?
Split sets the split function for the Scanner. The default split function is ScanLines.
From https://pkg.go.dev/bufio#Scanner.Split