Make DLP_PATTERNS internal and decouple tests from module internals#3398
Conversation
DLP_PATTERNS internal and decouple tests from module internals
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR reduces public API surface in the security-sensitive DLP module by making DLP_PATTERNS internal-only, and updates unit tests to validate behavior via generateDlpSquidConfig() output rather than importing internal module constants.
Changes:
- Removed the
exportfromDLP_PATTERNSinsrc/dlp.tsto avoid exposing internal pattern definitions. - Refactored
src/dlp.test.tsto derive regexes fromgenerateDlpSquidConfig().aclLinesand assert representative credential-detection behavior.
Show a summary per file
| File | Description |
|---|---|
| src/dlp.ts | Makes DLP_PATTERNS internal to reduce exported API surface. |
| src/dlp.test.ts | Updates tests to validate generated ACL patterns and matching behavior without importing DLP_PATTERNS. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 3
| * - Avoid overly broad patterns that would block legitimate traffic | ||
| */ | ||
| export const DLP_PATTERNS: DlpPattern[] = [ | ||
| const DLP_PATTERNS: DlpPattern[] = [ |
| const DLP_ACL_PREFIX = 'acl dlp_blocked url_regex -i '; | ||
|
|
||
| function getDlpRegexPatterns(): string[] { | ||
| const { aclLines } = generateDlpSquidConfig(); | ||
| return aclLines | ||
| .filter(line => line.startsWith(DLP_ACL_PREFIX)) | ||
| .map(line => line.slice(DLP_ACL_PREFIX.length)); |
| function scanForCredentialsUsingPatterns(input: string): string[] { | ||
| return DLP_PATTERNS | ||
| .filter(pattern => new RegExp(pattern.regex, 'i').test(input)) | ||
| .map(pattern => pattern.name); | ||
| return getDlpRegexPatterns().filter(regex => new RegExp(regex, 'i').test(input)); | ||
| } |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback |
Addressed in
|
Smoke Test Results✅ GitHub API: 2 PR entries found PASS — All smoke tests passed.
|
🔥 Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Author: Overall: PASS (core BYOK path verified ✅)
|
🔬 Smoke Test Results
PR: Make Overall: PARTIAL — MCP ✅, pre-step smoke data was not injected (template variables unexpanded).
|
|
Smoke test: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Smoke Test Results
Overall Status: FAIL PR titles found: #3385 (only one in shallow history) Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Chroot Smoke Test Results
Result: FAILED — Python and Node.js versions differ between host and chroot environment.
|
Smoke Test Results
Overall: FAIL
|
src/dlp.tsexposedDLP_PATTERNSas a public export even though it is only used internally bygenerateDlpSquidConfig(). This created unnecessary API surface in a security-critical module and test coupling to implementation details.API surface reduction
exportfromDLP_PATTERNSinsrc/dlp.ts.Test strategy update (behavior over internals)
src/dlp.test.tsto stop importingDLP_PATTERNS.generateDlpSquidConfig().aclLines.Scope of change