Repository navigation
feat(ressrf): expose the deny CIDR set for callers to mirror the gate - #36
Merged
Merged
Conversation
Add Policy.DeniedIPPrefixes() returning the network-layer deny ranges (PresetExternalOnly default set plus WithCloudProviderDenies and WithDeniedCIDRs entries; nil for PresetNone/InternalOnly), and CIDR.NativePrefix() to return IPv4 ranges in native 4-byte form rather than the IPv4-mapped form the matcher stores internally. A consumer that must mirror the gate at another layer (e.g. a Kubernetes NetworkPolicy egress except-list) can derive it from the policy instead of hand-maintaining a parallel CIDR list that drifts. denied_prefixes_test.go pins the invariant that the exported set equals what IsNetworkAllowed enforces.
…nimal A metadata IP that lives in both the built-in deny set and a cloud-provider module (169.254.169.254/32, 169.254.170.2/32, fd00:ec2::254/128 under PresetExternalOnly + WithCloudProviderDenies(CloudAWS)) was returned twice, so a NetworkPolicy except-list derived from DeniedIPPrefixes() carried duplicate entries that some API servers reject. De-duplicate in first-seen order; add a no-duplicate assertion to TestDeniedIPPrefixes.
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.
A consumer enforcing the same policy at the network layer (e.g. a Kubernetes NetworkPolicy egress except-list) must block the same IP ranges the application-layer dial gate enforces, but there was no way to read a policy's deny set, so it had to hand-maintain a parallel CIDR list that silently drifts from the gate.
Adds
Policy.DeniedIPPrefixes()returning the network-layer deny ranges in native form (IPv4 asIs4prefixes via the newCIDR.NativePrefix(), not the IPv4-mapped form the matcher stores internally), so a caller rendering a Kubernetes NetworkPolicy egress except-list can derive it from the policy.denied_prefixes_test.gopins the invariant that the exported set equals whatIsNetworkAllowedenforces, so the network-layer block list and the dial gate can't drift apart.The exported set is the raw deny set, de-duplicated;
WithAllowedCIDRsis not subtracted (documented on the method).PresetExternalOnlyreturns the built-in deny set plus any cloud-provider and user-supplied denies;PresetNoneandPresetInternalOnlyreturn nil.