From 73020a427bdcc65062a2fafecf89ff1f1cc3d865 Mon Sep 17 00:00:00 2001 From: Aayush Goel <81844215+Aayush-Goel-04@users.noreply.github.com> Date: Tue, 19 Mar 2024 12:53:33 +0530 Subject: [PATCH] bump-pydantic from 1.10.9 to 2.6.0 (#954) * bump-pydantic --- floss/results.py | 8 ++++---- pyproject.toml | 4 ++-- scripts/render-binja-import-script.py | 3 ++- scripts/render-ghidra-import-script.py | 3 ++- scripts/render-ida-import-script.py | 3 ++- scripts/render-r2-import-script.py | 3 ++- scripts/render-x64dbg-database.py | 2 +- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/floss/results.py b/floss/results.py index 50849bc..5168aec 100644 --- a/floss/results.py +++ b/floss/results.py @@ -8,6 +8,8 @@ from typing import Dict, List from pathlib import Path from dataclasses import field +from pydantic import TypeAdapter, ValidationError + # we use pydantic for dataclasses so that we can # easily load and validate JSON reports. # @@ -16,7 +18,6 @@ from dataclasses import field # # really, you should just pretend we're using stock dataclasses. from pydantic.dataclasses import dataclass -from pydantic.error_wrappers import ValidationError import floss.logging_ from floss.render import Verbosity @@ -212,9 +213,8 @@ class ResultDocument: strings: Strings = field(default_factory=Strings) @classmethod - def parse_file(cls, path): - # We're ignoring the following mypy error since this field is guaranteed by the Pydantic dataclass. - return cls.__pydantic_model__.parse_file(path) # type: ignore + def parse_file(cls, path: Path) -> "ResultDocument": + return TypeAdapter(cls).validate_json(path.read_text(encoding="utf-8")) def log_result(decoded_string, verbosity): diff --git a/pyproject.toml b/pyproject.toml index 5b4415c..de6c802 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,8 +34,8 @@ dependencies = [ "tabulate==0.9.0", "vivisect==1.1.1", "viv-utils[flirt]==0.7.9", - "pydantic==1.10.9", - "tqdm==4.65.0", + "pydantic==2.6.0", + "tqdm==4.66.2", "networkx==3.1", "halo==0.0.31", "rich==13.4.2", diff --git a/scripts/render-binja-import-script.py b/scripts/render-binja-import-script.py index f867134..24ccd83 100644 --- a/scripts/render-binja-import-script.py +++ b/scripts/render-binja-import-script.py @@ -25,6 +25,7 @@ import sys import base64 import logging import argparse +from pathlib import Path from floss.results import AddressType, ResultDocument @@ -147,7 +148,7 @@ def main(): logging.basicConfig(level=logging.INFO) logging.getLogger().setLevel(logging.INFO) - result_document = ResultDocument.parse_file(args.report_path) + result_document = ResultDocument.parse_file(Path(args.report_path)) print(render_binja_script(result_document)) return 0 diff --git a/scripts/render-ghidra-import-script.py b/scripts/render-ghidra-import-script.py index e398347..49cc189 100644 --- a/scripts/render-ghidra-import-script.py +++ b/scripts/render-ghidra-import-script.py @@ -25,6 +25,7 @@ import sys import base64 import logging import argparse +from pathlib import Path from floss.results import AddressType, ResultDocument @@ -135,7 +136,7 @@ def main(): logging.basicConfig(level=logging.INFO) logging.getLogger().setLevel(logging.INFO) - result_document = ResultDocument.parse_file(args.report_path) + result_document = ResultDocument.parse_file(Path(args.report_path)) print(render_ghidra_script(result_document)) return 0 diff --git a/scripts/render-ida-import-script.py b/scripts/render-ida-import-script.py index 954116d..f226720 100644 --- a/scripts/render-ida-import-script.py +++ b/scripts/render-ida-import-script.py @@ -24,6 +24,7 @@ import sys import base64 import logging import argparse +from pathlib import Path from floss.results import AddressType, ResultDocument @@ -141,7 +142,7 @@ def main(): logging.basicConfig(level=logging.INFO) logging.getLogger().setLevel(logging.INFO) - result_document = ResultDocument.parse_file(args.report_path) + result_document = ResultDocument.parse_file(Path(args.report_path)) print(render_ida_script(result_document)) return 0 diff --git a/scripts/render-r2-import-script.py b/scripts/render-r2-import-script.py index 6c3f272..635d847 100644 --- a/scripts/render-r2-import-script.py +++ b/scripts/render-r2-import-script.py @@ -25,6 +25,7 @@ import sys import base64 import logging import argparse +from pathlib import Path from floss.results import AddressType, ResultDocument @@ -90,7 +91,7 @@ def main(): logging.basicConfig(level=logging.INFO) logging.getLogger().setLevel(logging.INFO) - result_document = ResultDocument.parse_file(args.report_path) + result_document = ResultDocument.parse_file(Path(args.report_path)) print(render_r2_script(result_document)) return 0 diff --git a/scripts/render-x64dbg-database.py b/scripts/render-x64dbg-database.py index c251f96..6dbbd9c 100644 --- a/scripts/render-x64dbg-database.py +++ b/scripts/render-x64dbg-database.py @@ -102,7 +102,7 @@ def main(): logging.basicConfig(level=logging.INFO) logging.getLogger().setLevel(logging.INFO) - result_document = ResultDocument.parse_file(args.report_path) + result_document = ResultDocument.parse_file(Path(args.report_path)) print(render_x64dbg_database(result_document)) return 0