From a741b307393637705a42fd5d135460d44b855a47 Mon Sep 17 00:00:00 2001 From: Kris Coleman Date: Sat, 15 Jun 2024 10:28:19 -0400 Subject: [PATCH] Chore/upstream go witness (#4) Signed-off-by: Kris Coleman Co-authored-by: Nick Kane Signed-off-by: Kris Coleman --- archivista/store.go | 2 +- attestation/link/link_test.go | 33 ++++++++- attestation/product/product.go | 5 ++ attestation/slsa/slsa_test.go | 14 ++-- attestation/vex/vex.go | 122 +++++++++++++++++++++++++++++++++ attestation/vex/vex_test.go | 98 ++++++++++++++++++++++++++ go.mod | 4 +- go.sum | 4 ++ 8 files changed, 270 insertions(+), 12 deletions(-) create mode 100644 attestation/vex/vex.go create mode 100644 attestation/vex/vex_test.go diff --git a/archivista/store.go b/archivista/store.go index f4ed58e2..ccba927a 100644 --- a/archivista/store.go +++ b/archivista/store.go @@ -22,7 +22,7 @@ import ( ) func (c *Client) Store(ctx context.Context, env dsse.Envelope) (string, error) { - resp, err := archivistaapi.Upload(ctx, c.url, env) + resp, err := archivistaapi.Store(ctx, c.url, env) if err != nil { return "", err } diff --git a/attestation/link/link_test.go b/attestation/link/link_test.go index 8c8a27e4..6da82646 100644 --- a/attestation/link/link_test.go +++ b/attestation/link/link_test.go @@ -129,7 +129,10 @@ func TestAttest(t *testing.T) { testJson := []byte(testLinkJSON) if !bytes.Equal(linkJson, testJson) { - t.Errorf("expected \n%s\n, got \n%s\n", testJson, linkJson) + testJson := []byte(testLinkJSONAlternative) + if !bytes.Equal(linkJson, testJson) { + t.Errorf("expected \n%s\n, got \n%s\n", testJson, linkJson) + } } } @@ -178,6 +181,7 @@ func setupLink(t *testing.T) *Link { return link } + func TestRegistration(t *testing.T) { registrations := attestation.RegistrationEntries() @@ -191,7 +195,6 @@ func TestRegistration(t *testing.T) { if !found { t.Errorf("expected %s to be registered", Name) } - } const testLinkJSON = `{ @@ -219,3 +222,29 @@ const testLinkJSON = `{ "COLORTERM": "truecolor" } }` + +const testLinkJSONAlternative = `{ + "name": "test", + "command": [ + "touch", + "test.txt" + ], + "materials": [ + { + "name": "test1", + "digest": { + "sha256": "a53d0741798b287c6dd7afa64aee473f305e65d3f49463bb9d7408ec3b12bf5f" + } + }, + { + "name": "test2", + "digest": { + "sha256": "a53d0741798b287c6dd7afa64aee473f305e65d3f49463bb9d7408ec3b12bf5f" + } + } + ], + "environment": { + "COLORFGBG": "7;0", + "COLORTERM": "truecolor" + } +}` diff --git a/attestation/product/product.go b/attestation/product/product.go index 23f3a3d6..9e834f32 100644 --- a/attestation/product/product.go +++ b/attestation/product/product.go @@ -241,6 +241,11 @@ func getFileContentType(fileName string) (string, error) { return bytes.HasPrefix(buf, []byte(` github.com/testifysec/rekor v0.4.0-dsse-intermediates-2 replace github.com/gin-gonic/gin v1.5.0 => github.com/gin-gonic/gin v1.7.7 - -replace github.com/opencontainers/image-spec => github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1 diff --git a/go.sum b/go.sum index b285f0b1..447e5b8c 100644 --- a/go.sum +++ b/go.sum @@ -261,8 +261,12 @@ github.com/open-policy-agent/opa v0.64.0 h1:2g0JTt78zxhFaoBmZViY4UXvtOlzBjhhrnyr github.com/open-policy-agent/opa v0.64.0/go.mod h1:j4VeLorVpKipnkQ2TDjWshEuV3cvP/rHzQhYaraUXZY= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/openvex/go-vex v0.2.5 h1:41utdp2rHgAGCsG+UbjmfMG5CWQxs15nGqir1eRgSrQ= +github.com/openvex/go-vex v0.2.5/go.mod h1:j+oadBxSUELkrKh4NfNb+BPo77U3q7gdKME88IO/0Wo= github.com/owenrumney/go-sarif v1.1.1 h1:QNObu6YX1igyFKhdzd7vgzmw7XsWN3/6NMGuDzBgXmE= github.com/owenrumney/go-sarif v1.1.1/go.mod h1:dNDiPlF04ESR/6fHlPyq7gHKmrM0sHUvAGjsoh8ZH0U= +github.com/package-url/packageurl-go v0.1.1 h1:KTRE0bK3sKbFKAk3yy63DpeskU7Cvs/x/Da5l+RtzyU= +github.com/package-url/packageurl-go v0.1.1/go.mod h1:uQd4a7Rh3ZsVg5j0lNyAfyxIeGde9yrlhjF78GzeW0c= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=