forked from intel/cve-bin-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
777 additions
and
481 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright (C) 2023 Intel Corporation | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import sys | ||
import tempfile | ||
from pathlib import Path | ||
|
||
import atheris | ||
import atheris_libprotobuf_mutator | ||
from google.protobuf.json_format import MessageToDict | ||
|
||
import fuzz.generated.python_requirements_pb2 as python_requirements_pb2 | ||
from cve_bin_tool.cvedb import CVEDB | ||
from cve_bin_tool.log import LOGGER | ||
|
||
with atheris.instrument_imports(): | ||
from cve_bin_tool.parsers.python import PythonRequirementsParser | ||
|
||
cve_db = CVEDB() | ||
logger = LOGGER.getChild("Fuzz") | ||
|
||
|
||
def TestParseData(data): | ||
try: | ||
json_data = MessageToDict( | ||
data, preserving_proto_field_name=True, including_default_value_fields=True | ||
) | ||
|
||
with open(file_path, "w") as f: | ||
for dict in json_data.get("packages", []): | ||
extras = "" | ||
if len(dict["extras"]) > 0: | ||
extras = f"[{','.join(dict['extras'])}]" | ||
|
||
constraint = "" | ||
if "version" in dict.keys(): | ||
constraint = f" == {dict['version']}" | ||
elif "url" in dict.keys(): | ||
constraint = f"@{dict['url']}" | ||
|
||
f.write(f"{dict['name']}{extras}{constraint}\n") | ||
|
||
PRP = PythonRequirementsParser(cve_db, logger) | ||
PRP.run_checker(file_path) | ||
|
||
except SystemExit: | ||
return | ||
|
||
|
||
file_path = str(Path(tempfile.mkdtemp(prefix="cve-bin-tool-")) / "requirements.txt") | ||
|
||
atheris_libprotobuf_mutator.Setup( | ||
sys.argv, TestParseData, proto=python_requirements_pb2.PackageList | ||
) | ||
atheris.Fuzz() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2023 Intel Corporation | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
syntax = "proto3"; | ||
|
||
message PackageList{ | ||
message Package{ | ||
string name = 1; | ||
repeated string extras = 2; | ||
oneof constraint{ | ||
float version = 3; | ||
string url = 4; | ||
} | ||
} | ||
|
||
repeated Package packages = 1; | ||
} |
Oops, something went wrong.