Skip to content

Commit 7bc34ff

Browse files
Paul Hewletteccles
authored andcommitted
SBOM scraper uploads only PUBLIC files
Problem: The backend has defaulted to private uploads but this script should default to PUBLIC uploads. Solution: Added -p option to specify PRIVATE and default to PUBLIC if unspecified. Signed-off-by: Paul Hewlett <[email protected]>
1 parent 5991a95 commit 7bc34ff

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scripts/sbom_scraper.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#
3-
# Scrape a docker image and upload as SBOM file
3+
# Scrape a docker image and upload as public or private SBOM file
44
#
55
# Preparation:
66
#
@@ -48,20 +48,22 @@ FORMAT=cyclonedx
4848
# credentials directory has 0600 permissions
4949
CLIENTSECRET_FILE=credentials/client_secret
5050
SBOM=false
51+
PRIVACY=PUBLIC
5152

5253
URL=https://app.rkvst.io
5354

5455
usage() {
5556
cat >&2 <<EOF
5657
57-
Scrape an SBOM from a docker image
58+
Scrape an SBOM from a docker image and upload to abom archivist
5859
59-
Usage: $SCRIPTNAME [-c clientsecretfile] [-o output format] [-s sbomFile ] [-u url] client_id [docker-image|sbom file]
60+
Usage: $SCRIPTNAME [-p] [-c clientsecretfile] [-o output format] [-s sbomFile ] [-u url] client_id [docker-image|sbom file]
6061
6162
-c clientsecretfile containing client secret (default ${CLIENTSECRET_FILE})
6263
-o FORMAT default ($FORMAT) [cyclonedx]
6364
-s default ($SBOM) if specified the second argument is an sbom file
6465
and -o is ignored.
66+
-p upload private SBOM
6567
-u URL URL Default ($URL)
6668
6769
Example:
@@ -73,12 +75,14 @@ EOF
7375
exit 1
7476
}
7577

76-
while getopts "c:ho:su:" o; do
78+
while getopts "c:ho:psu:" o; do
7779
case "${o}" in
7880
c) CLIENTSECRET_FILE="${OPTARG}"
7981
;;
8082
o) FORMAT=${OPTARG}
8183
;;
84+
p) PRIVACY=PRIVATE
85+
;;
8286
s) SBOM=true
8387
;;
8488
u) URL=$OPTARG
@@ -165,14 +169,14 @@ EOF
165169
# ----------------------------------------------------------------------------
166170
# Upload SBOM
167171
# ----------------------------------------------------------------------------
168-
log "Upload ${OUTPUT}"
172+
log "Upload ${PRIVACY} ${OUTPUT}"
169173

170174
HTTP_STATUS=$(curl -s -w "%{http_code}" -X POST \
171175
-o "${TEMPDIR}/upload" \
172176
-H "@${BEARER_TOKEN_FILE}" \
173177
-H "content_type=text/xml" \
174178
-F "sbom=@${OUTPUT}" \
175-
"${URL}/archivist/v1/sboms")
179+
"${URL}/archivist/v1/sboms?privacy=${PRIVACY}")
176180

177181
if [ "${HTTP_STATUS}" != "200" ]
178182
then

0 commit comments

Comments
 (0)