Skip to content

Commit

Permalink
fix: TypeError in fuzz_python_requirement_parser in fuzzing reports
Browse files Browse the repository at this point in the history
* fixes intel#4053
  • Loading branch information
hassaanshafqatt authored Aug 7, 2024
1 parent 39287a2 commit 7abee04
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 15 deletions.
4 changes: 3 additions & 1 deletion fuzz/fuzz_cargo_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def CargoLockBuilder(data, file_path):
data (protobuf message): The protobuf message to convert to a Cargo.lock file.
"""
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_composer_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def ComposerLockBuilder(data, file_path):
file_path: The path of the file to build.
"""
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_cpanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def cpanfileBuilder(data, file_path):
"""
# Convert the Protobuf message to a dictionary
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_cyclonedx.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def TestParseData(data):
"""
try:
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

components = []
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_gemfile_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def GemfileLockBuilder(data, file_path):
file_path: File path of the file to write the Gemfile.lock into.
"""
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def GoModBuilder(data, file_path):
file_path: The path of the file to build.
"""
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_intermediate_report_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def TestParseData(data):
"""
try:
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

if json_data.get("metadata") is not None:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_package_list_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def TestPackageData(data):
with_version = []
without_version = []
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

print(json_data)
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_package_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def TestParseData(data):
"""
try:
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_package_resolved.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
def PackageResolvedBuilder(data):
"""Convert the Protobuf message to a dictionary"""
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_pkg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def PkgInfoBuilder(data, file_path):
file_path (str): The path to the file to write the PKG-INFO data to.
"""
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_pom_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def PomXmlBuilder(data, file_path):
file_path: The path of the file to build.
"""
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_pubspec_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def PubspecLockBuilder(data, file_path):
data (protobuf message): The protobuf message to convert to a pubspec.lock file.
"""
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_python_requirement_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def TestParseData(data, cve_db, logger, tmpdir):
"""
try:
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)
file_path = os.path.join(tmpdir, "requirements.txt")
with open(file_path, "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion fuzz/fuzz_renv_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def RenvLockBuilder(data, file_path):
"""
# Parse the JSON data
json_data = MessageToDict(
data, preserving_proto_field_name=True, including_default_value_fields=True
data,
preserving_proto_field_name=True,
always_print_fields_with_no_presence=True,
)

with open(file_path, "w") as f:
Expand Down

0 comments on commit 7abee04

Please sign in to comment.