Repository navigation
[Test Quality] test: pin wildcard blocklist deny ahead of protocol allow rules - #11992
Conversation
Squid applies the first matching http_access line. The blocklist suite only checked ordering for plain blocked domains, so moving the blocked_domains_regex deny after the protocol-specific allow rules passed every test. Add a case that asserts the wildcard deny precedes 'allow CONNECT allowed_https_only' when the parent domain is allowed over HTTPS. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active issues are reported, and the focused regression coverage checks the required blocklist-before-allow ordering without altering production code.
No open issues 🎉
What changed in this PR
This PR strengthens unit-test coverage for Squid access-rule ordering, ensuring wildcard blocklist denies are emitted before protocol-specific allow rules and preserving documented block-overrides-allow behavior.
Changes:
- Adds a regression test for wildcard blocklist precedence over HTTPS-only allow rules.
- Verifies the exact generated configuration lines appear in the required order.
- Leaves production code and existing tests unchanged.
| File | Description |
|---|---|
| src/squid-config-blocklist.test.ts | Adds regression coverage confirming the wildcard blocklist deny rule precedes the protocol-specific HTTPS allow rule. |
Review effort: Lite (adaptive)
|
✅ Copilot review passed with no inline comments. @github-actions[bot] Add the |
The check failed during |
Contract
Squid applies the first matching
http_accessline. A--block-domainswildcard entry (*.secret.example.com) must be denied before any protocol-specific allow rule that would otherwise match the subdomain. Documented indocs/usage.md(--block-domains: "takes precedence over allowed domains. Supports wildcards") anddocs/test-analysis/domain-network.mditem 2 ("block-overrides-allow precedence").Emission order is produced by
src/squid/access-rules.tsgenerateAccessRulesSection(): blocked deny rules, then# Protocol-specific domain access rules, then the catch-all deny.Previous weakness and missed regression
src/squid-config-blocklist.test.tsonly checked ordering for the plain blocked deny, by comparing against the catch-allhttp_access deny !allowed_domains. That anchor always sits after the protocol allows, so the check never reached the protocol-allow boundary. No test checked where the wildcardhttp_access deny blocked_domains_regexline falls.I confirmed the gap with a temporary mutation to
src/squid/access-rules.tsthat keeps the plain blocked deny in place but moves only theblocked_domains_regexdeny after the protocol allows. The real emitted config then readsallow CONNECT allowed_https_only(line 123) beforedeny blocked_domains_regex(line 125). All 99 tests in the blocklist, access-rules, policy, DLP, and security suites still passed under that mutation, so a blocked wildcard host under an allowed parent would have been let through by Squid.Change
One new unit test in
src/squid-config-blocklist.test.ts: withdomains: ['(example.com/redacted)']andblockedDomains: ['*.secret.example.com'], it asserts the exact linehttp_access deny blocked_domains_regexprecedeshttp_access allow CONNECT allowed_https_only. Test-only change; no production code, fixtures, or workflows touched.Validation
./node_modules/.bin/jest --runInBand --no-coverage --runTestsByPath src/squid-config-blocklist.test.ts→ 11/11 pass with the change.Expected: < 106,Received: 108. Mutation then reverted; the file was verified clean.npx eslint src/squid-config-blocklist.test.ts→ exit 0.tsc --noEmit -p tsconfig.json→ exit 0.src/enclave/mount-policy.test.tsTypeError: The "path" argument must be of type string ... Received undefined). These are sandbox/environment failures, unrelated to Squid config; none are introduced by this PR.Discovery in CI
src/squid-config-blocklist.test.tsis a root Jest unit test. Root Jest runs vianpm test/npm run test:unitin the existingbuild.ymljob (Run unit tests) androot-unit-tests.yml, so it is discovered and executed there.Limitations
Docker is unavailable in this sandbox, so integration suites (
tests/integration/) were not run. This is a process-level unit assertion on generatedsquid.conftext; it does not prove real Squid enforcement. Squid itself was not available to parse the config.Removed or consolidated tests
None removed. The existing plain-domain ordering test is retained unchanged.