Skip to content

Commit 73020a4

Browse files
bump-pydantic from 1.10.9 to 2.6.0 (mandiant#954)
* bump-pydantic
1 parent b60b609 commit 73020a4

7 files changed

+15
-11
lines changed

floss/results.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from pathlib import Path
99
from dataclasses import field
1010

11+
from pydantic import TypeAdapter, ValidationError
12+
1113
# we use pydantic for dataclasses so that we can
1214
# easily load and validate JSON reports.
1315
#
@@ -16,7 +18,6 @@
1618
#
1719
# really, you should just pretend we're using stock dataclasses.
1820
from pydantic.dataclasses import dataclass
19-
from pydantic.error_wrappers import ValidationError
2021

2122
import floss.logging_
2223
from floss.render import Verbosity
@@ -212,9 +213,8 @@ class ResultDocument:
212213
strings: Strings = field(default_factory=Strings)
213214

214215
@classmethod
215-
def parse_file(cls, path):
216-
# We're ignoring the following mypy error since this field is guaranteed by the Pydantic dataclass.
217-
return cls.__pydantic_model__.parse_file(path) # type: ignore
216+
def parse_file(cls, path: Path) -> "ResultDocument":
217+
return TypeAdapter(cls).validate_json(path.read_text(encoding="utf-8"))
218218

219219

220220
def log_result(decoded_string, verbosity):

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ dependencies = [
3434
"tabulate==0.9.0",
3535
"vivisect==1.1.1",
3636
"viv-utils[flirt]==0.7.9",
37-
"pydantic==1.10.9",
38-
"tqdm==4.65.0",
37+
"pydantic==2.6.0",
38+
"tqdm==4.66.2",
3939
"networkx==3.1",
4040
"halo==0.0.31",
4141
"rich==13.4.2",

scripts/render-binja-import-script.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import base64
2626
import logging
2727
import argparse
28+
from pathlib import Path
2829

2930
from floss.results import AddressType, ResultDocument
3031

@@ -147,7 +148,7 @@ def main():
147148
logging.basicConfig(level=logging.INFO)
148149
logging.getLogger().setLevel(logging.INFO)
149150

150-
result_document = ResultDocument.parse_file(args.report_path)
151+
result_document = ResultDocument.parse_file(Path(args.report_path))
151152

152153
print(render_binja_script(result_document))
153154
return 0

scripts/render-ghidra-import-script.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import base64
2626
import logging
2727
import argparse
28+
from pathlib import Path
2829

2930
from floss.results import AddressType, ResultDocument
3031

@@ -135,7 +136,7 @@ def main():
135136
logging.basicConfig(level=logging.INFO)
136137
logging.getLogger().setLevel(logging.INFO)
137138

138-
result_document = ResultDocument.parse_file(args.report_path)
139+
result_document = ResultDocument.parse_file(Path(args.report_path))
139140

140141
print(render_ghidra_script(result_document))
141142
return 0

scripts/render-ida-import-script.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import base64
2525
import logging
2626
import argparse
27+
from pathlib import Path
2728

2829
from floss.results import AddressType, ResultDocument
2930

@@ -141,7 +142,7 @@ def main():
141142
logging.basicConfig(level=logging.INFO)
142143
logging.getLogger().setLevel(logging.INFO)
143144

144-
result_document = ResultDocument.parse_file(args.report_path)
145+
result_document = ResultDocument.parse_file(Path(args.report_path))
145146

146147
print(render_ida_script(result_document))
147148
return 0

scripts/render-r2-import-script.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import base64
2626
import logging
2727
import argparse
28+
from pathlib import Path
2829

2930
from floss.results import AddressType, ResultDocument
3031

@@ -90,7 +91,7 @@ def main():
9091
logging.basicConfig(level=logging.INFO)
9192
logging.getLogger().setLevel(logging.INFO)
9293

93-
result_document = ResultDocument.parse_file(args.report_path)
94+
result_document = ResultDocument.parse_file(Path(args.report_path))
9495

9596
print(render_r2_script(result_document))
9697
return 0

scripts/render-x64dbg-database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def main():
102102
logging.basicConfig(level=logging.INFO)
103103
logging.getLogger().setLevel(logging.INFO)
104104

105-
result_document = ResultDocument.parse_file(args.report_path)
105+
result_document = ResultDocument.parse_file(Path(args.report_path))
106106

107107
print(render_x64dbg_database(result_document))
108108
return 0

0 commit comments

Comments
 (0)