Skip to content

Commit

Permalink
Add a flag for removing the cvss data from the output. (#183)
Browse files Browse the repository at this point in the history
When dumping GHSA for Malware these values are all "0" and don't make
sense.

---------

Signed-off-by: Caleb Brown <calebbrown@google.com>
  • Loading branch information
calebbrown authored Jul 25, 2023
1 parent 1ee624f commit c2daa75
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 52 deletions.
6 changes: 3 additions & 3 deletions tools/ghsa/convert_ghsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def convert_file(input_path: str, output_path: str):

entry = convert(ghsa)
vuln = osv.parse_vulnerability_from_dict(entry)

osv.analyze(vuln,
analyze_git=False,
detect_cherrypicks=False,
Expand Down Expand Up @@ -176,7 +177,6 @@ def get_affected(ghsa: Dict[str, Any]) -> List[Dict[str, Any]]:
package_to_vulns.setdefault((mapped_ecosystem, package['name']),
[]).append(vuln)

cvss = ghsa.get('cvss', {})
cwes = ghsa.get('cwes', {}).get('nodes', [])

# Convert the grouped vulnerabilities in OSV range structures.
Expand All @@ -195,9 +195,8 @@ def get_affected(ghsa: Dict[str, Any]) -> List[Dict[str, Any]]:
'database_specific': {
# Attribution.
'ghsa': ghsa['permalink'],
'cvss': cvss,
'cwes': cwes,
}
},
}
affected.append(current)

Expand Down Expand Up @@ -284,6 +283,7 @@ def main():
required=True)

args = parser.parse_args()

for input_path in args.input_files:
try:
convert_file(
Expand Down
1 change: 0 additions & 1 deletion tools/ghsa/convert_ghsa_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

TEST_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testdata')


class ConverterTest(unittest.TestCase):
"""Converter unit tests."""

Expand Down
4 changes: 0 additions & 4 deletions tools/ghsa/testdata/equals_no_patch.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-4g4c-8gqh-m4vm",
"cvss": {
"score": 9.8,
"vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
},
"cwes": [
{
"cweId": "CWE-829",
Expand Down
4 changes: 0 additions & 4 deletions tools/ghsa/testdata/equals_with_patch.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-fhjf-83wg-r2j9",
"cvss": {
"score": 9.8,
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
},
"cwes": [
{
"cweId": "CWE-88",
Expand Down
8 changes: 0 additions & 8 deletions tools/ghsa/testdata/full_ranges.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-mr95-9rr4-668f",
"cvss": {
"score": 9.1,
"vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
},
"cwes": [
{
"cweId": "CWE-338",
Expand Down Expand Up @@ -74,10 +70,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-mr95-9rr4-668f",
"cvss": {
"score": 9.1,
"vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
},
"cwes": [
{
"cweId": "CWE-338",
Expand Down
4 changes: 0 additions & 4 deletions tools/ghsa/testdata/greater_than_equals_no_patch.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-pxmp-fwjc-4x7q",
"cvss": {
"score": 0,
"vectorString": null
},
"cwes": []
}
}
Expand Down
4 changes: 0 additions & 4 deletions tools/ghsa/testdata/less_than_equals_no_patch.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-jvf4-g24p-2qgw",
"cvss": {
"score": 8.3,
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L"
},
"cwes": [
{
"cweId": "CWE-94",
Expand Down
4 changes: 0 additions & 4 deletions tools/ghsa/testdata/less_than_equals_with_patch.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-f89g-whpf-6q9m",
"cvss": {
"score": 0,
"vectorString": null
},
"cwes": [
{
"cweId": "CWE-79",
Expand Down
4 changes: 0 additions & 4 deletions tools/ghsa/testdata/maven_greater_than.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-76mp-659p-rw65",
"cvss": {
"score": 8.8,
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
},
"cwes": [
{
"cweId": "CWE-285",
Expand Down
4 changes: 0 additions & 4 deletions tools/ghsa/testdata/multiple_ranges_in_package.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-9qj7-jvg4-qr2x",
"cvss": {
"score": 0,
"vectorString": null
},
"cwes": []
}
}
Expand Down
4 changes: 0 additions & 4 deletions tools/ghsa/testdata/npm_greater_than.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-mhpp-875w-9cpv",
"cvss": {
"score": 7.5,
"vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
},
"cwes": [
{
"cweId": "CWE-400",
Expand Down
4 changes: 0 additions & 4 deletions tools/ghsa/testdata/pypi_normalize.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-p44j-xrqg-4xrr",
"cvss": {
"score": 0,
"vectorString": null
},
"cwes": [
{
"cweId": "CWE-601",
Expand Down
4 changes: 0 additions & 4 deletions tools/ghsa/testdata/withdrawn.osv.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
"versions": [],
"database_specific": {
"ghsa": "https://github.com/advisories/GHSA-35c4-f3rq-f9g3",
"cvss": {
"score": 0,
"vectorString": null
},
"cwes": []
}
}
Expand Down

0 comments on commit c2daa75

Please sign in to comment.