Skip to content

fix(archive): implement recursive nested archive scrubbing and preven… - #2

Open
ChrisBeaker wants to merge 2 commits into
SUSE:mainfrom
ChrisBeaker:fix/nested-archive-recursive-scrub
Open

ChrisBeaker wants to merge 2 commits into
SUSE:mainfrom
ChrisBeaker:fix/nested-archive-recursive-scrub

Conversation

@ChrisBeaker

Copy link
Copy Markdown

Summary / Overview

This Pull Request resolves a critical bug where embedded sub-archives (e.g., nested .txz or .tgz tarballs inside a parent supportconfig, common in SMLM 5.1 / containerized environments) were corrupted during the scrubbing process, and adds native, recursive nested archive scrubbing with shared mappings.


The Problem

  1. Plaintext Corruption: In processor.py, any file that is not matched as an sa binary or .obj is processed by default as a UTF-8 text file. If the archive contains nested .txz, .tgz, or .zip files, FileProcessor.process_file reads their raw compressed binary bytes, executes string replacements on them, and writes them back. This completely corrupts the binary structure, rendering the nested archives permanently unextractable.

  2. Incomplete Scrubbing: Because nested archives were not extracted, the sensitive information (IPs, hostnames, passwords) inside sub-tarballs (e.g., podman host
    OS or SMLM container logs) remained completely unanonymized.


The Solution / Changes

  1. Binary Corruption Guard (src/supportutils_scrub/processor.py):
    • Updated FileProcessor.process_file to inspect the filename using is_archive_path.
    • Compressed sub-archives are now securely skipped during plaintext scrubbing, preserving their binary integrity perfectly.
  2. Recursive Archive Scrubbing (src/supportutils_scrub/modes/archive.py):
    • Introduced a new recursive pre-processing helper: scrub_nested_archives_recursively.
    • When supportutils-scrub processes an archive, it now recursively scans the extracted directory tree for any embedded tarballs/archives.
    • Each nested archive is recursively extracted to a secure temporary folder, scrubbed recursively inside _scrub_tree using the active shared mapping dictionary, re-compressed back to its original filename/format, and cleaned up.

Benefits & Impact

  • Perfect SMLM 5.1 & Container Support: Embedded podman host OS and containerized sub-tarballs are now natively scrubbed, re-packed, and fully anonymized.
  • Integrity Preserved: Nested archives remain completely valid and uncorrupted, allowing downstream decoders to unpack them.
  • Performance Acceleration: Since this helper utilizes the central _scrub_tree function, nested archive scrubbing automatically leverages the newly implemented multi-core parallel processing (--jobs) and trie-regex performance improvements, making deep-nesting scrubbing extremely fast!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant