Commit 9e00767
fix: ensure consistent placeholder assignment for identical values (#283)
* fix: ensure consistent placeholder assignment for identical values in Anonymize scanner
- Check vault for existing value matches before creating new placeholders
- Reuse existing placeholder indices for known values
- Calculate next available index for new values to prevent conflicts
- Add batch consistency tracking within single processing runs
- Prevents duplicate vault entries for identical entity values
- Maintains referential integrity for proper deanonymization
Fixes issue where same entity values (e.g., "John Smith") would get
different placeholders ([REDACTED_PERSON_1], [REDACTED_PERSON_2])
across multiple scans, making consistent anonymization impossible.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* style: apply code formatting and fix performance warning in anonymize.py
- Apply ruff code formatting to improve readability
- Optimize try-except logic to avoid performance overhead in loop
- Pre-filter placeholder parts before attempting index extraction
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* test: add comprehensive test for placeholder consistency in Anonymize scanner
- Test ensures identical values get same placeholders across multiple scans
- Verifies no duplicate entries in vault for same entity values
- Confirms proper index assignment and reuse logic
- Validates referential integrity for deanonymization
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* style: apply code formatting to test assertions
Reformat multi-line assert statements to follow consistent style guidelines.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* Trigger actions: empty commit
* Empty commit to retrigger git actions
* fix space
* Disable caching and add cleanup
---------
Co-authored-by: Claude <[email protected]>1 parent 53af270 commit 9e00767
File tree
3 files changed
+140
-14
lines changed- .github/workflows
- llm_guard/input_scanners
- tests/input_scanners
3 files changed
+140
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
35 | 48 | | |
36 | 49 | | |
37 | 50 | | |
38 | 51 | | |
39 | | - | |
| 52 | + | |
| 53 | + | |
40 | 54 | | |
41 | 55 | | |
42 | 56 | | |
43 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
44 | 64 | | |
| 65 | + | |
| 66 | + | |
45 | 67 | | |
46 | 68 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
259 | 261 | | |
260 | 262 | | |
261 | 263 | | |
| |||
266 | 268 | | |
267 | 269 | | |
268 | 270 | | |
| 271 | + | |
269 | 272 | | |
270 | 273 | | |
271 | 274 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 275 | + | |
278 | 276 | | |
279 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
280 | 287 | | |
281 | | - | |
| 288 | + | |
282 | 289 | | |
283 | 290 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
288 | 325 | | |
289 | 326 | | |
290 | 327 | | |
| |||
347 | 384 | | |
348 | 385 | | |
349 | 386 | | |
| 387 | + | |
350 | 388 | | |
351 | 389 | | |
352 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
0 commit comments