fix(redact): scrub unknown binary parts - #241
Conversation
|
All contributors have signed the CLA — thank you! ✍️ ✅ Posted by the CLA bot. |
Greptile SummaryThe PR changes binary redaction from a deny-list to an allow-list and coordinates removal across package relationships and content-type declarations.
Confidence Score: 4/5The PR appears safe to merge after the non-blocking documentation-style cleanup. The package-removal flow coordinates normalized part classification, relationship cascades, and content-type pruning with substantial focused test coverage; the only accepted concern is unnecessarily verbose function documentation. Files Needing Attention: crates/ooxml-redact/src/scrub.rs
|
| Filename | Overview |
|---|---|
| crates/ooxml-redact/src/lib.rs | Replaces selective binary clearing with normalized allow-list classification, coordinated pruning, and post-pruning XML/media transformation. |
| crates/ooxml-redact/src/scrub.rs | Introduces relationship-graph cascading and declaration pruning; implementation appears coherent, with only overly detailed docstrings requiring cleanup. |
| crates/ooxml-redact/src/tests.rs | Adds broad regression coverage for binary removal, path aliases, ownership cascades, orphan relationships, unsupported media, and shared targets. |
| .changeset/redact-binary-allowlist.md | Accurately describes the package-level binary scrubbing behavior as a patch release. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Unpack validated OOXML parts] --> B[Normalize part names]
B --> C{Media or XML?}
C -- No --> D[Seed binary removal set]
C -- Yes --> E[Retain for transformation]
D --> F[Add owned relationship parts]
F --> G[Add internal relationship targets]
G --> H{Referenced by surviving owner?}
H -- Yes --> I[Spare shared target]
H -- No --> J[Remove part]
I --> F
J --> K[Prune relationships and content types]
K --> L[Redact XML and replace media]
E --> L
L --> M[Rebuild OOXML package]
Reviews (1): Last reviewed commit: "fix(redact): scrub unknown binary parts" | Re-trigger Greptile
|
|
||
| use crate::RedactError; | ||
|
|
||
| /// Drop scrubbed parts together with the relationship parts they own, the | ||
| /// internal parts those relationships target (unless a retained part also |
There was a problem hiding this comment.
This multi-line docstring explains implementation details already expressed by the function name and code, increasing maintenance cost and creating documentation that can drift as the cascade algorithm changes. The same pattern occurs on removal_closure and resolve_relationship_target.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
812620c to
1f6daef
Compare
1f6daef to
e6aa834
Compare
TL;DR:
Summary:
.relsparts cascade (including root-level_rels/x.relsforms and nested ownership), internal targets join the removal set unless a surviving part still references them, and content-type declarations are pruned./x, double slashes, backslashes) are classified, pruned and redacted consistentlyTest plan:
cargo test -p betteroffice-redactgreen