Repository navigation
[Test Quality] Pin --network-subnet override in isInternalAwfDomain - #11727
Conversation
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]>
There was a problem hiding this comment.
🟢 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
/24subnets, including network, broadcast, boundary, and default-subnet exclusion cases. - Verifies non-
/24CIDR 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)
|
✅ Copilot review passed with no inline comments. @github-actions[bot] Add the |
|
@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]>
Merged |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
Contract
isInternalAwfDomain(src/logs/internal-domain-filter.ts) decides which denied Squid entries are hidden fromawf logsstats and blocked-domain warnings. Its optionalnetworkSubnetargument is the effectiveawf-netsubnet for the run, taken from the policy manifest'snetworkSubnetfield and passed throughaggregateLogs/loadAndAggregate/squid-log-reader. It exists so a relocated--network-subnetrun still classifies its own containers as internal. The JSDoc states this explicitly: the override replaces the default172.30.0.0/24.Weakness
No test passed a
networkSubnetargument. I confirmed this by mutating the override branch to always use the default subnet: all 48 tests ininternal-domain-filter.test.tsandlog-aggregator.test.tsstill 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 newdescribeblock asserts:10.88.0.0/24) are internal, including the network and broadcast addresses.172.30.0.20is not internal once the subnet is relocated.10.88.1.1,10.87.255.255) are not internal.10.88.0.0/16) honours its own prefix length.No production code, manifests, or workflows changed.
Sensitivity evidence
internal-domain-filter.test.ts27/27 pass.networkSubnet(const awfNetwork = DEFAULT_AWF_NETWORK):Expected: true / Received: falsefor in-subnet IPs, andExpected: false / Received: truefor172.30.0.20). The other 24 pass.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, andbuild.ymlrunsnpm test(lines 76, 96). The new tests are discovered by that existing job and need no new wiring.Limitations