Skip to content

Commit

Permalink
integration
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
  • Loading branch information
LaurentGoderre committed Sep 30, 2024
1 parent 12e14c2 commit 291f3ae
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9213,7 +9213,13 @@ cat <<EOF > $BUILDKIT_SCAN_DESTINATION/spdx.json
{
"_type": "https://in-toto.io/Statement/v0.1",
"predicateType": "https://spdx.dev/Document",
"predicate": {"name": "fallback"}
"predicate": {
"name": "fallback",
"extraParams": {
"ARG1": "$BUILDKIT_SCAN_ARG1",
"ARG2": "$BUILDKIT_SCAN_ARG2"
}
}
}
EOF
`
Expand Down Expand Up @@ -9436,6 +9442,38 @@ EOF
require.Equal(t, "https://in-toto.io/Statement/v0.1", attest.Type)
require.Equal(t, intoto.PredicateSPDX, attest.PredicateType)
require.Subset(t, attest.Predicate, map[string]interface{}{"name": "frontend"})

// test configuring the scanner (simple)
target = registry + "/buildkit/testsbom4:latest"
_, err = c.Build(sb.Context(), SolveOpt{
FrontendAttrs: map[string]string{
"attest:sbom": "generator=" + scannerTarget + ",ARG1=foo,ARG2=bar",
},
Exports: []ExportEntry{
{
Type: ExporterImage,
Attrs: map[string]string{
"name": target,
"push": "true",
},
},
},
}, "", makeTargetFrontend(false), nil)
require.NoError(t, err)

desc, provider, err = contentutil.ProviderFromRef(target)
require.NoError(t, err)

imgs, err = testutil.ReadImages(sb.Context(), provider, desc)
require.NoError(t, err)
require.Equal(t, 2, len(imgs.Images))

att = imgs.Find("unknown/unknown")
attest = intoto.Statement{}
require.NoError(t, json.Unmarshal(att.LayersRaw[0], &attest))
require.Equal(t, "https://in-toto.io/Statement/v0.1", attest.Type)
require.Equal(t, intoto.PredicateSPDX, attest.PredicateType)
require.Subset(t, attest.Predicate, map[string]interface{}{"extraParams": map[string]interface{}{"ARG1": "foo", "ARG2": "bar"}})
}

func testSBOMScanSingleRef(t *testing.T, sb integration.Sandbox) {
Expand Down

0 comments on commit 291f3ae

Please sign in to comment.