Skip to content

Commit

Permalink
fix version range and added cvss4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SUSTAPLE117 committed Sep 17, 2024
1 parent 79abea4 commit 09ff61d
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 41 deletions.
10 changes: 10 additions & 0 deletions opa/opa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ func TestSemverConstraintCheck(t *testing.T) {
version: "1.0.0",
expected: true,
},
{
constraint: "<=3.11.13",
version: "3.11.13",
expected: true,
},
{
constraint: "<=3.11.13",
version: "3.11.14",
expected: false,
},
{
constraint: ">=4.0.0,<4.4.1",
version: "4",
Expand Down
30 changes: 22 additions & 8 deletions opa/populate_build_platform_vuln_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ type CVEData struct {
Vendor string `json:"vendor"`
Product string `json:"product"`
Versions []struct {
LessThan string `json:"lessThan"`
Version string `json:"version"`
VersionType string `json:"versionType"`
LessThan string `json:"lessThan"`
LessThanOrEqual string `json:"lessThanOrEqual"`
Version string `json:"version"`
VersionType string `json:"versionType"`
}
} `json:"affected"`
Descriptions []struct {
Expand All @@ -65,6 +66,9 @@ type CVEData struct {
CvssV31 struct {
VectorString string `json:"vectorString"`
} `json:"cvssV3_1"`
CvssV40 struct {
VectorString string `json:"vectorString"`
} `json:"cvssV4_0"`
} `json:"metrics"`
} `json:"cna"`
} `json:"containers"`
Expand Down Expand Up @@ -99,17 +103,27 @@ func TransformCVEDataToAdvisories(cveData []CVEData) PlatformAdvisories {
}

for _, metric := range data.Containers.CNA.Metrics {
cveItem.Severity = append(cveItem.Severity, Severity{
Type: "CVSS_V3",
Score: metric.CvssV31.VectorString,
})
if metric.CvssV31.VectorString != "" {
cveItem.Severity = append(cveItem.Severity, Severity{
Type: "CVSS_V3",
Score: metric.CvssV31.VectorString,
})
} else if metric.CvssV40.VectorString != "" {
cveItem.Severity = append(cveItem.Severity, Severity{
Type: "CVSS_V4",
Score: metric.CvssV40.VectorString,
})
}
}

var versionRanges []string

for _, version := range affected.Versions {
if version.VersionType == "custom" || version.VersionType == "semver" {
if version.LessThan != "" && version.Version != "" {
if version.LessThanOrEqual != "" {
versionRange := fmt.Sprintf("<=%s", version.LessThanOrEqual)
versionRanges = append(versionRanges, versionRange)
} else if version.LessThan != "" && version.Version != "" {
versionRange := fmt.Sprintf(">=%s,<%s", version.Version, version.LessThan)
versionRanges = append(versionRanges, versionRange)
}
Expand Down
161 changes: 128 additions & 33 deletions opa/rego/external/build_platform.rego
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,13 @@ advisories = {
}],
"cwe_ids": ["CWE-269"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.9.16",
"<=3.10.13",
"<=3.11.11",
"<=3.12.5",
"<=3.13.0",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-5746": {
Expand All @@ -479,7 +485,12 @@ advisories = {
}],
"cwe_ids": ["CWE-918"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.9.15",
"<=3.10.12",
"<=3.11.10",
"<=3.12.4",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-5795": {
Expand All @@ -493,7 +504,13 @@ advisories = {
}],
"cwe_ids": ["CWE-400"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.9.16",
"<=3.10.13",
"<=3.11.11",
"<=3.12.5",
"<=3.13.0",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-5815": {
Expand All @@ -502,12 +519,18 @@ advisories = {
"aliases": [],
"summary": "A Cross-Site Request Forgery vulnerability in GitHub Enterprise Server allowed write operations on a victim-owned repository by exploiting incorrect request types. A mitigating factor is that the attacker would have to be a trusted GitHub Enterprise Server user, and the victim would have to visit a tag in the attacker's fork of their own repository. vulnerability affected all versions of GitHub Enterprise Server prior 3.14 and was fixed in version 3.13.1, 3.12.6, 3.11.12, 3.10.14, and 3.9.17.\n\n\n This vulnerability was reported via the GitHub Bug Bounty program.",
"severity": [{
"type": "CVSS_V3",
"score": "",
"type": "CVSS_V4",
"score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:A/VC:N/VI:H/VA:N/SC:N/SI:H/SA:N/S:N/AU:N/R:U/RE:L/U:Amber",
}],
"cwe_ids": ["CWE-352"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.9.16",
"<=3.10.13",
"<=3.11.11",
"<=3.12.5",
"<=3.13.0",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-5816": {
Expand All @@ -516,12 +539,18 @@ advisories = {
"aliases": [],
"summary": "An Incorrect Authorization vulnerability was identified in GitHub Enterprise Server that allowed a suspended GitHub App to retain access to the repository via a scoped user access token. This was only exploitable in public repositories while private repositories were not impacted. This vulnerability affected all versions of GitHub Enterprise Server prior to 3.14 and was fixed in versions 3.9.17, 3.10.14, 3.11.12, 3.12.6, 3.13.1. This vulnerability was reported via the GitHub Bug Bounty program.",
"severity": [{
"type": "CVSS_V3",
"score": "",
"type": "CVSS_V4",
"score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:A/VC:N/VI:H/VA:N/SC:N/SI:H/SA:N",
}],
"cwe_ids": ["CWE-863"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.10.13",
"<=3.11.11",
"<=3.12.5",
"<=3.13.0",
"<=3.9.16",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-5817": {
Expand All @@ -530,12 +559,18 @@ advisories = {
"aliases": [],
"summary": "An Incorrect Authorization vulnerability was identified in GitHub Enterprise Server that allowed read access to issue content via GitHub Projects. This was only exploitable in internal repositories and required the attacker to have access to the corresponding project board. This vulnerability affected all versions of GitHub Enterprise Server prior to 3.14 and was fixed in versions 3.13.1, 3.12.6, 3.11.12, 3.10.14, and 3.9.17. This vulnerability was reported via the GitHub Bug Bounty program.",
"severity": [{
"type": "CVSS_V3",
"score": "",
"type": "CVSS_V4",
"score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:P/VC:H/VI:N/VA:N/SC:L/SI:N/SA:N/U:Amber",
}],
"cwe_ids": ["CWE-863"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.10.13",
"<=3.11.11",
"<=3.12.5",
"<=3.13.0",
"<=3.9.16",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-6336": {
Expand All @@ -544,12 +579,18 @@ advisories = {
"aliases": [],
"summary": "A Security Misconfiguration vulnerability in GitHub Enterprise Server allowed sensitive information disclosure to unauthorized users in GitHub Enterprise Server by exploiting organization ruleset feature. This attack required an organization member to explicitly change the visibility of a dependent repository from private to public. This vulnerability affected all versions of GitHub Enterprise Server prior to 3.14 and was fixed in versions 3.13.1, 3.12.6, 3.11.12, 3.10.14, and 3.9.17. This vulnerability was reported via the GitHub Bug Bounty program.",
"severity": [{
"type": "CVSS_V3",
"score": "",
"type": "CVSS_V4",
"score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:A/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N/S:N/AU:N/R:U/U:Amber",
}],
"cwe_ids": ["CWE-200"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.10.13",
"<=3.11.11",
"<=3.12.5",
"<=3.13.0",
"<=3.9.16",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-6337": {
Expand All @@ -558,12 +599,17 @@ advisories = {
"aliases": [],
"summary": "An Incorrect Authorization vulnerability was identified in GitHub Enterprise Server that allowed a GitHub App with only content: read and pull_request_write: write permissions to read issue content inside a private repository. This was only exploitable via user access token and installation access token was not impacted. This vulnerability affected all versions of GitHub Enterprise Server prior to 3.14 and was fixed in versions 3.13.3, 3.12.8, 3.11.14 and 3.10.16. This vulnerability was reported via the GitHub Bug Bounty program.",
"severity": [{
"type": "CVSS_V3",
"score": "",
"type": "CVSS_V4",
"score": "CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:P/VC:H/VI:N/VA:N/SC:L/SI:N/SA:N/S:N",
}],
"cwe_ids": ["CWE-863"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.10.15",
"<=3.11.14",
"<=3.12.7",
"<=3.13.2",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-6395": {
Expand All @@ -572,12 +618,18 @@ advisories = {
"aliases": [],
"summary": "An exposure of sensitive information vulnerability in GitHub Enterprise Server would allow an attacker to enumerate the names of private repositories that utilize deploy keys. This vulnerability did not allow unauthorized access to any repository content besides the name. This vulnerability affected all versions of GitHub Enterprise Server prior to 3.14 and was fixed in versions 3.13.1, 3.12.6, 3.11.12, 3.10.14, and 3.9.17. This vulnerability was reported via the GitHub Bug Bounty program.",
"severity": [{
"type": "CVSS_V3",
"score": "",
"type": "CVSS_V4",
"score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:L/SI:N/SA:N/S:N/AU:Y/V:C/RE:L/U:Amber",
}],
"cwe_ids": ["CWE-200"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.10.13",
"<=3.11.11",
"<=3.12.5",
"<=3.13.0",
"<=3.9.16",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-6800": {
Expand All @@ -586,12 +638,17 @@ advisories = {
"aliases": [],
"summary": "An XML signature wrapping vulnerability was present in GitHub Enterprise Server (GHES) when using SAML authentication with specific identity providers utilizing publicly exposed signed federation metadata XML. This vulnerability allowed an attacker with direct network access to GitHub Enterprise Server to forge a SAML response to provision and/or gain access to a user with site administrator privileges. Exploitation of this vulnerability would allow unauthorized access to the instance without requiring prior authentication. This vulnerability affected all versions of GitHub Enterprise Server prior to 3.14 and was fixed in versions 3.13.3, 3.12.8, 3.11.14, and 3.10.16. This vulnerability was reported via the GitHub Bug Bounty program.",
"severity": [{
"type": "CVSS_V3",
"score": "",
"type": "CVSS_V4",
"score": "CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:L/SC:H/SI:H/SA:L/R:U/V:C/RE:H/U:Red",
}],
"cwe_ids": ["CWE-347"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.13.2",
"<=3.12.7",
"<=3.11.13",
"<=3.10.15",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-7711": {
Expand All @@ -600,12 +657,16 @@ advisories = {
"aliases": [],
"summary": "An Incorrect Authorization vulnerability was identified in GitHub Enterprise Server, allowing an attacker to update the title, assignees, and labels of any issue inside a public repository. This was only exploitable inside a public repository. This vulnerability affected GitHub Enterprise Server versions before 3.14 and was fixed in versions 3.13.3, 3.12.8, and 3.11.14. Versions 3.10 of GitHub Enterprise Server are not affected. This vulnerability was reported via the GitHub Bug Bounty program.",
"severity": [{
"type": "CVSS_V3",
"score": "",
"type": "CVSS_V4",
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:N/SC:L/SI:L/SA:N/S:N/AU:Y/R:U/V:D/RE:L/U:Amber",
}],
"cwe_ids": ["CWE-863"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [],
"vulnerable_version_ranges": [
"<=3.11.13",
"<=3.12.7",
"<=3.13.2",
],
"vulnerable_commit_shas": [],
},
},
Expand Down Expand Up @@ -979,11 +1040,7 @@ advisories = {
}],
"cwe_ids": [""],
"vulnerable_versions": [],
"vulnerable_version_ranges": [
">=10.8, <13.0.12",
">=13.1, <13.1.6",
">=13.2, <13.2.3",
],
"vulnerable_version_ranges": [">=10.8"],
"vulnerable_commit_shas": [],
},
"CVE-2020-13284": {
Expand Down Expand Up @@ -9633,6 +9690,7 @@ advisories = {
"cwe_ids": ["CWE-284"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [
"<=16.4.3",
">=16.5,<16.5.4",
">=16.6,<16.6.2",
],
Expand Down Expand Up @@ -10251,6 +10309,7 @@ advisories = {
"cwe_ids": ["CWE-284"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [
"<=16.2.7",
">=16.3,<16.3.5",
">=16.4,<16.4.1",
],
Expand Down Expand Up @@ -11525,6 +11584,24 @@ advisories = {
],
"vulnerable_commit_shas": [],
},
"CVE-2024-4283": {
"osv_id": "CVE-2024-4283",
"published": "2024-09-16T21:34:08.579Z",
"aliases": [],
"summary": "An issue has been discovered in GitLab EE affecting all versions starting from 11.1 before 17.1.7, 17.2 before 17.2.5, and 17.3 before 17.3.2. Under certain conditions an open redirect vulnerability could allow for an account takeover by breaking the OAuth flow.",
"severity": [{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:N",
}],
"cwe_ids": ["CWE-601"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [
">=11.1,<17.1.7",
">=17.2,<17.2.5",
">=17.3,<17.3.2",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-4472": {
"osv_id": "CVE-2024-4472",
"published": "2024-09-12T18:26:38.059Z",
Expand Down Expand Up @@ -12008,6 +12085,24 @@ advisories = {
],
"vulnerable_commit_shas": [],
},
"CVE-2024-6685": {
"osv_id": "CVE-2024-6685",
"published": "2024-09-16T21:33:58.732Z",
"aliases": [],
"summary": "An issue was discovered in GitLab CE/EE affecting all versions starting from 16.7 prior to 17.1.7, 17.2 prior to 17.2.5, and 17.3 prior to 17.3.2, where group runners information was disclosed to unauthorised group members.",
"severity": [{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:N",
}],
"cwe_ids": ["CWE-639"],
"vulnerable_versions": [],
"vulnerable_version_ranges": [
">=16.7,<17.1.7",
">=17.3,<17.2.5",
">=17.3,<17.3.2",
],
"vulnerable_commit_shas": [],
},
"CVE-2024-7047": {
"osv_id": "CVE-2024-7047",
"published": "2024-07-25T00:30:40.657Z",
Expand Down Expand Up @@ -12156,7 +12251,7 @@ advisories = {
"osv_id": "CVE-2024-8124",
"published": "2024-09-12T16:56:33.253Z",
"aliases": [],
"summary": "An issue was discovered in GitLab CE/EE affecting all versions starting from 16.4 prior to 17.1.7, starting from 17.2 prior to 17.2.5, starting from 17.3 prior to 17.3.2 which could cause Denial of Service via sending a large `glm_source` parameter.",
"summary": "An issue was discovered in GitLab CE/EE affecting all versions starting from 16.4 prior to 17.1.7, starting from 17.2 prior to 17.2.5, starting from 17.3 prior to 17.3.2 which could cause Denial of Service via sending a specific POST request.",
"severity": [{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
Expand Down

0 comments on commit 09ff61d

Please sign in to comment.