diff --git a/tests/integration/archive/cpio/cpio_portable_ascii/__output__/sample.nofilepad.unaligned.cpio-newc_extract/0-1.unknown b/tests/integration/archive/cpio/cpio_portable_ascii/__output__/sample.nofilepad.unaligned.cpio-newc_extract/0-1.padding similarity index 100% rename from tests/integration/archive/cpio/cpio_portable_ascii/__output__/sample.nofilepad.unaligned.cpio-newc_extract/0-1.unknown rename to tests/integration/archive/cpio/cpio_portable_ascii/__output__/sample.nofilepad.unaligned.cpio-newc_extract/0-1.padding diff --git a/tests/integration/compression/bzip2/__output__/collated.headpad.bzip2_extract/0-17.unknown b/tests/integration/compression/bzip2/__output__/collated.headpad.bzip2_extract/0-17.padding similarity index 100% rename from tests/integration/compression/bzip2/__output__/collated.headpad.bzip2_extract/0-17.unknown rename to tests/integration/compression/bzip2/__output__/collated.headpad.bzip2_extract/0-17.padding diff --git a/tests/integration/executable/elf/elf64/__output__/kernel-initramfs-padding_extract/17-11651465.elf64_extract/initramfs_extract/366109-366113.unknown b/tests/integration/executable/elf/elf64/__output__/kernel-initramfs-padding_extract/17-11651465.elf64_extract/initramfs_extract/366109-366113.padding similarity index 100% rename from tests/integration/executable/elf/elf64/__output__/kernel-initramfs-padding_extract/17-11651465.elf64_extract/initramfs_extract/366109-366113.unknown rename to tests/integration/executable/elf/elf64/__output__/kernel-initramfs-padding_extract/17-11651465.elf64_extract/initramfs_extract/366109-366113.padding diff --git a/tests/integration/executable/elf/elf64/__output__/linux-kernel-with-initramfs-without-loadable-modules_extract/15039-1184915.xz_extract/xz.uncompressed_extract/initramfs_extract/366109-366113.unknown b/tests/integration/executable/elf/elf64/__output__/linux-kernel-with-initramfs-without-loadable-modules_extract/15039-1184915.xz_extract/xz.uncompressed_extract/initramfs_extract/366109-366113.padding similarity index 100% rename from tests/integration/executable/elf/elf64/__output__/linux-kernel-with-initramfs-without-loadable-modules_extract/15039-1184915.xz_extract/xz.uncompressed_extract/initramfs_extract/366109-366113.unknown rename to tests/integration/executable/elf/elf64/__output__/linux-kernel-with-initramfs-without-loadable-modules_extract/15039-1184915.xz_extract/xz.uncompressed_extract/initramfs_extract/366109-366113.padding diff --git a/tests/integration/filesystem/fat/fat12/__output__/cherry.truncated.fat12_extract/28160-32768.unknown b/tests/integration/filesystem/fat/fat12/__output__/cherry.truncated.fat12_extract/28160-32768.padding similarity index 100% rename from tests/integration/filesystem/fat/fat12/__output__/cherry.truncated.fat12_extract/28160-32768.unknown rename to tests/integration/filesystem/fat/fat12/__output__/cherry.truncated.fat12_extract/28160-32768.padding diff --git a/tests/integration/filesystem/fat/fat16/__output__/banana.truncated.fat16_extract/28160-32768.unknown b/tests/integration/filesystem/fat/fat16/__output__/banana.truncated.fat16_extract/28160-32768.padding similarity index 100% rename from tests/integration/filesystem/fat/fat16/__output__/banana.truncated.fat16_extract/28160-32768.unknown rename to tests/integration/filesystem/fat/fat16/__output__/banana.truncated.fat16_extract/28160-32768.padding diff --git a/tests/integration/filesystem/fat/fat32/__output__/banana.truncated.fat32_extract/551424-2097152.unknown b/tests/integration/filesystem/fat/fat32/__output__/banana.truncated.fat32_extract/551424-2097152.padding similarity index 100% rename from tests/integration/filesystem/fat/fat32/__output__/banana.truncated.fat32_extract/551424-2097152.unknown rename to tests/integration/filesystem/fat/fat32/__output__/banana.truncated.fat32_extract/551424-2097152.padding diff --git a/unblob/models.py b/unblob/models.py index e39c6f0336..5657af27d0 100644 --- a/unblob/models.py +++ b/unblob/models.py @@ -148,6 +148,27 @@ def as_report(self, entropy: Optional[EntropyReport]) -> UnknownChunkReport: ) +@attr.define(repr=False) +class PaddingChunk(Chunk): + r"""Gaps between valid chunks or otherwise unknown chunks. + + Important for manual analysis, and analytical certanity: for example + entropy, other chunks inside it, metadata, etc. + + These are not extracted, just logged for information purposes and further analysis, + like most common bytes (like \x00 and \xFF), ASCII strings, high entropy, etc. + """ + + def as_report(self, entropy: Optional[EntropyReport]) -> PaddingChunkReport: + return PaddingChunkReport( + chunk_id=self.id, + start_offset=self.start_offset, + end_offset=self.end_offset, + size=self.size, + entropy=entropy, + ) + + @attrs.define class MultiFile(Blob): name: str = attr.field(kw_only=True) @@ -171,26 +192,6 @@ def as_report(self, extraction_reports: List[Report]) -> MultiFileReport: ReportType = TypeVar("ReportType", bound=Report) -@attr.define(repr=False) -class PaddingChunk(Chunk): - r"""Gaps between valid chunks or otherwise unknown chunks. - - Important for manual analysis, and analytical certanity: for example - entropy, other chunks inside it, metadata, etc. - - These are not extracted, just logged for information purposes and further analysis, - like most common bytes (like \x00 and \xFF), ASCII strings, high entropy, etc. - """ - - def as_report(self) -> PaddingChunkReport: - return PaddingChunkReport( - chunk_id=self.id, - start_offset=self.start_offset, - end_offset=self.end_offset, - size=self.size, - ) - - @attr.define class TaskResult: task: Task diff --git a/unblob/report.py b/unblob/report.py index 48b6de7130..d9bb67e226 100644 --- a/unblob/report.py +++ b/unblob/report.py @@ -236,6 +236,16 @@ class UnknownChunkReport(Report): entropy: Optional[EntropyReport] +@final +@attr.define(kw_only=True, frozen=True) +class PaddingChunkReport(Report): + chunk_id: str + start_offset: int + end_offset: int + size: int + entropy: Optional[EntropyReport] + + @final @attr.define(kw_only=True, frozen=True) class MultiFileReport(Report): @@ -300,12 +310,3 @@ class SpecialFileExtractionProblem(ExtractionProblem): def log_with(self, logger): logger.warning(self.log_msg, path=self.path, mode=self.mode, device=self.device) - - -@final -@attr.define(kw_only=True) -class PaddingChunkReport(Report): - chunk_id: str - start_offset: int - end_offset: int - size: int