llm-guard icon indicating copy to clipboard operation
llm-guard copied to clipboard

feat: add vault support to Regex scanner for redacted value storage

Open AnandShivansh opened this issue 3 months ago • 0 comments

Similar to the Anonymizer scanner, the Regex scanner now supports storing redacted values in a vault for later deanonymization. When a vault is provided, matched patterns are replaced with unique placeholders like [REDACTED_REGEX_1], [REDACTED_REGEX_2], etc., and the original values are stored in the vault.

Key changes:

  • Add optional vault parameter to both input and output Regex scanners
  • Store matched regex patterns in vault with unique indexed placeholders
  • Maintain backward compatibility when no vault is provided (uses [REDACTED])
  • Update llm_guard_api scanner configuration to pass vault to Regex scanners
  • Implement proper counter management to avoid placeholder conflicts

Change Description

Describe your changes

Issue reference

This PR fixes issue #XX

Checklist

  • [x] I have reviewed the contribution guidelines
  • [x] My code includes unit tests
  • [x] All unit tests and lint checks pass locally
  • [x] My PR contains documentation updates / additions if required

AnandShivansh avatar Sep 05 '25 09:09 AnandShivansh