Skip to content

[Test Quality] test: pin wildcard blocklist deny ahead of protocol allow rules - #11992

Merged
lpcox merged 1 commit into
mainfrom
test-quality/blocklist-wildcard-precedence-20261123-dbd18c6c270fae0e
Nov 23, 2026
Merged

lpcox merged 1 commit into
mainfrom
test-quality/blocklist-wildcard-precedence-20261123-dbd18c6c270fae0e

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Contract

Squid applies the first matching http_access line. A --block-domains wildcard entry (*.secret.example.com) must be denied before any protocol-specific allow rule that would otherwise match the subdomain. Documented in docs/usage.md (--block-domains: "takes precedence over allowed domains. Supports wildcards") and docs/test-analysis/domain-network.md item 2 ("block-overrides-allow precedence").

Emission order is produced by src/squid/access-rules.ts generateAccessRulesSection(): blocked deny rules, then # Protocol-specific domain access rules, then the catch-all deny.

Previous weakness and missed regression

src/squid-config-blocklist.test.ts only checked ordering for the plain blocked deny, by comparing against the catch-all http_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 wildcard http_access deny blocked_domains_regex line falls.

I confirmed the gap with a temporary mutation to src/squid/access-rules.ts that keeps the plain blocked deny in place but moves only the blocked_domains_regex deny after the protocol allows. The real emitted config then reads allow CONNECT allowed_https_only (line 123) before deny 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: with domains: ['(example.com/redacted)'] and blockedDomains: ['*.secret.example.com'], it asserts the exact line http_access deny blocked_domains_regex precedes http_access allow CONNECT allowed_https_only. Test-only change; no production code, fixtures, or workflows touched.

Validation

  • Baseline and changed run: ./node_modules/.bin/jest --runInBand --no-coverage --runTestsByPath src/squid-config-blocklist.test.ts → 11/11 pass with the change.
  • Sensitivity: with the wildcard-ordering mutation reapplied, the new test fails on the intended assertion: 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.
  • Full root Jest run: 11 suites fail both with and without this change (identical failing set, e.g. src/enclave/mount-policy.test.ts TypeError: 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.ts is a root Jest unit test. Root Jest runs via npm test / npm run test:unit in the existing build.yml job (Run unit tests) and root-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 generated squid.conf text; 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.

Generated by Test Quality Improver · copilot · routed: haiku55 xhigh · ~39 AIC · ⌖ ~2 AIC · ⊞ 5.4K · ◷

  • expires on Dec 23, 2026, 12:56 PM UTC

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]>
@lpcox
lpcox marked this pull request as ready for review November 23, 2026 15:55
Copilot AI adaptive review requested due to automatic review settings November 23, 2026 15:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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)

@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Copilot review passed with no inline comments.

@github-actions[bot] Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@lpcox

lpcox commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Copilot AI commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@copilot fix this failing ci check https://github.com/github/gh-aw-firewall/actions/runs/45179117335/job/137822981216?pr=11992

The check failed during npm ci in containers/api-proxy with a package-registry ECONNRESET; tests did not run. I requested one retry of the failed workflow run (45179117335). No code change is needed for this transient network failure.

Copilot AI requested a review from lpcox November 23, 2026 16:34
@lpcox
lpcox merged commit 59647a8 into main Nov 23, 2026
41 of 44 checks passed
@lpcox
lpcox deleted the test-quality/blocklist-wildcard-precedence-20261123-dbd18c6c270fae0e branch November 23, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants