Skip to content

Commit e637ab6

Browse files
vlacigarrett-zetier
authored andcommitted
Review suggestions
1 parent 8193124 commit e637ab6

File tree

5 files changed

+87
-126
lines changed

5 files changed

+87
-126
lines changed

docs/guide.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ $ cat alpine-report.json
8181
"is_file": true,
8282
"is_link": false,
8383
"link_target": null,
84-
"report_type": "StatReport"
84+
"__typename__": "StatReport"
8585
},
8686
{
8787
"magic": "gzip compressed data, max compression, from Unix, original size modulo 2^32 5816320\\012- data",
8888
"mime_type": "application/gzip",
89-
"report_type": "FileMagicReport"
89+
"__typename__": "FileMagicReport"
9090
},
9191
{
9292
"id": "13590:1",
@@ -96,16 +96,18 @@ $ cat alpine-report.json
9696
"size": 2711958,
9797
"is_encrypted": false,
9898
"extraction_reports": [],
99-
"report_type": "ChunkReport"
99+
"__typename__": "ChunkReport"
100100
}
101101
],
102102
"subtasks": [
103103
{
104104
"path": "/home/walkman/Projects/unblob/demo/alpine-minirootfs-3.16.1-x86_64.tar.gz_extract",
105105
"depth": 1,
106-
"chunk_id": "13590:1"
106+
"chunk_id": "13590:1",
107+
"__typename__": "Task"
107108
}
108-
]
109+
],
110+
"__typename__": "TaskResult"
109111
},
110112
...
111113
]
@@ -141,7 +143,7 @@ $ unblob -vvv unknown-file | grep -C 15 "Entropy distribution"
141143
2024-10-30 10:52.03 [debug ] Shannon entropy calculated block_size=0x20000 highest=99.99 lowest=99.98 mean=99.98 path=unknown-file_extract/0-10485760.unknown pid=1963719 size=0xa00000
142144
2024-10-30 10:52.03 [debug ] Chi square probability calculated block_size=0x20000 highest=97.88 lowest=3.17 mean=52.76 path=unknown-file_extract/0-10485760.unknown pid=1963719 size=0xa00000
143145
2024-10-30 10:52.03 [debug ] Entropy chart chart=
144-
Randomness distribution
146+
Randomness distribution
145147
┌───────────────────────────────────────────────────────────────────────────┐
146148
100┤ •• Shannon entropy (%) •••••••••♰••••••••••••••••••••••••••••••••••│
147149
90┤ ♰♰ Chi square probability (%) ♰ ♰ ♰♰♰♰ ♰ ♰ ♰ │
@@ -155,16 +157,16 @@ $ unblob -vvv unknown-file | grep -C 15 "Entropy distribution"
155157
10┤ ♰ ♰ ♰ ♰ ♰ ♰♰ ♰ ♰ ♰♰ │
156158
0┤ ♰ ♰ │
157159
└─┬──┬─┬──┬────┬───┬──┬──┬──┬───┬───┬──┬────┬───┬────┬──┬──┬────┬──┬───┬──┬─┘
158-
0 2 5 7 11 16 20 23 27 30 34 38 42 47 51 56 60 63 68 71 76 79
159-
131072 bytes
160+
0 2 5 7 11 16 20 23 27 30 34 38 42 47 51 56 60 63 68 71 76 79
161+
131072 bytes
160162
path=unknown-file_extract/0-10485760.unknown pid=1963719
161163
2024-10-30 10:52.03 [info ] Extracting unknown chunk chunk=0xc96196-0x1696196 path=unknown-file_extract/13197718-23683478.unknown pid=1963719
162164
2024-10-30 10:52.03 [debug ] Carving chunk path=unknown-file_extract/13197718-23683478.unknown pid=1963719
163165
2024-10-30 10:52.03 [debug ] Calculating randomness for file path=unknown-file_extract/13197718-23683478.unknown pid=1963719 size=0xa00000
164166
2024-10-30 10:52.03 [debug ] Shannon entropy calculated block_size=0x20000 highest=99.99 lowest=99.98 mean=99.98 path=unknown-file_extract/13197718-23683478.unknown pid=1963719 size=0xa00000
165167
2024-10-30 10:52.03 [debug ] Chi square probability calculated block_size=0x20000 highest=99.03 lowest=0.23 mean=42.62 path=unknown-file_extract/13197718-23683478.unknown pid=1963719 size=0xa00000
166168
2024-10-30 10:52.03 [debug ] Entropy chart chart=
167-
Randomness distribution
169+
Randomness distribution
168170
┌───────────────────────────────────────────────────────────────────────────┐
169171
100┤ •• Shannon entropy (%) •••••••••••••••••••••♰••••••••••••••••••••••│
170172
90┤ ♰♰ Chi square probability (%) ♰ ♰♰ ♰ │
@@ -178,8 +180,8 @@ $ unblob -vvv unknown-file | grep -C 15 "Entropy distribution"
178180
10┤ ♰ ♰ ♰ ♰ ♰ ♰ ♰ ♰♰ ♰ ♰♰ ♰♰ ♰♰ ♰ ♰ ♰ │
179181
0┤ ♰ ♰ ♰♰ ♰ ♰♰ │
180182
└─┬──┬─┬──┬────┬───┬──┬──┬──┬───┬───┬──┬────┬───┬────┬──┬──┬────┬──┬───┬──┬─┘
181-
0 2 5 7 11 16 20 23 27 30 34 38 42 47 51 56 60 63 68 71 76 79
182-
131072 bytes
183+
0 2 5 7 11 16 20 23 27 30 34 38 42 47 51 56 60 63 68 71 76 79
184+
131072 bytes
183185
```
184186

185187
### Skip extraction with file magic

python/unblob/models.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from .report import (
1818
CarveDirectoryReport,
1919
ChunkReport,
20-
ErrorReportBase,
20+
ErrorReport,
2121
MultiFileReport,
2222
RandomnessReport,
2323
Report,
@@ -247,20 +247,18 @@ class ProcessResult(BaseModel):
247247
results: list[TaskResult] = []
248248

249249
@property
250-
def errors(self) -> list[ErrorReportBase]:
250+
def errors(self) -> list[ErrorReport]:
251251
reports = itertools.chain.from_iterable(r.reports for r in self.results)
252252
interesting_reports = (
253-
r for r in reports if isinstance(r, (ErrorReportBase, ChunkReport))
253+
r for r in reports if isinstance(r, (ErrorReport, ChunkReport))
254254
)
255255
errors = []
256256
for report in interesting_reports:
257-
if isinstance(report, ErrorReportBase):
257+
if isinstance(report, ErrorReport):
258258
errors.append(report)
259259
else:
260260
errors.extend(
261-
r
262-
for r in report.extraction_reports
263-
if isinstance(r, ErrorReportBase)
261+
r for r in report.extraction_reports if isinstance(r, ErrorReport)
264262
)
265263
return errors
266264

0 commit comments

Comments
 (0)