Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(license): add license handling to JUnit template #7409

Merged

Conversation

psibre
Copy link
Contributor

@psibre psibre commented Aug 27, 2024

Description

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@psibre psibre requested a review from knqyf263 as a code owner August 27, 2024 16:28
@psibre
Copy link
Contributor Author

psibre commented Aug 29, 2024

Preliminaries

psibre@go:~/trivy$ git worktree list
/home/psibre/trivy                     c96dcdd44 [main]
/home/psibre/trivy/fix-junit-template  2def603bf [psibre/fix-add-license-handling-to-junit-template]
psibre@go:~/trivy$ ./trivy version
2024/08/29 14:52:24 WARN Check ID is empty file_path=lib/docker/docker.rego
Version: 0.54.0-52-gc96dcdd44

I've created a Java project to produce a suitable SBOM specimen (see psibre/java-app-vuln-license-sbom-mwe@df7dc92), which I'll attach here for convenience:

Vulnerability scanner

Table format

psibre@go:~/trivy$ ./trivy sbom --quiet --scanners vuln sbom.json 
2024/08/29 14:56:24 WARN Check ID is empty file_path=lib/docker/docker.rego

Java (jar)

Total: 14 (UNKNOWN: 0, LOW: 0, MEDIUM: 5, HIGH: 7, CRITICAL: 2)

┌───────────────────────────────────┬────────────────┬──────────┬──────────┬───────────────────┬────────────────────────────────┬──────────────────────────────────────────────────────────────┐
│              Library              │ Vulnerability  │ Severity │  Status  │ Installed Version │         Fixed Version          │                            Title                             │
├───────────────────────────────────┼────────────────┼──────────┼──────────┼───────────────────┼────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│ com.google.protobuf:protobuf-java │ CVE-2021-22569 │ HIGH     │ fixed    │ 3.11.4            │ 3.16.1, 3.18.2, 3.19.2         │ protobuf-java: potential DoS in the parsing procedure for    │
│                                   │                │          │          │                   │                                │ binary data                                                  │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2021-22569                   │
│                                   ├────────────────┤          │          │                   ├────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│                                   │ CVE-2021-22570 │          │          │                   │ 3.15.0                         │ protobuf: Incorrect parsing of nullchar in the proto symbol  │
│                                   │                │          │          │                   │                                │ leads to Nullptr...                                          │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2021-22570                   │
│                                   ├────────────────┤          │          │                   ├────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│                                   │ CVE-2022-3509  │          │          │                   │ 3.16.3, 3.19.6, 3.20.3, 3.21.7 │ protobuf-java: Textformat parsing issue leads to DoS         │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2022-3509                    │
│                                   ├────────────────┤          │          │                   │                                ├──────────────────────────────────────────────────────────────┤
│                                   │ CVE-2022-3510  │          │          │                   │                                │ protobuf-java: Message-Type Extensions parsing issue leads   │
│                                   │                │          │          │                   │                                │ to DoS                                                       │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2022-3510                    │
│                                   ├────────────────┼──────────┤          │                   ├────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│                                   │ CVE-2022-3171  │ MEDIUM   │          │                   │ 3.21.7, 3.20.3, 3.19.6, 3.16.3 │ protobuf-java: timeout in parser leads to DoS                │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2022-3171                    │
├───────────────────────────────────┼────────────────┼──────────┤          ├───────────────────┼────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│ edu.stanford.nlp:stanford-corenlp │ CVE-2021-44550 │ CRITICAL │          │ 4.3.2             │ 4.4.0                          │ Access Control vulnerability within CoreNLP                  │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2021-44550                   │
│                                   ├────────────────┤          ├──────────┤                   ├────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│                                   │ CVE-2022-0239  │          │ affected │                   │                                │ corenlp is vulnerable to Improper Restriction of XML         │
│                                   │                │          │          │                   │                                │ External Entity Reference                                    │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2022-0239                    │
│                                   ├────────────────┼──────────┤          │                   ├────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│                                   │ CVE-2022-0198  │ MEDIUM   │          │                   │                                │ XML External Entity Reference in                             │
│                                   │                │          │          │                   │                                │ edu.stanford.nlp:stanford-corenlp                            │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2022-0198                    │
├───────────────────────────────────┼────────────────┼──────────┼──────────┼───────────────────┼────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│ xalan:xalan                       │ CVE-2022-34169 │ HIGH     │ fixed    │ 2.7.2             │ 2.7.3                          │ OpenJDK: integer truncation issue in Xalan-J (JAXP, 8285407) │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2022-34169                   │
├───────────────────────────────────┼────────────────┤          │          ├───────────────────┼────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│ xerces:xercesImpl                 │ CVE-2012-0881  │          │          │ 2.8.0             │ 2.12.0                         │ xml: xerces-j2 hash table collisions CPU usage DoS           │
│                                   │                │          │          │                   │                                │ (oCERT-2011-003)                                             │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2012-0881                    │
│                                   ├────────────────┤          │          │                   │                                ├──────────────────────────────────────────────────────────────┤
│                                   │ CVE-2013-4002  │          │          │                   │                                │ OpenJDK: XML parsing Denial of Service (JAXP, 8017298)       │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2013-4002                    │
│                                   ├────────────────┼──────────┤          │                   ├────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│                                   │ CVE-2009-2625  │ MEDIUM   │          │                   │ 2.10.0                         │ JDK: XML parsing Denial-Of-Service (6845701)                 │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2009-2625                    │
│                                   ├────────────────┤          │          │                   ├────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│                                   │ CVE-2020-14338 │          │          │                   │ 2.12.0.sp3                     │ wildfly: XML validation manipulation due to incomplete       │
│                                   │                │          │          │                   │                                │ application of use-grammar-pool-only in xercesImpl...        │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2020-14338                   │
│                                   ├────────────────┤          │          │                   ├────────────────────────────────┼──────────────────────────────────────────────────────────────┤
│                                   │ CVE-2022-23437 │          │          │                   │ 2.12.2                         │ xerces-j2: infinite loop when handling specially crafted XML │
│                                   │                │          │          │                   │                                │ document payloads                                            │
│                                   │                │          │          │                   │                                │ https://avd.aquasec.com/nvd/cve-2022-23437                   │
└───────────────────────────────────┴────────────────┴──────────┴──────────┴───────────────────┴────────────────────────────────┴──────────────────────────────────────────────────────────────┘

JUnit XML format

contrib/junit.tplpsibre@go:~/trivy$ ./trivy sbom --quiet --scanners vuln --format template \
  --template @contrib/junit.tpl sbom.json 
2024/08/29 15:00:08 WARN Check ID is empty file_path=lib/docker/docker.rego
<?xml version="1.0" ?>
<testsuites name="trivy">
    <testsuite tests="14" failures="14" name="Java" errors="0" skipped="0" time="">
        <properties>
            <property name="type" value="jar"></property>
        </properties>
        <testcase classname="com.google.protobuf:protobuf-java-3.11.4" name="[HIGH] CVE-2021-22569" time="">
            <failure message="protobuf-java: potential DoS in the parsing procedure for binary data" type="description">An issue in protobuf-java allowed the interleaving of com.google.protobuf.UnknownFieldSet fields in such a way that would be processed out of order. A small malicious payload can occupy the parser for several minutes by creating large numbers of short-lived objects that cause frequent, repeated pauses. We recommend upgrading libraries beyond the vulnerable versions.</failure>
        </testcase>
        <testcase classname="com.google.protobuf:protobuf-java-3.11.4" name="[HIGH] CVE-2021-22570" time="">
            <failure message="protobuf: Incorrect parsing of nullchar in the proto symbol leads to Nullptr dereference" type="description">Nullptr dereference when a null char is present in a proto symbol. The symbol is parsed incorrectly, leading to an unchecked call into the proto file&#39;s name during generation of the resulting error message. Since the symbol is incorrectly parsed, the file is nullptr. We recommend upgrading to version 3.15.0 or greater.</failure>
        </testcase>
        <testcase classname="com.google.protobuf:protobuf-java-3.11.4" name="[HIGH] CVE-2022-3509" time="">
            <failure message="protobuf-java: Textformat parsing issue leads to DoS" type="description">A parsing issue similar to CVE-2022-3171, but with textformat in protobuf-java core and lite versions prior to 3.21.7, 3.20.3, 3.19.6 and 3.16.3 can lead to a denial of service attack. Inputs containing multiple instances of non-repeated embedded messages with repeated or unknown fields causes objects to be converted back-n-forth between mutable and immutable forms, resulting in potentially long garbage collection pauses. We recommend updating to the versions mentioned above.</failure>
        </testcase>
        <testcase classname="com.google.protobuf:protobuf-java-3.11.4" name="[HIGH] CVE-2022-3510" time="">
            <failure message="protobuf-java: Message-Type Extensions parsing issue leads to DoS" type="description">A parsing issue similar to CVE-2022-3171, but with Message-Type Extensions in protobuf-java core and lite versions prior to 3.21.7, 3.20.3, 3.19.6 and 3.16.3 can lead to a denial of service attack. Inputs containing multiple instances of non-repeated embedded messages with repeated or unknown fields causes objects to be converted back-n-forth between mutable and immutable forms, resulting in potentially long garbage collection pauses. We recommend updating to the versions mentioned above.&#xA;&#xA;</failure>
        </testcase>
        <testcase classname="com.google.protobuf:protobuf-java-3.11.4" name="[MEDIUM] CVE-2022-3171" time="">
            <failure message="protobuf-java: timeout in parser leads to DoS" type="description">A parsing issue with binary data in protobuf-java core and lite versions prior to 3.21.7, 3.20.3, 3.19.6 and 3.16.3 can lead to a denial of service attack. Inputs containing multiple instances of non-repeated embedded messages with repeated or unknown fields causes objects to be converted back-n-forth between mutable and immutable forms, resulting in potentially long garbage collection pauses. We recommend updating to the versions mentioned above.</failure>
        </testcase>
        <testcase classname="edu.stanford.nlp:stanford-corenlp-4.3.2" name="[CRITICAL] CVE-2021-44550" time="">
            <failure message="Access Control vulnerability within CoreNLP" type="description">An Incorrect Access Control vulnerability exists in CoreNLP 4.3.2 via the classifier in NERServlet.java (lines 158 and 159).</failure>
        </testcase>
        <testcase classname="edu.stanford.nlp:stanford-corenlp-4.3.2" name="[CRITICAL] CVE-2022-0239" time="">
            <failure message="corenlp is vulnerable to Improper Restriction of XML External Entity Reference" type="description">corenlp is vulnerable to Improper Restriction of XML External Entity Reference</failure>
        </testcase>
        <testcase classname="edu.stanford.nlp:stanford-corenlp-4.3.2" name="[MEDIUM] CVE-2022-0198" time="">
            <failure message="XML External Entity Reference in edu.stanford.nlp:stanford-corenlp" type="description">corenlp is vulnerable to Improper Restriction of XML External Entity Reference</failure>
        </testcase>
        <testcase classname="xalan:xalan-2.7.2" name="[HIGH] CVE-2022-34169" time="">
            <failure message="OpenJDK: integer truncation issue in Xalan-J (JAXP, 8285407)" type="description">The Apache Xalan Java XSLT library is vulnerable to an integer truncation issue when processing malicious XSLT stylesheets. This can be used to corrupt Java class files generated by the internal XSLTC compiler and execute arbitrary Java bytecode. Users are recommended to update to version 2.7.3 or later. Note: Java runtimes (such as OpenJDK) include repackaged copies of Xalan.</failure>
        </testcase>
        <testcase classname="xerces:xercesImpl-2.8.0" name="[HIGH] CVE-2012-0881" time="">
            <failure message="xml: xerces-j2 hash table collisions CPU usage DoS (oCERT-2011-003)" type="description">Apache Xerces2 Java Parser before 2.12.0 allows remote attackers to cause a denial of service (CPU consumption) via a crafted message to an XML service, which triggers hash table collisions.</failure>
        </testcase>
        <testcase classname="xerces:xercesImpl-2.8.0" name="[HIGH] CVE-2013-4002" time="">
            <failure message="OpenJDK: XML parsing Denial of Service (JAXP, 8017298)" type="description">XMLscanner.java in Apache Xerces2 Java Parser before 2.12.0, as used in the Java Runtime Environment (JRE) in IBM Java 5.0 before 5.0 SR16-FP3, 6 before 6 SR14, 6.0.1 before 6.0.1 SR6, and 7 before 7 SR5 as well as Oracle Java SE 7u40 and earlier, Java SE 6u60 and earlier, Java SE 5.0u51 and earlier, JRockit R28.2.8 and earlier, JRockit R27.7.6 and earlier, Java SE Embedded 7u40 and earlier, and possibly other products allows remote attackers to cause a denial of service via vectors related to XML attribute names.</failure>
        </testcase>
        <testcase classname="xerces:xercesImpl-2.8.0" name="[MEDIUM] CVE-2009-2625" time="">
            <failure message="JDK: XML parsing Denial-Of-Service (6845701)" type="description">XMLScanner.java in Apache Xerces2 Java, as used in Sun Java Runtime Environment (JRE) in JDK and JRE 6 before Update 15 and JDK and JRE 5.0 before Update 20, and in other products, allows remote attackers to cause a denial of service (infinite loop and application hang) via malformed XML input, as demonstrated by the Codenomicon XML fuzzing framework.</failure>
        </testcase>
        <testcase classname="xerces:xercesImpl-2.8.0" name="[MEDIUM] CVE-2020-14338" time="">
            <failure message="wildfly: XML validation manipulation due to incomplete application of use-grammar-pool-only in xercesImpl" type="description">A flaw was found in Wildfly&#39;s implementation of Xerces, specifically in the way the XMLSchemaValidator class in the JAXP component of Wildfly enforced the &#34;use-grammar-pool-only&#34; feature. This flaw allows a specially-crafted XML file to manipulate the validation process in certain cases. This issue is the same flaw as CVE-2020-14621, which affected OpenJDK, and uses a similar code. This flaw affects all Xerces JBoss versions before 2.12.0.SP3.</failure>
        </testcase>
        <testcase classname="xerces:xercesImpl-2.8.0" name="[MEDIUM] CVE-2022-23437" time="">
            <failure message="xerces-j2: infinite loop when handling specially crafted XML document payloads" type="description">There&#39;s a vulnerability within the Apache Xerces Java (XercesJ) XML parser when handling specially crafted XML document payloads. This causes, the XercesJ XML parser to wait in an infinite loop, which may sometimes consume system resources for prolonged duration. This vulnerability is present within XercesJ version 2.12.1 and the previous versions.</failure>
        </testcase>
    </testsuite>
    <testsuite tests="0" failures="0" name="Java" errors="0" skipped="0" time="">
        <properties>
            <property name="type" value="jar"></property>
        </properties>
    </testsuite>
</testsuites>

License scanner

Table format

psibre@go:~/trivy$ ./trivy sbom --quiet --scanners license sbom.json 
2024/08/29 15:02:27 WARN Check ID is empty file_path=lib/docker/docker.rego

Java (license)

Total: 30 (UNKNOWN: 3, LOW: 23, MEDIUM: 3, HIGH: 1, CRITICAL: 0)

┌───────────────────────────────────────────┬────────────────────────────────────────────────────┬────────────────┬──────────┐
│                  Package                  │                      License                       │ Classification │ Severity │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┼────────────────┼──────────┤
│ com.apple:AppleJavaExtensions             │ Apple License                                      │ Non Standard   │ UNKNOWN  │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┼────────────────┼──────────┤
│ com.google.code.findbugs:jsr305           │ Apache-2.0                                         │ Notice         │ LOW      │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┤                │          │
│ com.google.protobuf:protobuf-java         │ BSD-3-Clause                                       │                │          │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┼────────────────┼──────────┤
│ com.sun.xml.bind:jaxb-core                │ CDDL-1.1                                           │ Reciprocal     │ MEDIUM   │
├───────────────────────────────────────────┤                                                    │                │          │
│ com.sun.xml.bind:jaxb-impl                │                                                    │                │          │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┼────────────────┼──────────┤
│ de.jollyday:jollyday                      │ Apache-2.0                                         │ Notice         │ LOW      │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┼────────────────┼──────────┤
│ edu.stanford.nlp:stanford-corenlp         │ GNU General Public License Version 3               │ Non Standard   │ UNKNOWN  │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┼────────────────┼──────────┤
│ javax.xml.bind:jaxb-api                   │ CDDL-1.1                                           │ Reciprocal     │ MEDIUM   │
│                                           ├────────────────────────────────────────────────────┼────────────────┼──────────┤
│                                           │ GPL-2.0-with-classpath-exception                   │ Restricted     │ HIGH     │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┼────────────────┼──────────┤
│ joda-time:joda-time                       │ Apache-2.0                                         │ Notice         │ LOW      │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.apache.commons:commons-lang3          │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.apache.lucene:lucene-analyzers-common │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.apache.lucene:lucene-core             │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.apache.lucene:lucene-queries          │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.apache.lucene:lucene-queryparser      │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.apache.lucene:lucene-sandbox          │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.ejml:ejml-cdense                      │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.ejml:ejml-core                        │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.ejml:ejml-ddense                      │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.ejml:ejml-dsparse                     │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.ejml:ejml-fdense                      │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.ejml:ejml-fsparse                     │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.ejml:ejml-simple                      │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ org.ejml:ejml-zdense                      │                                                    │                │          │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┤                │          │
│ org.slf4j:slf4j-api                       │ MIT                                                │                │          │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┤                │          │
│ xalan:serializer                          │ Apache-2.0                                         │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ xalan:xalan                               │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ xerces:xercesImpl                         │                                                    │                │          │
├───────────────────────────────────────────┤                                                    │                │          │
│ xml-apis:xml-apis                         │                                                    │                │          │
├───────────────────────────────────────────┼────────────────────────────────────────────────────┼────────────────┼──────────┤
│ xom:xom                                   │ The GNU Lesser General Public License, Version 2.1 │ Non Standard   │ UNKNOWN  │
└───────────────────────────────────────────┴────────────────────────────────────────────────────┴────────────────┴──────────┘

JUnit XML format (before)

psibre@go:~/trivy$ ./trivy sbom --quiet --scanners license --format template \
  --template @contrib/junit.tpl sbom.json 
2024/08/29 15:03:37 WARN Check ID is empty file_path=lib/docker/docker.rego
<?xml version="1.0" ?>
<testsuites name="trivy">
    <testsuite tests="0" failures="0" name="OS Packages" errors="0" skipped="0" time="">
    </testsuite>
    <testsuite tests="0" failures="0" name="OS Packages" errors="0" skipped="0" time="">
    </testsuite>
    <testsuite tests="0" failures="0" name="Java" errors="0" skipped="0" time="">
    </testsuite>
    <testsuite tests="0" failures="0" name="Java" errors="0" skipped="0" time="">
    </testsuite>
    <testsuite tests="0" failures="0" name="Loose File License(s)" errors="0" skipped="0" time="">
    </testsuite>
    <testsuite tests="0" failures="0" name="Loose File License(s)" errors="0" skipped="0" time="">
    </testsuite>
</testsuites>

JUnit XML format (after)

psibre@go:~/trivy$ ./trivy sbom --quiet --scanners license --format template \
  --template @fix-junit-template/contrib/junit.tpl sbom.json 
2024/08/29 15:04:34 WARN Check ID is empty file_path=lib/docker/docker.rego
<?xml version="1.0" ?>
<testsuites name="trivy">
    <testsuite tests="0" failures="0" name="OS Packages" errors="0" skipped="0" time="">
    </testsuite>
    <testsuite tests="0" failures="0" name="OS Packages" errors="0" skipped="0" time="">
    </testsuite>
    <testsuite tests="0" failures="0" name="Java" errors="0" skipped="0" time="">
    </testsuite>
    <testsuite tests="30" failures="30" name="Java" time="0">
        <testcase classname="com.apple:AppleJavaExtensions" name="[UNKNOWN] Apple License">
            <failure/>
        </testcase>
        <testcase classname="com.google.code.findbugs:jsr305" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="com.google.protobuf:protobuf-java" name="[LOW] BSD-3-Clause">
            <failure/>
        </testcase>
        <testcase classname="com.sun.xml.bind:jaxb-core" name="[MEDIUM] CDDL-1.1">
            <failure/>
        </testcase>
        <testcase classname="com.sun.xml.bind:jaxb-impl" name="[MEDIUM] CDDL-1.1">
            <failure/>
        </testcase>
        <testcase classname="de.jollyday:jollyday" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="edu.stanford.nlp:stanford-corenlp" name="[UNKNOWN] GNU General Public License Version 3">
            <failure/>
        </testcase>
        <testcase classname="javax.xml.bind:jaxb-api" name="[MEDIUM] CDDL-1.1">
            <failure/>
        </testcase>
        <testcase classname="javax.xml.bind:jaxb-api" name="[HIGH] GPL-2.0-with-classpath-exception">
            <failure/>
        </testcase>
        <testcase classname="joda-time:joda-time" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.apache.commons:commons-lang3" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.apache.lucene:lucene-analyzers-common" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.apache.lucene:lucene-core" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.apache.lucene:lucene-queries" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.apache.lucene:lucene-queryparser" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.apache.lucene:lucene-sandbox" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.ejml:ejml-cdense" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.ejml:ejml-core" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.ejml:ejml-ddense" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.ejml:ejml-dsparse" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.ejml:ejml-fdense" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.ejml:ejml-fsparse" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.ejml:ejml-simple" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.ejml:ejml-zdense" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="org.slf4j:slf4j-api" name="[LOW] MIT">
            <failure/>
        </testcase>
        <testcase classname="xalan:serializer" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="xalan:xalan" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="xerces:xercesImpl" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="xml-apis:xml-apis" name="[LOW] Apache-2.0">
            <failure/>
        </testcase>
        <testcase classname="xom:xom" name="[UNKNOWN] The GNU Lesser General Public License, Version 2.1">
            <failure/>
        </testcase>
    </testsuite>
    <testsuite tests="0" failures="0" name="Java" errors="0" skipped="0" time="">
    </testsuite>
    <testsuite tests="0" failures="0" name="Loose File License(s)" errors="0" skipped="0" time="">
    </testsuite>
    <testsuite tests="0" failures="0" name="Loose File License(s)" errors="0" skipped="0" time="">
    </testsuite>
</testsuites>

@psibre
Copy link
Contributor Author

psibre commented Aug 29, 2024

Perhaps it would be even more useful to add the <failure/> only when the severity is higher than LOW or MEDIUM, but that would essentially hard-code the policy threshold...

@knqyf263 knqyf263 requested a review from afdesk August 30, 2024 07:30
@knqyf263
Copy link
Collaborator

@afdesk Can you please take a look?

@afdesk
Copy link
Contributor

afdesk commented Aug 30, 2024

@psibre thanks a lot for your contribution! it's really nice.

Should License block be after Misconfiguration block?
wdyt?

contrib/junit.tpl Outdated Show resolved Hide resolved
@afdesk
Copy link
Contributor

afdesk commented Aug 30, 2024

Also about JUnit template.
It's a little confusing to me:
изображение
I mean a pattern [License severity] License name inside name field.

but this logic is for all blocks...

@psibre
Copy link
Contributor Author

psibre commented Aug 30, 2024

Also about JUnit template. It's a little confusing to me: изображение
I mean a pattern [License severity] License name inside name field.

but this logic is for all blocks...

I based this pattern on the one already present in the Vulnerabilities portion of the template. Specifically, in junit.tpl#L12, there is

<testcase classname="{{ .PkgName }}-{{ .InstalledVersion }}" name="[{{ .Vulnerability.Severity }}] {{ .VulnerabilityID }}" time="">

Since that name attribute is typically part of the summary (e.g., in a GitLab test report), I think it's consistent with expected behavior of Trivy-generated JUnit XML reports to maintain that pattern for the licenses.

@afdesk
Copy link
Contributor

afdesk commented Aug 30, 2024

I based this pattern on the one already present in the Vulnerabilities portion of the template.

i understand it. thanks!

@psibre psibre requested a review from afdesk August 31, 2024 17:16
contrib/junit.tpl Show resolved Hide resolved
@knqyf263 knqyf263 added this pull request to the merge queue Sep 3, 2024
Merged via the queue into aquasecurity:main with commit f80183c Sep 3, 2024
12 checks passed
@aqua-bot aqua-bot mentioned this pull request Sep 3, 2024
@psibre psibre deleted the fix-add-license-handling-to-junit-template branch September 4, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants