|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | # |
3 | | -# Scrape a docker image and upload as SBOM file |
| 3 | +# Scrape a docker image and upload as public or private SBOM file |
4 | 4 | # |
5 | 5 | # Preparation: |
6 | 6 | # |
@@ -48,20 +48,22 @@ FORMAT=cyclonedx |
48 | 48 | # credentials directory has 0600 permissions |
49 | 49 | CLIENTSECRET_FILE=credentials/client_secret |
50 | 50 | SBOM=false |
| 51 | +PRIVACY=PUBLIC |
51 | 52 |
|
52 | 53 | URL=https://app.rkvst.io |
53 | 54 |
|
54 | 55 | usage() { |
55 | 56 | cat >&2 <<EOF |
56 | 57 |
|
57 | | -Scrape an SBOM from a docker image |
| 58 | +Scrape an SBOM from a docker image and upload to abom archivist |
58 | 59 |
|
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] |
60 | 61 |
|
61 | 62 | -c clientsecretfile containing client secret (default ${CLIENTSECRET_FILE}) |
62 | 63 | -o FORMAT default ($FORMAT) [cyclonedx] |
63 | 64 | -s default ($SBOM) if specified the second argument is an sbom file |
64 | 65 | and -o is ignored. |
| 66 | + -p upload private SBOM |
65 | 67 | -u URL URL Default ($URL) |
66 | 68 |
|
67 | 69 | Example: |
|
73 | 75 | exit 1 |
74 | 76 | } |
75 | 77 |
|
76 | | -while getopts "c:ho:su:" o; do |
| 78 | +while getopts "c:ho:psu:" o; do |
77 | 79 | case "${o}" in |
78 | 80 | c) CLIENTSECRET_FILE="${OPTARG}" |
79 | 81 | ;; |
80 | 82 | o) FORMAT=${OPTARG} |
81 | 83 | ;; |
| 84 | + p) PRIVACY=PRIVATE |
| 85 | + ;; |
82 | 86 | s) SBOM=true |
83 | 87 | ;; |
84 | 88 | u) URL=$OPTARG |
@@ -165,14 +169,14 @@ EOF |
165 | 169 | # ---------------------------------------------------------------------------- |
166 | 170 | # Upload SBOM |
167 | 171 | # ---------------------------------------------------------------------------- |
168 | | -log "Upload ${OUTPUT}" |
| 172 | +log "Upload ${PRIVACY} ${OUTPUT}" |
169 | 173 |
|
170 | 174 | HTTP_STATUS=$(curl -s -w "%{http_code}" -X POST \ |
171 | 175 | -o "${TEMPDIR}/upload" \ |
172 | 176 | -H "@${BEARER_TOKEN_FILE}" \ |
173 | 177 | -H "content_type=text/xml" \ |
174 | 178 | -F "sbom=@${OUTPUT}" \ |
175 | | - "${URL}/archivist/v1/sboms") |
| 179 | + "${URL}/archivist/v1/sboms?privacy=${PRIVACY}") |
176 | 180 |
|
177 | 181 | if [ "${HTTP_STATUS}" != "200" ] |
178 | 182 | then |
|
0 commit comments