File tree Expand file tree Collapse file tree 7 files changed +15
-11
lines changed Expand file tree Collapse file tree 7 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 8
8
from pathlib import Path
9
9
from dataclasses import field
10
10
11
+ from pydantic import TypeAdapter , ValidationError
12
+
11
13
# we use pydantic for dataclasses so that we can
12
14
# easily load and validate JSON reports.
13
15
#
16
18
#
17
19
# really, you should just pretend we're using stock dataclasses.
18
20
from pydantic .dataclasses import dataclass
19
- from pydantic .error_wrappers import ValidationError
20
21
21
22
import floss .logging_
22
23
from floss .render import Verbosity
@@ -212,9 +213,8 @@ class ResultDocument:
212
213
strings : Strings = field (default_factory = Strings )
213
214
214
215
@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" ))
218
218
219
219
220
220
def log_result (decoded_string , verbosity ):
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ dependencies = [
34
34
" tabulate==0.9.0" ,
35
35
" vivisect==1.1.1" ,
36
36
" 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 " ,
39
39
" networkx==3.1" ,
40
40
" halo==0.0.31" ,
41
41
" rich==13.4.2" ,
Original file line number Diff line number Diff line change 25
25
import base64
26
26
import logging
27
27
import argparse
28
+ from pathlib import Path
28
29
29
30
from floss .results import AddressType , ResultDocument
30
31
@@ -147,7 +148,7 @@ def main():
147
148
logging .basicConfig (level = logging .INFO )
148
149
logging .getLogger ().setLevel (logging .INFO )
149
150
150
- result_document = ResultDocument .parse_file (args .report_path )
151
+ result_document = ResultDocument .parse_file (Path ( args .report_path ) )
151
152
152
153
print (render_binja_script (result_document ))
153
154
return 0
Original file line number Diff line number Diff line change 25
25
import base64
26
26
import logging
27
27
import argparse
28
+ from pathlib import Path
28
29
29
30
from floss .results import AddressType , ResultDocument
30
31
@@ -135,7 +136,7 @@ def main():
135
136
logging .basicConfig (level = logging .INFO )
136
137
logging .getLogger ().setLevel (logging .INFO )
137
138
138
- result_document = ResultDocument .parse_file (args .report_path )
139
+ result_document = ResultDocument .parse_file (Path ( args .report_path ) )
139
140
140
141
print (render_ghidra_script (result_document ))
141
142
return 0
Original file line number Diff line number Diff line change 24
24
import base64
25
25
import logging
26
26
import argparse
27
+ from pathlib import Path
27
28
28
29
from floss .results import AddressType , ResultDocument
29
30
@@ -141,7 +142,7 @@ def main():
141
142
logging .basicConfig (level = logging .INFO )
142
143
logging .getLogger ().setLevel (logging .INFO )
143
144
144
- result_document = ResultDocument .parse_file (args .report_path )
145
+ result_document = ResultDocument .parse_file (Path ( args .report_path ) )
145
146
146
147
print (render_ida_script (result_document ))
147
148
return 0
Original file line number Diff line number Diff line change 25
25
import base64
26
26
import logging
27
27
import argparse
28
+ from pathlib import Path
28
29
29
30
from floss .results import AddressType , ResultDocument
30
31
@@ -90,7 +91,7 @@ def main():
90
91
logging .basicConfig (level = logging .INFO )
91
92
logging .getLogger ().setLevel (logging .INFO )
92
93
93
- result_document = ResultDocument .parse_file (args .report_path )
94
+ result_document = ResultDocument .parse_file (Path ( args .report_path ) )
94
95
95
96
print (render_r2_script (result_document ))
96
97
return 0
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ def main():
102
102
logging .basicConfig (level = logging .INFO )
103
103
logging .getLogger ().setLevel (logging .INFO )
104
104
105
- result_document = ResultDocument .parse_file (args .report_path )
105
+ result_document = ResultDocument .parse_file (Path ( args .report_path ) )
106
106
107
107
print (render_x64dbg_database (result_document ))
108
108
return 0
You can’t perform that action at this time.
0 commit comments