Add anonymizer tool - #166
Open
sfraczek wants to merge 5 commits into
Open
Conversation
jczaja
reviewed
Dec 8, 2025
sfraczek
force-pushed
the
sfraczek/anonymizer
branch
2 times, most recently
from
December 13, 2025 18:12
c7fdef8 to
816af4d
Compare
sfraczek
force-pushed
the
sfraczek/anonymizer
branch
2 times, most recently
from
July 7, 2026 17:50
ff026ea to
296708b
Compare
sfraczek
marked this pull request as ready for review
July 7, 2026 17:50
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Rust-based “etradeAnonymizer” tool within the existing crate, aimed at detecting and replacing PII in (a constrained subset of) PDF statement streams while preserving original stream byte lengths to avoid rebuilding XREF offsets.
Changes:
- Adds a new
etradeAnonymizerbinary withlistandanonymizesubcommands. - Implements PDF stream scanning/text token extraction plus “smart” token-preserving replacement with size-fitting recompression and padding.
- Updates project metadata and dependencies to support the new functionality (e.g.,
flate2,sha2) and ignores local PDF fixtures.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib.rs | Exports the new anonymizer module from the crate root for library/tests/binary access. |
| src/anonymizer/mod.rs | Defines the anonymizer module structure and re-exports submodules. |
| src/anonymizer/anonymizer.rs | Adds the new CLI binary entry point and subcommand routing. |
| src/anonymizer/pdf.rs | Implements strict PDF header validation, stream scanning, and token extraction/unescaping utilities. |
| src/anonymizer/replace.rs | Implements smart anonymization by token replacement with recompression-to-fit and padding. |
| src/anonymizer/list.rs | Adds a “list tokens” mode for inspecting extracted text tokens per stream. |
| src/anonymizer/path.rs | Adds helper for generating default anonymized output filenames. |
| src/anonymizer/README.md | Documents usage, strategy, limitations, and local-only testing workflow. |
| README.md | Updates SPDX copyright year range. |
| Cargo.toml | Registers the new binary and adds required dependencies. |
| Cargo.lock | Updates the lockfile to include new/updated dependency versions. |
| .gitignore | Ignores local PDF fixtures for offline integration testing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sfraczek
force-pushed
the
sfraczek/anonymizer
branch
2 times, most recently
from
July 7, 2026 18:15
d45fb82 to
c666272
Compare
sfraczek
force-pushed
the
sfraczek/anonymizer
branch
from
July 10, 2026 13:13
4b9e581 to
5289612
Compare
Register the etradeAnonymizer binary, add its dependencies (flate2, clap derive), refresh the lockfile (incl. ethnum 1.5.3 for newer rustc), ignore local PDF fixtures, and bump the SPDX copyright year.
Strict %PDF-1.3 reader, a single-regex stream scanner that classifies each stream by its dictionary (font programs via /Length1 and unsupported filters skipped, FlateDecode decoded, plain content scanned), byte-exact stream slicing with end-marker validation, and a linear text-token scanner that only commits tokens inside closed BT/ET text objects. Wires the module into the crate root.
replace_pii_smart decompresses each content stream, replaces PII tokens with positional indices while preserving marker phrases and the CASH FLOW section, recompresses to fit, and NUL-pads to keep the original stream byte length so the XREF table stays valid. Warns loudly on skipped streams and on a CASH FLOW section that never closes.
The list subcommand prints extracted tokens per stream; anonymous_output_path builds the default 'anonymous_<input>.pdf' name; the clap-based binary wires the list and anonymize subcommands.
sfraczek
force-pushed
the
sfraczek/anonymizer
branch
from
August 20, 2026 15:06
5289612 to
0ec86c8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces
etradeAnonymizer— a Rust binary andanonymizermodule for anonymizing E*TRADE / Morgan Stanley PDF statements while preserving data needed for tax calculations.Subcommands
list <input.pdf>— lists all text tokens from FlateDecode/uncompressed streams (debugging/inspection).anonymize <input.pdf> [output.pdf]— replaces PII with stable numeric tokens; output defaults toanonymous_<input>.pdf.How it works
/Length, PDF 1.3).CLIENT STATEMENT/For the Period, and everything betweenCASH FLOW ACTIVITY BY DATEandNET CREDITS/(DEBITS)(inclusive).Module layout
list.rs,replace.rs(engine:replace_pii_smart),path.rs,pdf.rs. No separatedetectmodule/mode.Testing
#[ignore]— they require local plain PDF fixtures inanonymizer_data/(git-ignored) and do not run in CI.Notes
openssldependency, no bundled encrypted fixtures, noANONYMIZER_TEST_KEYin CI.