Skip to content

[Test Quality] Pin --network-subnet override in isInternalAwfDomain - #11727

Merged
lpcox merged 2 commits into
mainfrom
test-quality/internal-domain-subnet-override-94c9f91628cebd96
Nov 17, 2026
Merged

lpcox merged 2 commits into
mainfrom
test-quality/internal-domain-subnet-override-94c9f91628cebd96

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Contract

isInternalAwfDomain (src/logs/internal-domain-filter.ts) decides which denied Squid entries are hidden from awf logs stats and blocked-domain warnings. Its optional networkSubnet argument is the effective awf-net subnet for the run, taken from the policy manifest's networkSubnet field and passed through aggregateLogs / loadAndAggregate / squid-log-reader. It exists so a relocated --network-subnet run still classifies its own containers as internal. The JSDoc states this explicitly: the override replaces the default 172.30.0.0/24.

Weakness

No test passed a networkSubnet argument. I confirmed this by mutating the override branch to always use the default subnet: all 48 tests in internal-domain-filter.test.ts and log-aggregator.test.ts still passed. A regression that ignores the override would ship silently, and on a relocated run it would either leak container denials into reports or hide real external denials.

Change

Test-only, one file (src/logs/internal-domain-filter.test.ts, +38 lines). A new describe block asserts:

  • IPs inside the relocated subnet (10.88.0.0/24) are internal, including the network and broadcast addresses.
  • 172.30.0.20 is not internal once the subnet is relocated.
  • Boundary neighbours (10.88.1.1, 10.87.255.255) are not internal.
  • A non-/24 override (10.88.0.0/16) honours its own prefix length.
  • With no override, the default behaviour is unchanged.
  • Single-label and topology-peer checks still apply alongside a relocated subnet.

No production code, manifests, or workflows changed.

Sensitivity evidence

  • Baseline (unchanged code): internal-domain-filter.test.ts 27/27 pass.
  • Temporary mutation that ignores networkSubnet (const awfNetwork = DEFAULT_AWF_NETWORK):
    • Before this PR: 48/48 pass (gap shown).
    • With this PR: 3 fail on the intended assertions (Expected: true / Received: false for in-subnet IPs, and Expected: false / Received: true for 172.30.0.20). The other 24 pass.
  • Production file restored; mutation was not committed.
  • Final clean run: internal-domain-filter.test.ts + log-aggregator.test.ts, 54/54 pass.
  • npx eslint src/logs/internal-domain-filter.test.ts: exit 0.

Discovery in CI

Root Jest runs src/**/*.test.ts, and build.yml runs npm test (lines 76, 96). The new tests are discovered by that existing job and need no new wiring.

Limitations

  • Unit-level only. This validates the classification logic, not real Squid, iptables, or Docker enforcement, which needs Docker and was not available in this sandbox.
  • No tests removed or consolidated.

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

  • expires on Dec 17, 2026, 12:39 PM UTC

The awf-net subnet override is threaded from the policy manifest into
isInternalAwfDomain, deciding which denied IPs are hidden from reports.
No test passed a subnet argument, so ignoring the override passed the
whole suite. Add tests that a relocated subnet classifies its own IPs as
internal, stops classifying the default 172.30.0.0/24, respects prefix
length, and leaves the default unchanged when no override is given.

Co-authored-by: Copilot <[email protected]>
@lpcox
lpcox marked this pull request as ready for review November 17, 2026 18:39
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 18:39

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

The review identifies no active issues, and the added tests cover relocated subnet overrides, CIDR boundaries, fallback behavior, and hostname classification.

No open issues 🎉

What changed in this PR

This test-only PR strengthens unit coverage for isInternalAwfDomain by verifying that relocated --network-subnet overrides are honored while preserving default subnet and hostname-based classification behavior.

Changes:

  • Adds coverage for relocated /24 subnets, including network, broadcast, boundary, and default-subnet exclusion cases.
  • Verifies non-/24 CIDR handling and fallback behavior without an override.
  • Confirms topology-peer and single-label hostname checks remain effective with a relocated subnet.
File Description
src/​logs/​internal-domain-filter.test.ts Adds regression tests for relocated subnet overrides, CIDR boundaries, default fallback behavior, and related hostname classification.

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 17, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and resolve conflicts then make sure all review feedback has been addressed

…-domain-subnet-override-94c9f91628cebd96

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

@copilot merge main and resolve conflicts then make sure all review feedback has been addressed

Merged main cleanly with no conflicts. The merge commit is 46788b8; the subnet regression tests remain intact. I attempted the targeted test, but dependency installation was blocked by registry resolution/404 errors and the available Node version is below several locked packages’ requirements.

Copilot AI requested a review from lpcox November 17, 2026 20:00
@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 94.18% 94.19% ➡️ +0.01%
Statements 92.80% 92.81% 📈 +0.01%
Functions 93.37% 93.37% ➡️ +0.00%
Branches 87.16% 87.18% 📈 +0.02%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/nvx/one-shot-process.ts 81.5% → 84.0% (+2.47%) 74.7% → 76.8% (+2.11%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@lpcox
lpcox merged commit d62b31f into main Nov 17, 2026
40 of 41 checks passed
@lpcox
lpcox deleted the test-quality/internal-domain-subnet-override-94c9f91628cebd96 branch November 17, 2026 21:55
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