CycloneDX / cyclonedx-linux-generator

Lockheed Martin developed utility to generate CycloneDX SBOMs for Linux distributions
https://cyclonedx.org/
Other
39 stars 14 forks source link

System locale different than en_US #55

Open vielfarbig opened 2 years ago

vielfarbig commented 2 years ago

Hello,

if the system locale is different than en_US you get the internationalized output of apt, but the output is parsed based on the english words. Therefore the building of the SBOM fails:

$JAVA_HOME is already set.
/usr/lib/jvm/java-11-openjdk-amd64
Found ./target/linux-sbom-generator-3.1.0-SNAPSHOT-jar-with-dependencies.jar
2022-07-11 11:54:49 DEBUG SBomGenerator:229 - Attempting to build SBOM for Ubuntu.
2022-07-11 11:54:49 INFO  SBomGenerator:255 - Ubuntu, uses the APT package manager.
2022-07-11 11:54:49 DEBUG UnixSBomGenerator:58 - Processing 883 software programs.
2022-07-11 11:54:49 DEBUG UnixSBomGenerator:68 - Generating Component (accountsservice)
2022-07-11 11:54:49 DEBUG UnixSBomGenerator:96 - Attempting to get software (accountsservice) version via: apt policy accountsservice
2022-07-11 11:54:50 DEBUG UnixSBomGenerator:116 - Found Version (null) for accountsservice.
2022-07-11 11:54:50 ERROR UnixSBomGenerator:394 - Unexpected process exit value (100), while attempting to generate the Detail Map!
2022-07-11 11:54:50 ERROR UnixSBomGenerator:543 - Unable to process Unix Command's output while attempting to get the software details (apt show accountsservice=null)!
org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.exceptions.SBomException: Unexpected process exit value (100), while attempting to generate the Detail Map!
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.generator.UnixSBomGenerator.processDetailMapCommand(UnixSBomGenerator.java:395)
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.generator.UnixSBomGenerator.produceDetailMap(UnixSBomGenerator.java:537)
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.generator.UbuntuSBomGenerator.produceDetailMap(UbuntuSBomGenerator.java:195)
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.generator.UbuntuSBomGenerator.generateSBom(UbuntuSBomGenerator.java:69)
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.generator.SBomGenerator.generateSBom(SBomGenerator.java:257)
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.UnixSbomGeneratorApplication.main(UnixSbomGeneratorApplication.java:65)
2022-07-11 11:54:50 ERROR UnixSbomGeneratorApplication:70 - Unexpected process exit value (100), while attempting to generate the Detail Map!
org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.exceptions.SBomException: Unexpected process exit value (100), while attempting to generate the Detail Map!
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.generator.UnixSBomGenerator.processDetailMapCommand(UnixSBomGenerator.java:395)
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.generator.UnixSBomGenerator.produceDetailMap(UnixSBomGenerator.java:537)
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.generator.UbuntuSBomGenerator.produceDetailMap(UbuntuSBomGenerator.java:195)
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.generator.UbuntuSBomGenerator.generateSBom(UbuntuSBomGenerator.java:69)
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.generator.SBomGenerator.generateSBom(SBomGenerator.java:257)
    at org.cyclonedx.contrib.com.lmco.efoss.unix.sbom.UnixSbomGeneratorApplication.main(UnixSbomGeneratorApplication.java:65)
2022-07-11 11:54:50 INFO  UnixSbomGeneratorApplication:99 - It took 980 MILLISECONDS to fail to build the Software Bill Of Materials (SBOM)! 

So in german it is:

> apt policy accountsservice
accountsservice:
  Installiert:           0.6.55-0ubuntu12~20.04.5
  Installationskandidat: 0.6.55-0ubuntu12~20.04.5
  Versionstabelle:
 *** 0.6.55-0ubuntu12~20.04.5 500
        500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://archive.ubuntu.com/ubuntu focal-security/main amd64 Packages
        100 /var/lib/dpkg/status
     0.6.55-0ubuntu11 500
        500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages 

But it greps "Installed" instead of the german "Installiert".

The solution is to set the system language to en_US.