Skip to content

Commit 4058791

Browse files
authored
Merge branch 'intel:main' into main2
2 parents 85bcfbf + 0c1d8ce commit 4058791

File tree

5 files changed

+168
-44
lines changed

5 files changed

+168
-44
lines changed

fuzz/fuzz_cargo_lock.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright (C) 2023 Intel Corporation
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
import sys
5+
import tempfile
6+
from pathlib import Path
7+
8+
import atheris
9+
import atheris_libprotobuf_mutator
10+
from google.protobuf.json_format import MessageToDict
11+
12+
import fuzz.generated.cargo_lock_pb2 as cargo_lock_pb2
13+
from cve_bin_tool.cvedb import CVEDB
14+
from cve_bin_tool.log import LOGGER
15+
16+
with atheris.instrument_imports():
17+
from cve_bin_tool.parsers.rust import RustParser
18+
19+
cve_db = CVEDB()
20+
logger = LOGGER.getChild("Fuzz")
21+
22+
23+
def CargoLockBuilder(data):
24+
json_data = MessageToDict(
25+
data, preserving_proto_field_name=True, including_default_value_fields=True
26+
)
27+
28+
with open(file_path, "w") as f:
29+
for package_data in json_data.get("packages", []):
30+
package_name = package_data.get("name", "")
31+
package_version = package_data.get("version", "")
32+
f.write("[[package]]\n")
33+
f.write(f'name = "{package_name}"\n')
34+
f.write(f'version = "{package_version}"\n')
35+
package_source = package_data.get("source", "")
36+
if package_source != "":
37+
f.write(f'source = "{package_source}"\n')
38+
package_checksum = package_data.get("checksum", "")
39+
if package_checksum != "":
40+
f.write(f'checksum = "{package_checksum}"\n')
41+
42+
dependencies = package_data.get("dependency", [])
43+
f.write("dependencies = [\n")
44+
for dependency in dependencies:
45+
name = dependency.get("name", "")
46+
version = dependency.get("version", "")
47+
url = dependency.get("url", "")
48+
f.write(f' "{name}')
49+
if version != "":
50+
f.write(f" {version}")
51+
if url != "":
52+
f.write(f" {url}")
53+
f.write('",\n')
54+
f.write("]\n")
55+
f.write("\n")
56+
57+
58+
def TestParseData(data):
59+
try:
60+
CargoLockBuilder(data)
61+
62+
rust_parser = RustParser(cve_db, logger)
63+
rust_parser.run_checker(file_path)
64+
65+
except SystemExit:
66+
return
67+
68+
69+
file_path = str(Path(tempfile.mkdtemp(prefix="cve-bin-tool-")) / "Cargo.lock")
70+
71+
atheris_libprotobuf_mutator.Setup(
72+
sys.argv, TestParseData, proto=cargo_lock_pb2.CargoLock
73+
)
74+
atheris.Fuzz()

fuzz/generated/cargo_lock_pb2.py

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fuzz/proto_files/cargo_lock.proto

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (C) 2023 Intel Corporation
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
syntax = "proto3";
5+
6+
message CargoLock {
7+
message Package {
8+
string name = 1;
9+
string version = 2;
10+
optional string source = 3;
11+
optional string checksum = 4;
12+
repeated Dependencies dependency = 5;
13+
}
14+
message Dependencies {
15+
string name = 1;
16+
optional string version = 2;
17+
optional string url = 3;
18+
}
19+
repeated Package packages = 1;
20+
}

sbom/cve-bin-tool-py3.8.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
33
"bomFormat": "CycloneDX",
44
"specVersion": "1.5",
5-
"serialNumber": "urn:uuid:59585fe9-a8d6-4aeb-9105-511d0b303e62",
5+
"serialNumber": "urn:uuid:bd4dc772-3281-4b09-82cb-4c763a0777b2",
66
"version": 1,
77
"metadata": {
8-
"timestamp": "2023-10-23T00:27:16Z",
8+
"timestamp": "2023-10-30T00:27:18Z",
99
"tools": {
1010
"components": [
1111
{
@@ -506,7 +506,7 @@
506506
"type": "library",
507507
"bom-ref": "16-gsutil",
508508
"name": "gsutil",
509-
"version": "5.26",
509+
"version": "5.27",
510510
"supplier": {
511511
"name": "Google Inc .",
512512
"contact": [
@@ -515,7 +515,7 @@
515515
}
516516
]
517517
},
518-
"cpe": "cpe:2.3:a:google_inc.:gsutil:5.26:*:*:*:*:*:*:*",
518+
"cpe": "cpe:2.3:a:google_inc.:gsutil:5.27:*:*:*:*:*:*:*",
519519
"description": "A command line tool for interacting with cloud storage services.",
520520
"licenses": [
521521
{
@@ -527,12 +527,12 @@
527527
],
528528
"externalReferences": [
529529
{
530-
"url": "https://pypi.org/project/gsutil/5.26",
530+
"url": "https://pypi.org/project/gsutil/5.27",
531531
"type": "distribution",
532532
"comment": "Download location for component"
533533
}
534534
],
535-
"purl": "pkg:pypi/gsutil@5.26",
535+
"purl": "pkg:pypi/gsutil@5.27",
536536
"properties": [
537537
{
538538
"name": "License Comments",
@@ -1021,7 +1021,7 @@
10211021
"type": "library",
10221022
"bom-ref": "31-pyopenssl",
10231023
"name": "pyopenssl",
1024-
"version": "23.2.0",
1024+
"version": "23.3.0",
10251025
"supplier": {
10261026
"name": "The pyOpenSSL developers",
10271027
"contact": [
@@ -1030,7 +1030,7 @@
10301030
}
10311031
]
10321032
},
1033-
"cpe": "cpe:2.3:a:the_pyopenssl_developers:pyopenssl:23.2.0:*:*:*:*:*:*:*",
1033+
"cpe": "cpe:2.3:a:the_pyopenssl_developers:pyopenssl:23.3.0:*:*:*:*:*:*:*",
10341034
"description": "Python wrapper module around the OpenSSL library",
10351035
"licenses": [
10361036
{
@@ -1042,12 +1042,12 @@
10421042
],
10431043
"externalReferences": [
10441044
{
1045-
"url": "https://pypi.org/project/pyOpenSSL/23.2.0",
1045+
"url": "https://pypi.org/project/pyOpenSSL/23.3.0",
10461046
"type": "distribution",
10471047
"comment": "Download location for component"
10481048
}
10491049
],
1050-
"purl": "pkg:pypi/pyopenssl@23.2.0",
1050+
"purl": "pkg:pypi/pyopenssl@23.3.0",
10511051
"properties": [
10521052
{
10531053
"name": "License Comments",
@@ -1059,7 +1059,7 @@
10591059
"type": "library",
10601060
"bom-ref": "32-cryptography",
10611061
"name": "cryptography",
1062-
"version": "41.0.4",
1062+
"version": "41.0.5",
10631063
"supplier": {
10641064
"name": "The Python Cryptographic Authority and individual contributors",
10651065
"contact": [
@@ -1068,7 +1068,7 @@
10681068
}
10691069
]
10701070
},
1071-
"cpe": "cpe:2.3:a:the_python_cryptographic_authority_and_individual_contributors:cryptography:41.0.4:*:*:*:*:*:*:*",
1071+
"cpe": "cpe:2.3:a:the_python_cryptographic_authority_and_individual_contributors:cryptography:41.0.5:*:*:*:*:*:*:*",
10721072
"description": "cryptography is a package which provides cryptographic recipes and primitives to Python developers.",
10731073
"licenses": [
10741074
{
@@ -1077,12 +1077,12 @@
10771077
],
10781078
"externalReferences": [
10791079
{
1080-
"url": "https://pypi.org/project/cryptography/41.0.4",
1080+
"url": "https://pypi.org/project/cryptography/41.0.5",
10811081
"type": "distribution",
10821082
"comment": "Download location for component"
10831083
}
10841084
],
1085-
"purl": "pkg:pypi/[email protected].4"
1085+
"purl": "pkg:pypi/[email protected].5"
10861086
},
10871087
{
10881088
"type": "library",
@@ -1266,7 +1266,7 @@
12661266
"type": "library",
12671267
"bom-ref": "38-cachetools",
12681268
"name": "cachetools",
1269-
"version": "5.3.1",
1269+
"version": "5.3.2",
12701270
"supplier": {
12711271
"name": "Thomas Kemmer",
12721272
"contact": [
@@ -1275,7 +1275,7 @@
12751275
}
12761276
]
12771277
},
1278-
"cpe": "cpe:2.3:a:thomas_kemmer:cachetools:5.3.1:*:*:*:*:*:*:*",
1278+
"cpe": "cpe:2.3:a:thomas_kemmer:cachetools:5.3.2:*:*:*:*:*:*:*",
12791279
"description": "Extensible memoizing collections and decorators",
12801280
"licenses": [
12811281
{
@@ -1287,12 +1287,12 @@
12871287
],
12881288
"externalReferences": [
12891289
{
1290-
"url": "https://pypi.org/project/cachetools/5.3.1",
1290+
"url": "https://pypi.org/project/cachetools/5.3.2",
12911291
"type": "distribution",
12921292
"comment": "Download location for component"
12931293
}
12941294
],
1295-
"purl": "pkg:pypi/[email protected].1"
1295+
"purl": "pkg:pypi/[email protected].2"
12961296
},
12971297
{
12981298
"type": "library",
@@ -1763,7 +1763,7 @@
17631763
"type": "library",
17641764
"bom-ref": "55-plotly",
17651765
"name": "plotly",
1766-
"version": "5.17.0",
1766+
"version": "5.18.0",
17671767
"supplier": {
17681768
"name": "Chris P",
17691769
"contact": [
@@ -1772,7 +1772,7 @@
17721772
}
17731773
]
17741774
},
1775-
"cpe": "cpe:2.3:a:chris_p:plotly:5.17.0:*:*:*:*:*:*:*",
1775+
"cpe": "cpe:2.3:a:chris_p:plotly:5.18.0:*:*:*:*:*:*:*",
17761776
"description": "An open-source, interactive data visualization library for Python",
17771777
"licenses": [
17781778
{
@@ -1784,12 +1784,12 @@
17841784
],
17851785
"externalReferences": [
17861786
{
1787-
"url": "https://pypi.org/project/plotly/5.17.0",
1787+
"url": "https://pypi.org/project/plotly/5.18.0",
17881788
"type": "distribution",
17891789
"comment": "Download location for component"
17901790
}
17911791
],
1792-
"purl": "pkg:pypi/plotly@5.17.0"
1792+
"purl": "pkg:pypi/plotly@5.18.0"
17931793
},
17941794
{
17951795
"type": "library",

0 commit comments

Comments
 (0)