Split DLP detector-config parsing into its own module #291

Open
didericis-claude wants to merge 1 commits from decompose-egress-dlp-config into main
Collaborator

Closes #287.

Summary

bot_bottle/egress_addon_core.py (862 LOC) mixed the per-route dlp: block parser — _parse_detectors plus the detector-name frozensets and outbound_on_match policy constants — in with the request-time scan/decision flow.

This moves that config-parsing layer into a new stdlib-only bot_bottle/egress_dlp_config.py as parse_dlp_block, so the decision path in the core module reads top-to-bottom without scrolling past config plumbing.

Compatibility

  • The detector-name frozensets, ON_MATCH_* constants, OUTBOUND_ON_MATCH_VALUES, DEFAULT_OUTBOUND_ON_MATCH, and parse_dlp_block are re-exported from egress_addon_core (and listed in its __all__), so existing from egress_addon_core import … callers (egress_addon.py, egress.py, tests) are unchanged.
  • The new module ships flat into the sidecar bundle (added to Dockerfile.sidecars) and uses the same flat/package import shim as its siblings; both import paths are verified.
  • Pure refactor — behavior and YAML wire format unchanged.

Full unit suite (1297 tests) passes; pyright clean; pylint 10.00 on the changed files.

Closes #287. ## Summary `bot_bottle/egress_addon_core.py` (862 LOC) mixed the per-route `dlp:` block parser — `_parse_detectors` plus the detector-name frozensets and `outbound_on_match` policy constants — in with the request-time scan/decision flow. This moves that config-parsing layer into a new stdlib-only `bot_bottle/egress_dlp_config.py` as `parse_dlp_block`, so the decision path in the core module reads top-to-bottom without scrolling past config plumbing. ## Compatibility - The detector-name frozensets, `ON_MATCH_*` constants, `OUTBOUND_ON_MATCH_VALUES`, `DEFAULT_OUTBOUND_ON_MATCH`, and `parse_dlp_block` are re-exported from `egress_addon_core` (and listed in its `__all__`), so existing `from egress_addon_core import …` callers (`egress_addon.py`, `egress.py`, tests) are unchanged. - The new module ships flat into the sidecar bundle (added to `Dockerfile.sidecars`) and uses the same flat/package import shim as its siblings; both import paths are verified. - Pure refactor — behavior and YAML wire format unchanged. Full unit suite (1297 tests) passes; pyright clean; pylint 10.00 on the changed files.
didericis-claude added 1 commit 2026-06-25 19:35:55 -04:00
refactor(egress): split DLP detector-config parsing into its own module
lint / lint (push) Successful in 1m50s
test / unit (pull_request) Successful in 45s
test / integration (pull_request) Successful in 19s
1659f738ef
`egress_addon_core.py` mixed the per-route `dlp:` block parser
(`_parse_detectors` plus the detector-name and `outbound_on_match`
constants) in with the request-time scan/decision flow. Move that
config-parsing layer into a new stdlib-only `egress_dlp_config.py` as
`parse_dlp_block`, so the decision path in the core module reads
top-to-bottom without scrolling past config plumbing.

The constants and parser are re-exported from `egress_addon_core`
(and listed in `__all__`) so existing `from egress_addon_core import
ON_MATCH_*` / `OUTBOUND_DETECTOR_NAMES` callers are unchanged. The new
module ships flat into the sidecar bundle (Dockerfile.sidecars) and
uses the same flat/package import shim as its siblings. Pure refactor;
behavior and wire format unchanged.

Closes #287

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NkwFXLFff9PYPy4wgVBJp9
Some checks are pending
lint / lint (push) Successful in 1m50s
test / unit (pull_request) Successful in 45s
test / integration (pull_request) Successful in 19s
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin decompose-egress-dlp-config:decompose-egress-dlp-config
git checkout decompose-egress-dlp-config
Sign in to join this conversation.