anthonyharrison / distro2SBOM

Generates SBOM files from system packaging information
Apache License 2.0
10 stars 7 forks source link

Issue on running utility on CentOS 7 #12

Closed acdmail closed 3 months ago

acdmail commented 3 months ago

hi, On try to run the distro2sbom on CentOS i am getting below:

distro2sbom --distro rpm --system --format json --output-file /tmp/test.txt --sbom cyclonedx --format json Traceback (most recent call last): File "/usr/local/bin/distro2sbom", line 8, in sys.exit(main()) File "/usr/local/lib/python3.8/site-packages/distro2sbom/cli.py", line 203, in main sbom_build = RpmBuilder(args["name"], args["release"], args["debug"]) File "/usr/local/lib/python3.8/site-packages/distro2sbom/distrobuilder/rpmbuilder.py", line 21, in init self.system_data = self.get_system() File "/usr/local/lib/python3.8/site-packages/distro2sbom/distrobuilder/distrobuilder.py", line 81, in get_system metadata[data[0].lower()] = data[1].replace('"', "").strip() IndexError: list index out of range

It seems to be related to the fact that /etc/os-release in CentOS 7 is containing empty lines like below, so most probably code to be updated to take this in account:

NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"

Thanks in advance, Oleg

anthonyharrison commented 3 months ago

@acdmail Thanks for raising. The bug seems to be related to the blank line in the /etc/os-release file.