Skip to content

Error on py-sbom and py-trivy when use not slim image

Describe the bug

when using the version 7.0 with standard python image (not slim) py-sbom and py-trivy

Actual behavior

job fail

Logs and/or screenshots

[INFO] Syft version unset: retrieve latest version...
_linux_amd64.tar.gz
  File "<string>", line 1
    import urllib.request;urllib.request.urlretrieve("https://github.com/anchore/syft/releases/download/v1.4.1
                                                     ^
SyntaxError: unterminated string literal (detected at line 1)

https://gitlab.com/pytgaen-group/uvpipx/-/jobs/6885131003

Expected behavior

not fail

Context & Configuration

not but an explanation below

Explanation

the problem come from github_get_latest_version when the image is fat, we use curl command

but:

uu="anchore/syft"
aa=$(curl -sSf -I "https://github.com/$uu/releases/latest" | awk -F '/' '/location:/ { print $NF }')
printf "$aa" | xxd -
00000000: 7631 2e34 2e31 0d                        v1.4.1.

in fact there is 0d too many

the solution is to change the awk part

aa=$(curl -sSf -I "https://github.com/$uu/releases/latest" | awk -F '/' '/location:/ { sub(/(\r|\n)*$/, "", $NF); print $NF }')
printf "$aa" | xxd -
00000000: 7631 2e34 2e31                           v1.4.1
Edited by Gaëtan Montury