Skip to content

Allow global network allowlist wildcard#15549

Open
rreichel3-oai wants to merge 4 commits intomainfrom
rreichel3/network-proxy-global-allow-wildcard
Open

Allow global network allowlist wildcard#15549
rreichel3-oai wants to merge 4 commits intomainfrom
rreichel3/network-proxy-global-allow-wildcard

Conversation

@rreichel3-oai
Copy link

Problem

Today codex-network-proxy rejects a global * in network.allowed_domains, so there is no static way to configure a denylist-only posture for public hosts. Users have to enumerate broad allowlist patterns instead.

Approach

  • Make global wildcard acceptance field-specific: allowed_domains can use *, while denied_domains still rejects a global wildcard.
  • Keep the existing evaluation order, so explicit denies still win first and local/private protections still apply unless separately enabled.
  • Add coverage for the denylist-only behavior and update the README to document it.

Validation

  • just fmt
  • cargo test -p codex-network-proxy (full run had one unrelated flaky telemetry test: network_policy::tests::emit_block_decision_audit_event_emits_non_domain_event; reran in isolation and it passed)
  • cargo test -p codex-network-proxy network_policy::tests::emit_block_decision_audit_event_emits_non_domain_event -- --exact --nocapture
  • just fix -p codex-network-proxy
  • just argument-comment-lint

Update network-proxy glob compilation and validation so the global * wildcard is accepted for allowed_domains but still rejected for denied_domains.

Add host-policy and config-state tests covering denylist-only behavior with a global allowlist wildcard, and refresh the network-proxy README to document the new mode.
Add a network-proxy regression test that starts from allowed_domains = ["*"], adds a new denied host that has no exact allowlist entry, and verifies the host is then blocked while the global allowlist remains.
Use allowlist- and denylist-specific glob compilation helpers instead of a positional boolean, and keep wildcard rejection validation only on the denylist path.
}

#[tokio::test]
async fn host_blocked_global_wildcard_allowlist_allows_public_hosts_except_denylist() {
Copy link
Author

Choose a reason for hiding this comment

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

@bolinfest this test confirms this usecase functions as expected!

for pattern in patterns {
ensure!(
!is_global_wildcard_domain_pattern(pattern),
matches!(global_wildcard, GlobalWildcard::Allow)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we deMorgan this to:

if global_wildcard == GlobalWildcard::Reject && is_global_wildcard_domain_pattern(pattern) {
  return Err(...)
}

Because then it's clearer that the error message follows from the condition.

Apply review feedback in network-proxy glob compilation by spelling the reject case as an explicit if/return Err branch instead of a negated ensure condition.
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.

2 participants