zyppcli 0.2.2__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zyppcli-0.4.0/.github/workflows/ci.yaml +42 -0
- zyppcli-0.4.0/PKG-INFO +236 -0
- zyppcli-0.4.0/README.md +215 -0
- zyppcli-0.4.0/plans/anonymize-plan.md +293 -0
- zyppcli-0.4.0/pyproject.toml +45 -0
- zyppcli-0.4.0/tests/conftest.py +34 -0
- zyppcli-0.4.0/tests/test_anonymize.py +297 -0
- zyppcli-0.4.0/tests/test_integration.py +355 -0
- zyppcli-0.4.0/tests/test_pdf.py +198 -0
- zyppcli-0.4.0/tests/test_recognizers.py +55 -0
- zyppcli-0.4.0/tests/test_synthetic.py +62 -0
- zyppcli-0.4.0/tests/test_tabular.py +87 -0
- zyppcli-0.4.0/uv.lock +2537 -0
- {zyppcli-0.2.2 → zyppcli-0.4.0}/zyppcli/__main__.py +4 -1
- zyppcli-0.4.0/zyppcli/anonymization/__init__.py +5 -0
- zyppcli-0.4.0/zyppcli/anonymization/pdf.py +195 -0
- zyppcli-0.4.0/zyppcli/anonymization/recognizers.py +42 -0
- zyppcli-0.4.0/zyppcli/anonymization/synthetic.py +72 -0
- zyppcli-0.4.0/zyppcli/anonymization/tabular.py +69 -0
- zyppcli-0.4.0/zyppcli/anonymization/text.py +243 -0
- zyppcli-0.4.0/zyppcli/commands/anonymize.py +187 -0
- zyppcli-0.2.2/.github/workflows/ci.yaml +0 -19
- zyppcli-0.2.2/PKG-INFO +0 -72
- zyppcli-0.2.2/README.md +0 -62
- zyppcli-0.2.2/pyproject.toml +0 -24
- zyppcli-0.2.2/uv.lock +0 -368
- {zyppcli-0.2.2 → zyppcli-0.4.0}/.github/workflows/publish.yaml +0 -0
- {zyppcli-0.2.2 → zyppcli-0.4.0}/.gitignore +0 -0
- {zyppcli-0.2.2 → zyppcli-0.4.0}/.pre-commit-config.yaml +0 -0
- {zyppcli-0.2.2 → zyppcli-0.4.0}/plans/zyppcli-plan.md +0 -0
- {zyppcli-0.2.2 → zyppcli-0.4.0}/zyppcli/__init__.py +0 -0
- {zyppcli-0.2.2 → zyppcli-0.4.0}/zyppcli/commands/__init__.py +0 -0
- {zyppcli-0.2.2 → zyppcli-0.4.0}/zyppcli/commands/keyvault.py +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches-ignore:
|
|
6
|
+
- "master"
|
|
7
|
+
- "main"
|
|
8
|
+
- "staging"
|
|
9
|
+
- "development"
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v6
|
|
17
|
+
|
|
18
|
+
- name: Run prek pre-commit checks
|
|
19
|
+
uses: j178/prek-action@v1
|
|
20
|
+
|
|
21
|
+
tests:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v6
|
|
25
|
+
- uses: astral-sh/setup-uv@v7
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.12"
|
|
28
|
+
- run: uv sync --locked
|
|
29
|
+
- run: uv run --no-sync pytest
|
|
30
|
+
|
|
31
|
+
integration:
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v6
|
|
35
|
+
- uses: astral-sh/setup-uv@v7
|
|
36
|
+
with:
|
|
37
|
+
python-version: "3.12"
|
|
38
|
+
- run: sudo apt-get update && sudo apt-get install -y tesseract-ocr tesseract-ocr-nld tesseract-ocr-eng
|
|
39
|
+
- run: uv sync --locked
|
|
40
|
+
- name: Install local language models
|
|
41
|
+
run: uv run --no-sync zypp anonymize --setup
|
|
42
|
+
- run: uv run --no-sync pytest -m integration
|
zyppcli-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: zyppcli
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Internal CLI for Zypp
|
|
5
|
+
Requires-Python: >=3.12
|
|
6
|
+
Requires-Dist: azure-identity>=1.17.0
|
|
7
|
+
Requires-Dist: azure-keyvault-secrets>=4.8.0
|
|
8
|
+
Requires-Dist: azure-mgmt-keyvault>=10.0.0
|
|
9
|
+
Requires-Dist: certifi>=2026.10.18
|
|
10
|
+
Requires-Dist: faker>=40.63.0
|
|
11
|
+
Requires-Dist: openpyxl>=3.1.5
|
|
12
|
+
Requires-Dist: pandas>=3.1.1
|
|
13
|
+
Requires-Dist: pillow>=13.0.0
|
|
14
|
+
Requires-Dist: presidio-analyzer<3,>=2.2.360
|
|
15
|
+
Requires-Dist: presidio-anonymizer<3,>=2.2.360
|
|
16
|
+
Requires-Dist: presidio-image-redactor>=0.0.62
|
|
17
|
+
Requires-Dist: pymupdf<2,>=1.26.0
|
|
18
|
+
Requires-Dist: spacy<3.9,>=3.8
|
|
19
|
+
Requires-Dist: tldextract>=5.4.0
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# Zypp CLI
|
|
23
|
+
|
|
24
|
+
Internal CLI for Zypp: load secrets from Azure Key Vault and anonymize client files locally with Microsoft Presidio.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uv tool install zyppcli
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
To upgrade to the latest version:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
uv tool install zyppcli --upgrade
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Key Vault prerequisites
|
|
39
|
+
|
|
40
|
+
You need to be authenticated with Azure:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
az login
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
### Anonymize PDF, Excel or text files
|
|
49
|
+
|
|
50
|
+
Install Zypp CLI normally, then download both local spaCy models once:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv tool install zyppcli
|
|
54
|
+
zypp anonymize --setup
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
To install from this checkout, use `uv tool install .` instead. To upgrade an
|
|
58
|
+
existing installation, use `uv tool install zyppcli --upgrade`. Setup installs the
|
|
59
|
+
Dutch and English models into the CLI's own environment, using uv when available
|
|
60
|
+
or pip otherwise. It can be run again safely. Downloading models requires network
|
|
61
|
+
access; anonymizing client files does not download anything.
|
|
62
|
+
|
|
63
|
+
Scanned PDFs and PDF pages with images or annotations also need local Tesseract
|
|
64
|
+
OCR and its Dutch (`nld`) and English (`eng`) language packs:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# macOS
|
|
68
|
+
brew install tesseract tesseract-lang
|
|
69
|
+
|
|
70
|
+
# Ubuntu/Debian
|
|
71
|
+
sudo apt-get install tesseract-ocr tesseract-ocr-nld tesseract-ocr-eng
|
|
72
|
+
|
|
73
|
+
# Check which language packs are available
|
|
74
|
+
tesseract --list-langs
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
zypp anonymize report.pdf
|
|
79
|
+
# -> report.anonymized.pdf
|
|
80
|
+
|
|
81
|
+
zypp anonymize customers.xlsx
|
|
82
|
+
# -> customers.anonymized.xlsx
|
|
83
|
+
|
|
84
|
+
zypp anonymize ./client-files
|
|
85
|
+
# -> ./client-files.anonymized/ (recursive, with relative file paths preserved)
|
|
86
|
+
|
|
87
|
+
zypp anonymize report.pdf --language en
|
|
88
|
+
zypp anonymize ./client-files --output ./review-copy
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Dutch is the default. Processing uses local Presidio/spaCy/Tesseract engines;
|
|
92
|
+
client files are not sent to cloud services. By default, detected values are
|
|
93
|
+
replaced with synthetic data: fake names, example-domain emails, generated bank
|
|
94
|
+
accounts and other values of the detected type. The same entity type and exact
|
|
95
|
+
value receive the same replacement within one run; the in-memory mapping is not
|
|
96
|
+
saved. Different runs generate new data.
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Default: fill detected fields with bogus data
|
|
100
|
+
zypp anonymize report.pdf
|
|
101
|
+
|
|
102
|
+
# Previous behavior: black PDF boxes and entity-label replacements in text/Excel
|
|
103
|
+
zypp anonymize report.pdf --redact
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
PDF originals are removed before replacement text is drawn, including text in
|
|
107
|
+
images. Unaffected native text stays selectable. Long fake values may use smaller
|
|
108
|
+
text or be abbreviated to fit the original field. No original text is left hidden
|
|
109
|
+
under the replacement. A synthetic PDF field is not an editable form widget.
|
|
110
|
+
|
|
111
|
+
Detection is broad by default: organization names, locations and dates are included,
|
|
112
|
+
as well as personal identifiers. For business documents where you want to keep
|
|
113
|
+
those categories, opt into the narrower personal profile:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
zypp anonymize report.pdf --profile personal
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This profile targets people, email addresses, phone numbers, Dutch BSNs, IBANs and
|
|
120
|
+
credit cards. It leaves organization names, locations and dates alone, including
|
|
121
|
+
birth dates. It reduces false positives on ordinary Dutch business terms that the
|
|
122
|
+
language model mistakes for organizations or places. It does not prevent all
|
|
123
|
+
incorrect detections of person names.
|
|
124
|
+
|
|
125
|
+
For more specific tuning:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Choose exactly which Presidio entity types to detect (overrides the profile)
|
|
129
|
+
zypp anonymize report.pdf --entities PERSON EMAIL_ADDRESS PHONE_NUMBER NL_BSN IBAN_CODE
|
|
130
|
+
|
|
131
|
+
# Discard detections below a Presidio score of 0.7
|
|
132
|
+
zypp anonymize report.pdf --profile personal --score-threshold 0.7
|
|
133
|
+
|
|
134
|
+
# Keep an exact detected phrase; repeat the option for more phrases
|
|
135
|
+
zypp anonymize report.pdf --allow-list Vakantiebijslag --allow-list Onregelmatigheids-
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Settings apply to native PDF text, OCR, Excel, CSV and text/JSON alike. Allow-list
|
|
139
|
+
matches are exact and case-sensitive. The default score threshold remains `0`,
|
|
140
|
+
preserving the original broad behavior. Raising it is not a universal fix: spaCy
|
|
141
|
+
name/location/organization detections commonly share the same fixed score, so a
|
|
142
|
+
high threshold can discard real names as well as false positives. Start by choosing
|
|
143
|
+
the categories your use case needs; use an allow-list for known-safe exact phrases.
|
|
144
|
+
|
|
145
|
+
| Format | Result |
|
|
146
|
+
| --- | --- |
|
|
147
|
+
| `.pdf` | Preserves unaffected selectable text on native and mixed pages. Scans use OCR for detection and remain image content. Detected characters are deleted and matching image pixels are blanked before synthetic text is inserted; `--redact` uses black fills. Interactive forms, annotations, links and original document metadata are removed. |
|
|
148
|
+
| `.xlsx` | Fresh values-only workbook. All worksheets and hidden cells are processed; output tabs are named `Sheet1`, `Sheet2`, etc. Formulas, formatting, comments, links, drawings and original metadata are omitted. |
|
|
149
|
+
| `.csv`, `.tsv` | Properly quoted UTF-8 data with cell-level replacements. CSV uses commas; TSV uses tabs. |
|
|
150
|
+
| `.txt`, `.md`, `.log` | UTF-8 text with synthetic values, or entity labels with `--redact`. |
|
|
151
|
+
| `.json`, `.jsonl` | Valid JSON with processed keys and values. Colliding or duplicate keys are rejected. |
|
|
152
|
+
|
|
153
|
+
Excel formulas use the results saved by Excel. If a formula has no saved result,
|
|
154
|
+
the workbook fails with an instruction to recalculate and save it in Excel.
|
|
155
|
+
Numeric identifiers are scanned too; matched numbers become replacement strings.
|
|
156
|
+
Unmatched values retain their types, and text leading zeroes are preserved.
|
|
157
|
+
Custom Excel display formats such as `000000000` are not retained. Excel drawings
|
|
158
|
+
and embedded objects are omitted with a warning, rather than processed as images.
|
|
159
|
+
|
|
160
|
+
Originals are preserved. Rerunning replaces matching output files automatically;
|
|
161
|
+
you do not need to delete earlier output first. Replacement is atomic: a failed
|
|
162
|
+
rerun keeps the previous completed output. Folder reruns keep unrelated existing
|
|
163
|
+
files. Source/output overlap and symbolic links are refused.
|
|
164
|
+
|
|
165
|
+
For folders, unsupported files are skipped. Failed new files have no final output,
|
|
166
|
+
and completed files are retained. A skipped or failed file makes the command exit
|
|
167
|
+
with status `1` and report a partial run. Temporary files and new output use
|
|
168
|
+
owner-only permissions where supported.
|
|
169
|
+
|
|
170
|
+
Dutch invoice coverage includes an IBAN-field fallback for OCR spacing/character
|
|
171
|
+
confusion and a targeted name recognizer for initials and a
|
|
172
|
+
surname after `T.a.v.` or `Ter attentie van`, plus Dutch VAT ID format detection
|
|
173
|
+
(`NL_VAT`) in broad mode. The personal profile includes the name recognizer but
|
|
174
|
+
omits VAT IDs unless explicitly selected through `--entities`. These focused rules
|
|
175
|
+
help with invoice fields; arbitrary names and addresses can still be missed.
|
|
176
|
+
|
|
177
|
+
**Review output before sharing.** Detection and OCR can miss personal data or
|
|
178
|
+
replace harmless text. Faces, signatures, indirect identifiers and every kind of
|
|
179
|
+
address or sensitive fact are not comprehensively detected. Filesystem names
|
|
180
|
+
remain unchanged and may themselves identify people. Legacy `.xls`, macro-enabled
|
|
181
|
+
Office files and password-protected PDFs are not supported.
|
|
182
|
+
|
|
183
|
+
For implementation details, see [the anonymize plan](plans/anonymize-plan.md).
|
|
184
|
+
|
|
185
|
+
### List Key Vaults
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
zypp keyvault list --subscription <subscription-id>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Lists all accessible Key Vaults in the given Azure subscription.
|
|
192
|
+
|
|
193
|
+
To filter by name (case-insensitive substring match):
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
zypp keyvault list --subscription <subscription-id> --name dev
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Load secrets from Azure Key Vault
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
eval $(zypp keyvault load --vault <vault-name>)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
This fetches all enabled secrets from the specified vault and exports them as environment variables. Secret names are transformed: hyphens become underscores and the name is uppercased (e.g. `db-password` becomes `DB_PASSWORD`).
|
|
206
|
+
|
|
207
|
+
Without `eval`, the command only prints the export statements without setting them:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
zypp keyvault load --vault <vault-name>
|
|
211
|
+
# Output:
|
|
212
|
+
# export DB_PASSWORD='...'
|
|
213
|
+
# export SQL_DB='...'
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Version
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
zypp --version
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Development and checks
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
uv sync
|
|
226
|
+
uv run --no-sync zypp anonymize --setup
|
|
227
|
+
uv run --no-sync pytest
|
|
228
|
+
uv run --no-sync pytest -m integration
|
|
229
|
+
uvx prek run --all-files
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The default suite tests file handling and document adapters without spaCy models
|
|
233
|
+
or Tesseract. Integration tests require both language models, Tesseract and its
|
|
234
|
+
`nld`/`eng` packs; they exercise real detection, scans, mixed PDFs and the CLI.
|
|
235
|
+
Use `--no-sync` after setup: an exact `uv sync` removes model packages that
|
|
236
|
+
are not in the project lockfile. Run setup again if needed. CI runs both suites.
|
zyppcli-0.4.0/README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Zypp CLI
|
|
2
|
+
|
|
3
|
+
Internal CLI for Zypp: load secrets from Azure Key Vault and anonymize client files locally with Microsoft Presidio.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv tool install zyppcli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
To upgrade to the latest version:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uv tool install zyppcli --upgrade
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Key Vault prerequisites
|
|
18
|
+
|
|
19
|
+
You need to be authenticated with Azure:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
az login
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Anonymize PDF, Excel or text files
|
|
28
|
+
|
|
29
|
+
Install Zypp CLI normally, then download both local spaCy models once:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
uv tool install zyppcli
|
|
33
|
+
zypp anonymize --setup
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
To install from this checkout, use `uv tool install .` instead. To upgrade an
|
|
37
|
+
existing installation, use `uv tool install zyppcli --upgrade`. Setup installs the
|
|
38
|
+
Dutch and English models into the CLI's own environment, using uv when available
|
|
39
|
+
or pip otherwise. It can be run again safely. Downloading models requires network
|
|
40
|
+
access; anonymizing client files does not download anything.
|
|
41
|
+
|
|
42
|
+
Scanned PDFs and PDF pages with images or annotations also need local Tesseract
|
|
43
|
+
OCR and its Dutch (`nld`) and English (`eng`) language packs:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# macOS
|
|
47
|
+
brew install tesseract tesseract-lang
|
|
48
|
+
|
|
49
|
+
# Ubuntu/Debian
|
|
50
|
+
sudo apt-get install tesseract-ocr tesseract-ocr-nld tesseract-ocr-eng
|
|
51
|
+
|
|
52
|
+
# Check which language packs are available
|
|
53
|
+
tesseract --list-langs
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
zypp anonymize report.pdf
|
|
58
|
+
# -> report.anonymized.pdf
|
|
59
|
+
|
|
60
|
+
zypp anonymize customers.xlsx
|
|
61
|
+
# -> customers.anonymized.xlsx
|
|
62
|
+
|
|
63
|
+
zypp anonymize ./client-files
|
|
64
|
+
# -> ./client-files.anonymized/ (recursive, with relative file paths preserved)
|
|
65
|
+
|
|
66
|
+
zypp anonymize report.pdf --language en
|
|
67
|
+
zypp anonymize ./client-files --output ./review-copy
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Dutch is the default. Processing uses local Presidio/spaCy/Tesseract engines;
|
|
71
|
+
client files are not sent to cloud services. By default, detected values are
|
|
72
|
+
replaced with synthetic data: fake names, example-domain emails, generated bank
|
|
73
|
+
accounts and other values of the detected type. The same entity type and exact
|
|
74
|
+
value receive the same replacement within one run; the in-memory mapping is not
|
|
75
|
+
saved. Different runs generate new data.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Default: fill detected fields with bogus data
|
|
79
|
+
zypp anonymize report.pdf
|
|
80
|
+
|
|
81
|
+
# Previous behavior: black PDF boxes and entity-label replacements in text/Excel
|
|
82
|
+
zypp anonymize report.pdf --redact
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
PDF originals are removed before replacement text is drawn, including text in
|
|
86
|
+
images. Unaffected native text stays selectable. Long fake values may use smaller
|
|
87
|
+
text or be abbreviated to fit the original field. No original text is left hidden
|
|
88
|
+
under the replacement. A synthetic PDF field is not an editable form widget.
|
|
89
|
+
|
|
90
|
+
Detection is broad by default: organization names, locations and dates are included,
|
|
91
|
+
as well as personal identifiers. For business documents where you want to keep
|
|
92
|
+
those categories, opt into the narrower personal profile:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
zypp anonymize report.pdf --profile personal
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This profile targets people, email addresses, phone numbers, Dutch BSNs, IBANs and
|
|
99
|
+
credit cards. It leaves organization names, locations and dates alone, including
|
|
100
|
+
birth dates. It reduces false positives on ordinary Dutch business terms that the
|
|
101
|
+
language model mistakes for organizations or places. It does not prevent all
|
|
102
|
+
incorrect detections of person names.
|
|
103
|
+
|
|
104
|
+
For more specific tuning:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Choose exactly which Presidio entity types to detect (overrides the profile)
|
|
108
|
+
zypp anonymize report.pdf --entities PERSON EMAIL_ADDRESS PHONE_NUMBER NL_BSN IBAN_CODE
|
|
109
|
+
|
|
110
|
+
# Discard detections below a Presidio score of 0.7
|
|
111
|
+
zypp anonymize report.pdf --profile personal --score-threshold 0.7
|
|
112
|
+
|
|
113
|
+
# Keep an exact detected phrase; repeat the option for more phrases
|
|
114
|
+
zypp anonymize report.pdf --allow-list Vakantiebijslag --allow-list Onregelmatigheids-
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Settings apply to native PDF text, OCR, Excel, CSV and text/JSON alike. Allow-list
|
|
118
|
+
matches are exact and case-sensitive. The default score threshold remains `0`,
|
|
119
|
+
preserving the original broad behavior. Raising it is not a universal fix: spaCy
|
|
120
|
+
name/location/organization detections commonly share the same fixed score, so a
|
|
121
|
+
high threshold can discard real names as well as false positives. Start by choosing
|
|
122
|
+
the categories your use case needs; use an allow-list for known-safe exact phrases.
|
|
123
|
+
|
|
124
|
+
| Format | Result |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
| `.pdf` | Preserves unaffected selectable text on native and mixed pages. Scans use OCR for detection and remain image content. Detected characters are deleted and matching image pixels are blanked before synthetic text is inserted; `--redact` uses black fills. Interactive forms, annotations, links and original document metadata are removed. |
|
|
127
|
+
| `.xlsx` | Fresh values-only workbook. All worksheets and hidden cells are processed; output tabs are named `Sheet1`, `Sheet2`, etc. Formulas, formatting, comments, links, drawings and original metadata are omitted. |
|
|
128
|
+
| `.csv`, `.tsv` | Properly quoted UTF-8 data with cell-level replacements. CSV uses commas; TSV uses tabs. |
|
|
129
|
+
| `.txt`, `.md`, `.log` | UTF-8 text with synthetic values, or entity labels with `--redact`. |
|
|
130
|
+
| `.json`, `.jsonl` | Valid JSON with processed keys and values. Colliding or duplicate keys are rejected. |
|
|
131
|
+
|
|
132
|
+
Excel formulas use the results saved by Excel. If a formula has no saved result,
|
|
133
|
+
the workbook fails with an instruction to recalculate and save it in Excel.
|
|
134
|
+
Numeric identifiers are scanned too; matched numbers become replacement strings.
|
|
135
|
+
Unmatched values retain their types, and text leading zeroes are preserved.
|
|
136
|
+
Custom Excel display formats such as `000000000` are not retained. Excel drawings
|
|
137
|
+
and embedded objects are omitted with a warning, rather than processed as images.
|
|
138
|
+
|
|
139
|
+
Originals are preserved. Rerunning replaces matching output files automatically;
|
|
140
|
+
you do not need to delete earlier output first. Replacement is atomic: a failed
|
|
141
|
+
rerun keeps the previous completed output. Folder reruns keep unrelated existing
|
|
142
|
+
files. Source/output overlap and symbolic links are refused.
|
|
143
|
+
|
|
144
|
+
For folders, unsupported files are skipped. Failed new files have no final output,
|
|
145
|
+
and completed files are retained. A skipped or failed file makes the command exit
|
|
146
|
+
with status `1` and report a partial run. Temporary files and new output use
|
|
147
|
+
owner-only permissions where supported.
|
|
148
|
+
|
|
149
|
+
Dutch invoice coverage includes an IBAN-field fallback for OCR spacing/character
|
|
150
|
+
confusion and a targeted name recognizer for initials and a
|
|
151
|
+
surname after `T.a.v.` or `Ter attentie van`, plus Dutch VAT ID format detection
|
|
152
|
+
(`NL_VAT`) in broad mode. The personal profile includes the name recognizer but
|
|
153
|
+
omits VAT IDs unless explicitly selected through `--entities`. These focused rules
|
|
154
|
+
help with invoice fields; arbitrary names and addresses can still be missed.
|
|
155
|
+
|
|
156
|
+
**Review output before sharing.** Detection and OCR can miss personal data or
|
|
157
|
+
replace harmless text. Faces, signatures, indirect identifiers and every kind of
|
|
158
|
+
address or sensitive fact are not comprehensively detected. Filesystem names
|
|
159
|
+
remain unchanged and may themselves identify people. Legacy `.xls`, macro-enabled
|
|
160
|
+
Office files and password-protected PDFs are not supported.
|
|
161
|
+
|
|
162
|
+
For implementation details, see [the anonymize plan](plans/anonymize-plan.md).
|
|
163
|
+
|
|
164
|
+
### List Key Vaults
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
zypp keyvault list --subscription <subscription-id>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Lists all accessible Key Vaults in the given Azure subscription.
|
|
171
|
+
|
|
172
|
+
To filter by name (case-insensitive substring match):
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
zypp keyvault list --subscription <subscription-id> --name dev
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Load secrets from Azure Key Vault
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
eval $(zypp keyvault load --vault <vault-name>)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
This fetches all enabled secrets from the specified vault and exports them as environment variables. Secret names are transformed: hyphens become underscores and the name is uppercased (e.g. `db-password` becomes `DB_PASSWORD`).
|
|
185
|
+
|
|
186
|
+
Without `eval`, the command only prints the export statements without setting them:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
zypp keyvault load --vault <vault-name>
|
|
190
|
+
# Output:
|
|
191
|
+
# export DB_PASSWORD='...'
|
|
192
|
+
# export SQL_DB='...'
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Version
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
zypp --version
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Development and checks
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
uv sync
|
|
205
|
+
uv run --no-sync zypp anonymize --setup
|
|
206
|
+
uv run --no-sync pytest
|
|
207
|
+
uv run --no-sync pytest -m integration
|
|
208
|
+
uvx prek run --all-files
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The default suite tests file handling and document adapters without spaCy models
|
|
212
|
+
or Tesseract. Integration tests require both language models, Tesseract and its
|
|
213
|
+
`nld`/`eng` packs; they exercise real detection, scans, mixed PDFs and the CLI.
|
|
214
|
+
Use `--no-sync` after setup: an exact `uv sync` removes model packages that
|
|
215
|
+
are not in the project lockfile. Run setup again if needed. CI runs both suites.
|