Skip to content

Commit ad27465

Browse files
committed
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 0cab66e commit ad27465

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
@@ -179,21 +179,20 @@ for sbom_path in "${sboms_to_upload[@]}"; do
179179
token_type="$(jq -r .token_type <<< "$token_response")"
180180
expires_in="$(jq -r ".expires_in // empty" <<< "$token_response")"
181181

182-
retry_max_time=0 # no limit
182+
retry_max_time=600 # 10 minutes as the default value
183183
if [[ -n "$expires_in" ]]; then
184-
retry_max_time="$expires_in"
184+
retry_max_time="$expires_in" # Adjust timeout to match token expiration
185185
fi
186186

187187
# This sbom_id is the one created in the gather-sboms step - sha256:${checksum}
188188
sbom_id="$(basename -s .json "$sbom_path")"
189189
supported_version_of_sbom="${sbom_path}.supported_version"
190190

191-
echo "Uploading SBOM to $bombastic_api_url (with id=$sbom_id)"
191+
echo "Uploading SBOM to $bombastic_api_url (with id=$sbom_id) [retry_max_time=$retry_max_time]"
192192
# https://docs.trustification.dev/trustification/user/bombastic.html#publishing-an-sbom-doc
193193
curl "${curl_opts[@]}" \
194194
--retry-max-time "$retry_max_time" \
195195
-H "authorization: $token_type $access_token" \
196-
-H "transfer-encoding: chunked" \
197196
-H "content-type: application/json" \
198197
--data "@$supported_version_of_sbom" \
199198
"$bombastic_api_url/api/v2/sbom?id=$sbom_id"

0 commit comments

Comments
 (0)