Skip to content

Commit 999e6a2

Browse files
lcarvarhopp
authored andcommitted
Remove chunked encoding
In some cases, 'transfer-encoding: chunked' is causing curl to hang indefinetly when uploading an SBOM. There are two reasons one may want to use this chunked encoding. First, if the length of the content being uploaded is unknown. This is not the case here since we have the full file before making the API call. Second, if the file being uploaded is excessively large, the targeted server may require the data to be streamed via chunks. Although SBOMs can be quite large, we don't seem to be anywhere near it. (The limit on TPA is currently not documented.) It is also important to call out that when using chunked encoding, "the content-length header must be omitted": https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Transfer-Encoding#chunked For these reasonse, this commit removes the chunked encoding. Additionally, the default `retry-max-timeout` is changed from 0 (no timeout) to 10 minutes which should be quite generous. The default value is used if the token doesn't provide its own expiration. Signed-off-by: Luiz Carvalho <[email protected]>
1 parent 1cb8b3b commit 999e6a2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

rhtap/upload-sbom-to-trustification.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,21 +186,20 @@ for sbom_path in "${sboms_to_upload[@]}"; do
186186
token_type="$(jq -r .token_type <<< "$token_response")"
187187
expires_in="$(jq -r ".expires_in // empty" <<< "$token_response")"
188188

189-
retry_max_time=0 # no limit
189+
retry_max_time=600 # 10 minutes as the default value
190190
if [[ -n "$expires_in" ]]; then
191-
retry_max_time="$expires_in"
191+
retry_max_time="$expires_in" # Adjust timeout to match token expiration
192192
fi
193193

194194
# This sbom_id is the one created in the gather-sboms step - sha256:${checksum}
195195
sbom_id="$(basename -s .json "$sbom_path")"
196196
supported_version_of_sbom="${sbom_path}.supported_version"
197197

198-
echo "Uploading SBOM to $bombastic_api_url (with id=$sbom_id)"
198+
echo "Uploading SBOM to $bombastic_api_url (with id=$sbom_id) [retry_max_time=$retry_max_time]"
199199
# https://docs.trustification.dev/trustification/user/bombastic.html#publishing-an-sbom-doc
200200
curl "${curl_opts[@]}" \
201201
--retry-max-time "$retry_max_time" \
202202
-H "authorization: $token_type $access_token" \
203-
-H "transfer-encoding: chunked" \
204203
-H "content-type: application/json" \
205204
--data "@$supported_version_of_sbom" \
206205
"$bombastic_api_url/api/v2/sbom?id=$sbom_id"

0 commit comments

Comments
 (0)