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

[feature] Adds a parser for CycloneDX Vex data #1181

Merged
merged 12 commits into from
Aug 31, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"version": 1,
"vulnerabilities": [
{
"id": "CVE-2020-25649",
"source": {
"name": "NVD",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-25649"
},
"references": [
{
"id": "SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302",
"source": {
"name": "SNYK",
"url": "https://security.snyk.io/vuln/SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302"
}
}
],
"ratings": [
{
"source": {
"name": "NVD",
"url": "https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N&version=3.1"
},
"score": 7.5,
"severity": "high",
"method": "CVSSv31",
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
},
{
"source": {
"name": "SNYK",
"url": "https://security.snyk.io/vuln/SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302"
},
"score": 8.2,
"severity": "high",
"method": "CVSSv31",
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
},
{
"source": {
"name": "Acme Inc",
"url": "https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N/CR:X/IR:X/AR:X/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:N/MI:N/MA:N&version=3.1"
},
"score": 0.0,
"severity": "none",
"method": "CVSSv31",
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N/CR:X/IR:X/AR:X/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:N/MI:N/MA:N"
}
],
"cwes": [
611
],
"description": "com.fasterxml.jackson.core:jackson-databind is a library which contains the general-purpose data-binding functionality and tree-model for Jackson Data Processor.\n\nAffected versions of this package are vulnerable to XML External Entity (XXE) Injection. A flaw was found in FasterXML Jackson Databind, where it does not have entity expansion secured properly in the DOMDeserializer class. The highest threat from this vulnerability is data integrity.",
"detail": "XXE Injection is a type of attack against an application that parses XML input. XML is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. By default, many XML processors allow specification of an external entity, a URI that is dereferenced and evaluated during XML processing. When an XML document is being parsed, the parser can make a request and include the content at the specified URI inside of the XML document.\n\nAttacks can include disclosing local files, which may contain sensitive data such as passwords or private user data, using file: schemes or relative paths in the system identifier.",
"recommendation": "Upgrade com.fasterxml.jackson.core:jackson-databind to version 2.6.7.4, 2.9.10.7, 2.10.5.1 or higher.",
"advisories": [
{
"title": "GitHub Commit",
"url": "https://github.com/FasterXML/jackson-databind/commit/612f971b78c60202e9cd75a299050c8f2d724a59"
},
{
"title": "GitHub Issue",
"url": "https://github.com/FasterXML/jackson-databind/issues/2589"
},
{
"title": "RedHat Bugzilla Bug",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=1887664"
}
],
"created": "2020-12-03T00:00:00.000Z",
"published": "2020-12-03T00:00:00.000Z",
"updated": "2021-10-26T00:00:00.000Z",
"credits": {
"individuals": [
{
"name": "Bartosz Baranowski"
}
]
},
"analysis": {
"state": "not_affected",
"justification": "code_not_reachable",
"response": ["will_not_fix", "update"],
"detail": "Automated dataflow analysis and manual code review indicates that the vulnerable code is not reachable, either directly or indirectly."
},
"affects": [
{
"ref": "urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/1#pkg:maven/com.fasterxml.jackson.core/[email protected]?type=jar"
}
]
}
]
}
stevemenezes marked this conversation as resolved.
Show resolved Hide resolved
54 changes: 54 additions & 0 deletions internal/testing/testdata/exampledata/cyclonedx-vex-affected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"version": 1,
"metadata" : {
"timestamp" : "2022-03-03T00:00:00Z",
"component" : {
"name" : "ABC",
"type" : "application",
"bom-ref" : "product-ABC"
}
},
"vulnerabilities": [
{
"id": "CVE-2021-44228",
"source": {
"name": "NVD",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-44228"
},
"ratings": [
{
"source": {
"name": "NVD",
"url": "https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H&version=3.1"
},
"score": 10.0,
"severity": "critical",
"method": "CVSSv31",
"vector": "AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
}
],
"analysis": {
"state": "exploitable",
"response": ["will_not_fix", "update"],
"detail": "Versions of Product ABC are affected by the vulnerability. Customers are advised to upgrade to the latest release."
},
"affects": [
{
"ref": "urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/1#pkg:maven/com.fasterxml.jackson.core/jackson-databind@",
"versions": [
{
"version": "2.4",
"status": "affected"
},
{
"version": "2.6",
"status": "affected"
}
]
}
]
}
]
}
stevemenezes marked this conversation as resolved.
Show resolved Hide resolved
107 changes: 107 additions & 0 deletions internal/testing/testdata/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ var (
//go:embed exampledata/cyclonedx-no-top-level.json
CycloneDXExampleNoTopLevelComp []byte

//go:embed exampledata/cyclonedx-unaffected-vex.json
CycloneDXVEXUnAffected []byte

//go:embed exampledata/cyclonedx-vex-affected.json
CycloneDXVEXAffected []byte

//go:embed exampledata/crev-review.json
ITE6CREVExample []byte

Expand Down Expand Up @@ -128,6 +134,99 @@ var (
//go:embed exampledata/ingest_predicates.json
IngestPredicatesExample []byte

// CycloneDX VEX testdata unaffected
pkg, _ = asmhelpers.PurlToPkg("pkg:maven/com.fasterxml.jackson.core/[email protected]?type=jar")
vulnSpec = &generated.VulnerabilityInputSpec{
Type: "cve",
VulnerabilityID: "cve-2020-25649",
}
CycloneDXUnAffectedVexIngest = []assembler.VexIngest{
{
Pkg: pkg,
Vulnerability: vulnSpec,
VexData: &generated.VexStatementInputSpec{
Status: "NOT_AFFECTED",
pxp928 marked this conversation as resolved.
Show resolved Hide resolved
VexJustification: "VULNERABLE_CODE_NOT_IN_EXECUTE_PATH",
pxp928 marked this conversation as resolved.
Show resolved Hide resolved
Statement: "Automated dataflow analysis and manual code review indicates that the vulnerable code is not reachable, either directly or indirectly.",
StatusNotes: "not_affected:code_not_reachable",
KnownSince: parseUTCTime("2020-12-03T00:00:00.000Z"),
},
},
}
CycloneDXUnAffectedVulnMetadata = []assembler.VulnMetadataIngest{
{
Vulnerability: vulnSpec,
VulnMetadata: &generated.VulnerabilityMetadataInputSpec{
ScoreType: "CVSSv31",
pxp928 marked this conversation as resolved.
Show resolved Hide resolved
ScoreValue: 7.5,
Timestamp: parseUTCTime("2020-12-03T00:00:00.000Z"),
},
},
{
Vulnerability: vulnSpec,
VulnMetadata: &generated.VulnerabilityMetadataInputSpec{
ScoreType: "CVSSv31",
ScoreValue: 8.2,
Timestamp: parseUTCTime("2020-12-03T00:00:00.000Z"),
},
},
{
Vulnerability: vulnSpec,
VulnMetadata: &generated.VulnerabilityMetadataInputSpec{
ScoreType: "CVSSv31",
ScoreValue: 0.0,
Timestamp: parseUTCTime("2020-12-03T00:00:00.000Z"),
},
},
}

// CycloneDX VEX testdata in triage
pkg1, _ = asmhelpers.PurlToPkg("pkg:maven/com.fasterxml.jackson.core/[email protected]")
pkg2, _ = asmhelpers.PurlToPkg("pkg:maven/com.fasterxml.jackson.core/[email protected]")

vulnSpecAffected = &generated.VulnerabilityInputSpec{
Type: "cve",
VulnerabilityID: "cve-2021-44228",
}
vexDataAffected = &generated.VexStatementInputSpec{
Status: "AFFECTED",
Statement: "Versions of Product ABC are affected by the vulnerability. Customers are advised to upgrade to the latest release.",
StatusNotes: "exploitable:",
}
CycloneDXAffectedVexIngest = []assembler.VexIngest{
{
Pkg: pkg1,
Vulnerability: vulnSpecAffected,
VexData: vexDataAffected,
},
{
Pkg: pkg2,
Vulnerability: vulnSpecAffected,
VexData: vexDataAffected,
},
}
CycloneDXAffectedVulnMetadata = []assembler.VulnMetadataIngest{
{
Vulnerability: vulnSpecAffected,
VulnMetadata: &generated.VulnerabilityMetadataInputSpec{
ScoreType: "CVSSv31",
ScoreValue: 10,
},
},
}
CycloneDXAffectedCertifyVuln = []assembler.CertifyVulnIngest{
{
Pkg: pkg1,
Vulnerability: vulnSpecAffected,
VulnData: &generated.ScanMetadataInput{},
},
{
Pkg: pkg2,
Vulnerability: vulnSpecAffected,
VulnData: &generated.ScanMetadataInput{},
},
}

// DSSE/SLSA Testdata

// Taken from: https://slsa.dev/provenance/v0.2#example
Expand Down Expand Up @@ -2500,3 +2599,11 @@ func toTime(s string) time.Time {
}
return timeScanned
}

func parseUTCTime(s string) time.Time {
timeScanned, err := time.Parse("2006-01-02T15:04:05Z", s)
if err != nil {
panic(err)
}
return timeScanned
}
12 changes: 8 additions & 4 deletions pkg/assembler/clients/generated/operations.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/assembler/graphql/generated/root_.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions pkg/assembler/graphql/model/nodes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/assembler/graphql/schema/vulnMetadata.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ enum VulnerabilityScoreType {
CVSSv3
EPSSv1
EPSSv2
CVSSv31
CVSSv4
OWASP
SSVC
}

"The Comparator is used by the vulnerability score filter on ranges"
Expand Down
Loading
Loading