Repository navigation
network: compile policy files through public egress rules - #1298
Draft
Enrique Saurez (esaurez) wants to merge 1 commit into
Draft
Enrique Saurez (esaurez) wants to merge 1 commit into
Enrique Saurez (esaurez) wants to merge 1 commit into
Conversation
Build the existing destination and port selector values from both JSON forms, and use the native egress query for each action. Preserve field diagnostics, parsing precedence, canonical rules and resource limits without exposing the private lowerer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: be2e3770-0238-43d9-9d0a-2302f94943ff
Contributor
This pull request changes existing testsIt modifies or removes 1 existing test asset(s), listed below. Review each with care: a change to a test can hide a regression that the test caught. See doc/contribute.md#changes-to-existing-tests. Test code
Relocated unchanged: 0; added: 3. Compared the merge base |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the policy-file reader refactor.
No open issues 🎉
What changed in this PR
Refactors the policy-file reader to build public egress rules and compile them through NetworkPolicy::native_egress_rules(). This advances #1124’s separation of CLI policy parsing from private network internals without changing visibility or adding public API.
Changes:
- Routes flat and MXC JSON policies through public rule types while preserving diagnostics and compilation limits.
- Avoids redundant normalization for single destinations and removes reader-specific lowering helpers.
- Adapts the property-test helper and adds tests for public rule construction and error precedence.
| File | Description |
|---|---|
nvx-rs/src/host/network/rule.rs |
Skips redundant grouping for a single normalized destination. |
nvx-rs/src/host/network/policy/tests/properties.rs |
Converts public rules before invoking the lifted-budget test lowerer. |
nvx-rs/src/host/network/policy/tests.rs |
Adds rule-construction and diagnostic-precedence tests. |
nvx-rs/src/host/network/policy/mod.rs |
Builds public rule values and compiles actions through the public query. |
nvx-rs/src/host/network/lowering.rs |
Removes input helpers no longer needed by the reader. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1124
What and why
Build on #1293: policy files now construct the existing
public
EgressRule,Destination, andPortSelectorvalues and compileeach action through
NetworkPolicy::native_egress_rules().The reader no longer imports private address or lowering types. It retains
both flat and MXC JSON forms, CIDR spellings and exclusions, protocol and
port semantics, canonical native output, and every existing limit.
Actions still compile independently so allow errors precede deny errors.
Earlier CIDR errors retain precedence over later JSON-field errors, parsing
errors precede native-output budgets, and flat-rule diagnostics keep their
original field paths.
The public parser avoids merging a single destination that is already
normalized, preserving the existing merge-work bound. The lowerer loses
only reader-specific input helpers. There is no second compiler, new public
API, visibility change, or change to shared normalization results.
Tests
check_test_changes.pyagainst the PR base reports one modified existingtest helper and three added tests; this PR carries
tests-modified.The existing
properties::lower_liftedhelper now converts the reader'spublic rules through the existing public-rule parser before invoking its
original test-only lifted-budget lowerer. Its limit, independent reference
model, generators, canonicality/redundancy checks, packet equivalence,
action independence, and all assertions remain unchanged. No old test is
retired or weakened.
New owning-module unit tests:
both_forms_build_public_rules: both JSON forms preserve destinations,exceptions, protocol selectors, and unexpanded port ranges in public values.
cidr_errors_precede_later_json_errors: earlier malformed addresses orexclusions retain precedence and original flat/MXC field paths.
parsing_precedes_native_budgets_and_allow_precedes_deny: malformed inputwins over an already-exceeded native budget, without a partial rule
accidentally subsuming the earlier rules; allow still precedes deny.
Existing policy tests kept, by name
policy/tests.rs:policy/tests/grammar.rs:policy/tests/properties.rs:policy/tests/model.rs:policy/tests/generator.rs:policy/json/tests.rs:Validation
Qualification uses a clean local merge of this PR's unchanged head with
256ebe3dd9c23f20da94503b55d678d1193e392d. Earlier results on the originalbase are historical, not substitutes for these runs.
5190a0c10525577155e4a5446cde148475bc3b20The WHP selection comprises
directional-network-policy,host-loopback-policy,private-network-ingress,ipv6-egress-policy,l3-l4-egress-policy,l3-l4-egress-port-ranges,l3-l4-egress-protocols,network-snapshot,endpoint-policy-snapshot,untiered-network-policy,platform-network-policy,managed-exec-config,sandbox-lifecycle,sandbox-proxy-only, andsandbox-ram-upper.Windows Python commands use native CPython 3.14.9. The unittest command
uses the standalone interpreter, task-local compatible dependencies, a
physical short temporary directory, and Git's
usr\binshell on PATH.The adversarial command also uses the standalone interpreter; resolver
and help commands use a native virtual environment with the same shell
PATH. The first merged
unittest run reported a CSV replacement
WinError 5and is retained as afailed attempt, not counted as a pass. A subsequent complete run reported
two Git shell timeouts. No tests or timeouts were relaxed.
The first WHP adapter run found a copied scratch template's inherited
read-only attribute and one time-repair failure. Only the workspace copy's
attribute was corrected; the immutable input and its digest were unchanged.
Both focused checks and a new complete 156-scenario run passed. The failed
full run is retained, not counted as green.
Both CLIs, guest binaries, Alpine image and static adapter executable were
built from the merged sources. OpenVMM and kernel inputs come from
v0.1.0-dev.256ebe3dd9c2, with OpenVMM9cec2b89245f41f2126f9a787c5e43a0d84b7154. Every consumed input wasrehashed after copying; current runtime and kernel/Alpine/Ubuntu source
provenance validators passed on both platforms. No release CLI or guest
image replaced a candidate build.
CI's quality action runs only on Ubuntu (
ci.yml,qualityjob). ItsSpecula suite imports POSIX
fcntland is not applicable to native Windows.Additional Windows lint/type/format and PowerShell syntax checks passed.
KVM execution and OpenVMM's upstream suites remain with their owning CI.
This PR does not claim the complete Ubuntu/Azure Linux runtime matrix.
No manual CI run, Ready transition, or merge is requested.