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(sca): fix CycloneDX output for Docker images #3586

Merged
merged 1 commit into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion checkov/common/output/cyclonedx.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def create_image_component(self, resource: Record, bom: Bom) -> None:
def create_vulnerability(self, check_type: str, resource: Record, component: Component) -> Vulnerability:
"""Creates a vulnerability"""

if check_type == CheckType.SCA_PACKAGE:
if check_type in SCA_CHECKTYPES:
vulnerability = self.create_cve_vulnerability(resource=resource, component=component)
else:
vulnerability = self.create_iac_vulnerability(resource=resource, component=component)
Expand Down
48 changes: 32 additions & 16 deletions tests/sca_image/outputs/results_cyclonedx.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.4" version="1" serialNumber="urn:uuid:e6e11b45-ab99-4b14-b01f-61835165706d">
<bom serialNumber="urn:uuid:d4912465-39d5-4f9d-853b-ee60e3463a4d" version="1" xmlns="http://cyclonedx.org/schema/bom/1.4">
<metadata>
<timestamp>2022-09-03T19:50:22.454965+00:00</timestamp>
<timestamp>2022-09-29T11:09:18.873373+00:00</timestamp>
<tools>
<tool>
<vendor>CycloneDX</vendor>
Expand Down Expand Up @@ -37,7 +37,7 @@
<tool>
<vendor>bridgecrew</vendor>
<name>checkov</name>
<version>UNKNOWN</version>
<version>2.1.213</version>
<externalReferences>
<reference type="build-system">
<url>https://github.com/bridgecrewio/checkov/actions</url>
Expand Down Expand Up @@ -68,11 +68,11 @@
</tools>
</metadata>
<components>
<component type="container" bom-ref="pkg:oci/bridgecrewio/example/path/to/Dockerfile@sha256:123456">
<component bom-ref="pkg:oci/bridgecrewio/example/path/to/Dockerfile@sha256:123456" type="container">
<name>bridgecrewio/example//sha256:123456</name>
<purl>pkg:oci/bridgecrewio/example/path/to/Dockerfile@sha256:123456</purl>
</component>
<component type="library" bom-ref="pkg:generic/bridgecrewio/example/path/to/Dockerfile/[email protected]">
<component bom-ref="pkg:generic/bridgecrewio/example/path/to/Dockerfile/[email protected]" type="library">
<name>bzip2</name>
<version>1.0.8-5build1</version>
<licenses>
Expand All @@ -82,7 +82,7 @@
</licenses>
<purl>pkg:generic/bridgecrewio/example/path/to/Dockerfile/[email protected]</purl>
</component>
<component type="library" bom-ref="pkg:generic/bridgecrewio/example/path/to/Dockerfile/[email protected]">
<component bom-ref="pkg:generic/bridgecrewio/example/path/to/Dockerfile/[email protected]" type="library">
<name>libidn2</name>
<version>2.3.2-2build1</version>
<licenses>
Expand All @@ -92,7 +92,7 @@
</licenses>
<purl>pkg:generic/bridgecrewio/example/path/to/Dockerfile/[email protected]</purl>
</component>
<component type="library" bom-ref="pkg:deb/bridgecrewio/example/path/to/Dockerfile/ubuntu/[email protected]?distro=jammy">
<component bom-ref="pkg:deb/bridgecrewio/example/path/to/Dockerfile/ubuntu/[email protected]?distro=jammy" type="library">
<name>pcre2</name>
<version>10.39-3build1</version>
<licenses>
Expand All @@ -102,7 +102,7 @@
</licenses>
<purl>pkg:deb/bridgecrewio/example/path/to/Dockerfile/ubuntu/[email protected]?distro=jammy</purl>
</component>
<component type="library" bom-ref="pkg:deb/bridgecrewio/example/path/to/Dockerfile/ubuntu/[email protected]?distro=jammy">
<component bom-ref="pkg:deb/bridgecrewio/example/path/to/Dockerfile/ubuntu/[email protected]?distro=jammy" type="library">
<name>perl</name>
<version>5.34.0-3ubuntu1</version>
<licenses>
Expand All @@ -121,34 +121,50 @@
<dependency ref="pkg:deb/bridgecrewio/example/path/to/Dockerfile/ubuntu/[email protected]?distro=jammy"/>
</dependencies>
<vulnerabilities>
<vulnerability bom-ref="6bd56c92-c511-4ad0-baf1-27fac9e8a729">
<id>CKV_CVE_2022_1587</id>
<vulnerability bom-ref="76003c55-f10b-42a3-95bf-c6eae15d8006">
<id>CVE-2022-1587</id>
<source>
<name>checkov</name>
<url>https://people.canonical.com/~ubuntu-security/cve/2022/CVE-2022-1587</url>
</source>
<ratings>
<rating>
<source>
<url>https://people.canonical.com/~ubuntu-security/cve/2022/CVE-2022-1587</url>
</source>
<score>9.1</score>
<severity>low</severity>
<method>CVSSv3</method>
<vector>AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H</vector>
</rating>
</ratings>
<description>Resource: path/to/Dockerfile (sha256:123456).pcre2. SCA package scan</description>
<description>An out-of-bounds read vulnerability was discovered in the PCRE2 library in the get_recurse_data_length() function of the pcre2_jit_compile.c file. This issue affects recursions in JIT-compiled regular expressions caused by duplicate data transfers.</description>
<recommendation>needed</recommendation>
<published>2022-05-17T00:15:00+03:00</published>
<affects>
<target>
<ref>pkg:deb/bridgecrewio/example/path/to/Dockerfile/ubuntu/[email protected]?distro=jammy</ref>
</target>
</affects>
</vulnerability>
<vulnerability bom-ref="1c581339-32a1-4799-8570-4e89744a1df6">
<id>CKV_CVE_2020_16156</id>
<vulnerability bom-ref="7e2e6e05-54b2-4a97-b246-95d69c792bc3">
<id>CVE-2020-16156</id>
<source>
<name>checkov</name>
<url>https://people.canonical.com/~ubuntu-security/cve/2020/CVE-2020-16156</url>
</source>
<ratings>
<rating>
<source>
<url>https://people.canonical.com/~ubuntu-security/cve/2020/CVE-2020-16156</url>
</source>
<score>7.8</score>
<severity>medium</severity>
<method>CVSSv3</method>
<vector>AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H</vector>
</rating>
</ratings>
<description>Resource: path/to/Dockerfile (sha256:123456).perl. SCA package scan</description>
<description>CPAN 2.28 allows Signature Verification Bypass.</description>
<recommendation>needed</recommendation>
<published>2021-12-13T20:15:00+02:00</published>
<affects>
<target>
<ref>pkg:deb/bridgecrewio/example/path/to/Dockerfile/ubuntu/[email protected]?distro=jammy</ref>
Expand Down