Repository navigation
[Test Quality] Pin Slack user token (xoxp-) DLP detection and length bounds - #11584
Conversation
The built-in DLP pattern for Slack user OAuth tokens had no test anywhere in the repository. Breaking its regex, in either direction (fail-open or broadened), left all DLP tests green. Add a positive case at the minimum and maximum digit-group lengths and a negative case for out-of-bounds digit groups and hex length. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The changes are limited to targeted Slack user-token DLP boundary regression tests, with no production logic changes or unresolved review concerns identified.
No open issues 🎉
What changed in this PR
Adds focused regression coverage for the Slack user OAuth token (xoxp-) DLP pattern, strengthening detection and length-bound testing without changing production logic.
Changes:
- Adds positive tests for minimum and maximum numeric-group lengths.
- Adds negative tests for undersized hexadecimal and numeric components.
- Verifies matching behavior against the generated DLP regex patterns.
| File | Description |
|---|---|
| src/dlp.test.ts | Adds positive, negative, and boundary regression tests for Slack user token DLP detection. |
Review effort: Lite (dynamic)
|
✅ Copilot review passed with no inline comments. @github-actions[bot] Add the |
|
@copilot fix this failing ci check. 'npm test' must not have any failures https://github.com/github/gh-aw-firewall/actions/runs/43595984665/job/132567960986?pr=11584 |
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Fixed the stale dispatcher manifest assertion to check |
Contract
src/dlp.tsdefines the built-in DLP credential patterns that--enable-dlpcompiles into Squidurl_regexdeny ACLs (documented indocs/usage.mdunder--enable-dlp, and in thedlp.tsheader: "Match the distinctive prefix of each credential type... Require enough characters after the prefix"). The Slack user OAuth token pattern (xoxp-) is one of those contract entries.Weakness
The
xoxp-pattern had no test anywhere in the repository. Every other built-in pattern has at least one positive-detection assertion insrc/dlp.test.ts;xoxp-had none.Verified on the unchanged baseline: breaking the regex in either direction left all DLP tests green.
{32}→{33}, so real 32-hex tokens stop matching): 38/38 pass.A regression there silently removes detection of a real credential type from the exfiltration guard.
Change (test-only)
src/dlp.test.ts, +25 lines, no production code touched:it.eachat minimum (10-digit) and maximum (13-digit) group lengths, asserting the exactxoxp-pattern is among the matched regexes for a realistic token shape.xoxp-pattern. Written behaviorally (some(regex => regex.startsWith('xoxp-'))) so it detects broadening, not only removal of the original string.Regression sensitivity (before/after)
Temporary mutations to
src/dlp.ts, each restored and verified clean withgit diff --quiet:dlp.test.ts){32}→{33}{10,13}→{9,13}Each mutant fails for the intended assertion, not setup or syntax.
Validation
./node_modules/.bin/jest --runInBand --no-coverage --runTestsByPath src/dlp.test.ts src/squid-config-dlp.test.ts src/squid/config-sections.test.ts src/squid/api-proxy-upstreams.test.ts→ 4 suites, 98/98 pass.jest --listTestsincludessrc/dlp.test.tsunder the root config (roots: src)..github/workflows/root-unit-tests.ymlrunsnpm teston every PR.npx tsc --noEmit -p tsconfig.json→ exit 0.npx eslint src/dlp.test.ts→ 0 errors; the 3 warnings are pre-existing and unchanged.Notes / limits
url_regex(that needs a running proxy, which this sandbox cannot provide). It checks the generated regex text and its matching behavior, as the existing DLP tests do.squid.conf(deny at thedlp_blockedline, ahead of!allowed_domains). Existing tests already pin it; no change made there.