Skip to content

Commit 360b27c

Browse files
Add sbom scanning command
1 parent e22b5e2 commit 360b27c

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

.test/meta-commands/out.sh

+70
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ jq '
5353
' temp/index.json > temp/index.json.new
5454
mv temp/index.json.new temp/index.json
5555
# </build>
56+
# <sbom_scan>
57+
docker buildx build --progress=plain \
58+
--provenance=false \
59+
--sbom=generator="$BASHBREW_BUILDKIT_SBOM_GENERATOR" \
60+
--tag 'docker:24.0.7-cli' \
61+
--tag 'docker:24.0-cli' \
62+
--tag 'docker:24-cli' \
63+
--tag 'docker:cli' \
64+
--tag 'docker:24.0.7-cli-alpine3.18' \
65+
--tag 'amd64/docker:24.0.7-cli' \
66+
--tag 'amd64/docker:24.0-cli' \
67+
--tag 'amd64/docker:24-cli' \
68+
--tag 'amd64/docker:cli' \
69+
--tag 'amd64/docker:24.0.7-cli-alpine3.18' \
70+
--tag 'oisupport/staging-amd64:4b199ac326c74b3058a147e14f553af9e8e1659abc29bd3e82c9c9807b66ee43' \
71+
--output '"type=oci","tar=false","dest=sbom"' \
72+
- <<<'FROM oisupport/staging-amd64:4b199ac326c74b3058a147e14f553af9e8e1659abc29bd3e82c9c9807b66ee43@sha256:0432a4d379794811b4a2e01d0d3e67a9bcf95d6c2bf71545f03bce3f1d60f401'
73+
# </sbom_scan>
5674
# <push>
5775
crane push temp 'oisupport/staging-amd64:4b199ac326c74b3058a147e14f553af9e8e1659abc29bd3e82c9c9807b66ee43'
5876
rm -rf temp
@@ -88,6 +106,30 @@ SOURCE_DATE_EPOCH=1700741054 \
88106
--file 'Dockerfile' \
89107
'https://github.com/docker-library/docker.git#6d541d27b5dd12639e5a33a675ebca04d3837d74:24/windows/windowsservercore-ltsc2022'
90108
# </build>
109+
# <sbom_scan>
110+
docker buildx build --progress=plain \
111+
--provenance=false \
112+
--sbom=generator="$BASHBREW_BUILDKIT_SBOM_GENERATOR" \
113+
--tag 'docker:24.0.7-windowsservercore-ltsc2022' \
114+
--tag 'docker:24.0-windowsservercore-ltsc2022' \
115+
--tag 'docker:24-windowsservercore-ltsc2022' \
116+
--tag 'docker:windowsservercore-ltsc2022' \
117+
--tag 'docker:24.0.7-windowsservercore' \
118+
--tag 'docker:24.0-windowsservercore' \
119+
--tag 'docker:24-windowsservercore' \
120+
--tag 'docker:windowsservercore' \
121+
--tag 'winamd64/docker:24.0.7-windowsservercore-ltsc2022' \
122+
--tag 'winamd64/docker:24.0-windowsservercore-ltsc2022' \
123+
--tag 'winamd64/docker:24-windowsservercore-ltsc2022' \
124+
--tag 'winamd64/docker:windowsservercore-ltsc2022' \
125+
--tag 'winamd64/docker:24.0.7-windowsservercore' \
126+
--tag 'winamd64/docker:24.0-windowsservercore' \
127+
--tag 'winamd64/docker:24-windowsservercore' \
128+
--tag 'winamd64/docker:windowsservercore' \
129+
--tag 'oisupport/staging-windows-amd64:9b405cfa5b88ba65121aabdb95ae90fd2e1fee7582174de82ae861613ae3072e' \
130+
--output '"type=oci","tar=false","dest=sbom"' \
131+
- <<<'FROM oisupport/staging-windows-amd64:9b405cfa5b88ba65121aabdb95ae90fd2e1fee7582174de82ae861613ae3072e@sha256:69aba7120e3f4014bfa80f4eae2cfc9698dcb6b8a5d64daf06de4039a19846ce'
132+
# </sbom_scan>
91133
# <push>
92134
docker push 'oisupport/staging-windows-amd64:9b405cfa5b88ba65121aabdb95ae90fd2e1fee7582174de82ae861613ae3072e'
93135
# </push>
@@ -174,6 +216,34 @@ done
174216
jq -r --argjson sbomManifestDesc "$sbomManifestDesc" '.manifests += [ $sbomManifestDesc ]' temp/index.json > temp/index.json.new
175217
mv temp/index.json.new temp/index.json
176218
# </build>
219+
# <sbom_scan>
220+
docker buildx build --progress=plain \
221+
--provenance=false \
222+
--sbom=generator="$BASHBREW_BUILDKIT_SBOM_GENERATOR" \
223+
--tag 'busybox:1.36.1' \
224+
--tag 'busybox:1.36' \
225+
--tag 'busybox:1' \
226+
--tag 'busybox:stable' \
227+
--tag 'busybox:latest' \
228+
--tag 'busybox:1.36.1-glibc' \
229+
--tag 'busybox:1.36-glibc' \
230+
--tag 'busybox:1-glibc' \
231+
--tag 'busybox:stable-glibc' \
232+
--tag 'busybox:glibc' \
233+
--tag 'amd64/busybox:1.36.1' \
234+
--tag 'amd64/busybox:1.36' \
235+
--tag 'amd64/busybox:1' \
236+
--tag 'amd64/busybox:stable' \
237+
--tag 'amd64/busybox:latest' \
238+
--tag 'amd64/busybox:1.36.1-glibc' \
239+
--tag 'amd64/busybox:1.36-glibc' \
240+
--tag 'amd64/busybox:1-glibc' \
241+
--tag 'amd64/busybox:stable-glibc' \
242+
--tag 'amd64/busybox:glibc' \
243+
--tag 'oisupport/staging-amd64:191402ad0feacf03daf9d52a492207e73ef08b0bd17265043aea13aa27e2bb3f' \
244+
--output '"type=oci","tar=false","dest=sbom"' \
245+
- <<<'FROM oisupport/staging-amd64:191402ad0feacf03daf9d52a492207e73ef08b0bd17265043aea13aa27e2bb3f@sha256:4be429a5fbb2e71ae7958bfa558bc637cf3a61baf40a708cb8fff532b39e52d0'
246+
# </sbom_scan>
177247
# <push>
178248
crane push --index temp 'oisupport/staging-amd64:191402ad0feacf03daf9d52a492207e73ef08b0bd17265043aea13aa27e2bb3f'
179249
rm -rf temp

meta.jq

+55
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,60 @@ def build_command:
369369
error("unknown/unimplemented Builder: \($builder)")
370370
end
371371
;
372+
373+
# input: "build" object (with "buildId" top level key)
374+
def image_digest:
375+
.build.resolved.manifests[0].digest
376+
;
377+
378+
# input: "build" object (with "buildId" top level key)
379+
def image_ref:
380+
"\(.build.img)@\(image_digest)"
381+
;
382+
383+
# input: "build" object (with "buildId" top level key)
384+
# output: string "command for generating an SBOM from an OCI layout", may be multiple lines, expects to run in Bash with "set -Eeuo pipefail"
385+
def sbom_command:
386+
[
387+
(
388+
[
389+
"docker buildx build --progress=plain",
390+
"--provenance=false",
391+
"--sbom=generator=\"$BASHBREW_BUILDKIT_SBOM_GENERATOR\"",
392+
(
393+
(
394+
.source.arches[.build.arch]
395+
| .tags[], .archTags[]
396+
),
397+
.build.img
398+
| "--tag " + @sh
399+
),
400+
"--output " + (
401+
[
402+
"type=oci",
403+
"tar=false",
404+
"dest=sbom",
405+
empty
406+
]
407+
| @csv
408+
| @sh
409+
),
410+
"- <<<" + (
411+
[
412+
"FROM ",
413+
image_ref,
414+
empty
415+
]
416+
| join("")
417+
| @sh
418+
),
419+
empty
420+
] | join(" \\\n\t")
421+
),
422+
empty
423+
] | join("\n")
424+
;
425+
372426
# input: "build" object (with "buildId" top level key)
373427
# output: string "push command" ("docker push ..."), may be multiple lines, expects to run in Bash with "set -Eeuo pipefail"
374428
def push_command:
@@ -398,6 +452,7 @@ def commands:
398452
{
399453
pull: pull_command,
400454
build: build_command,
455+
sbom_scan: sbom_command,
401456
push: push_command,
402457
}
403458
;

0 commit comments

Comments
 (0)