Skip to content

Commit

Permalink
feat(report): Report carved files
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Fasano committed Jul 2, 2024
1 parent f143e96 commit 76ce0fb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions unblob/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from .pool import make_pool
from .report import (
CalculateMultiFileExceptionReport,
CarveReport,
EntropyReport,
ExtractDirectoryExistsReport,
FileMagicReport,
Expand Down Expand Up @@ -579,6 +580,10 @@ def _extract_chunk(self, file, chunk: ValidChunk): # noqa: C901
carved_path = None
else:
inpath = carve_valid_chunk(self.carve_dir, file, chunk)
self.result.add_report(
CarveReport.from_chunk(self.task.path, inpath, chunk)
)

extract_dir = self.carve_dir / (inpath.name + self.config.extract_suffix)
carved_path = inpath

Expand Down
21 changes: 21 additions & 0 deletions unblob/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,27 @@ class UnknownChunkReport(Report):
entropy: Optional[EntropyReport]


@attr.define(kw_only=True, frozen=True)
class CarveReport(Report):
"""Describes a successful carving operation."""

carved_from: Path
carved_to: Path
start_offset: int
end_offset: int
handler_name: str

@classmethod
def from_chunk(cls, carved_from: Path, carved_to: Path, chunk: ChunkReport):
return cls(
carved_from=carved_from,
carved_to=carved_to,
start_offset=chunk.start_offset,
end_offset=chunk.end_offset,
handler_name=chunk.handler.NAME,
)


@final
@attr.define(kw_only=True, frozen=True)
class MultiFileReport(Report):
Expand Down

0 comments on commit 76ce0fb

Please sign in to comment.