-
Notifications
You must be signed in to change notification settings - Fork 3.4k
policy: Do not select any identity with empty slices #29608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
policy: Do not select any identity with empty slices #29608
Conversation
7bc0a93
to
ab776e6
Compare
/test |
ab776e6
to
cbe8190
Compare
/test |
cbe8190
to
c606bc5
Compare
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you
This comment was marked as outdated.
This comment was marked as outdated.
In case of L4 ingress policies with an explicit (non-nil) empty slice in either: - fromEndpoints - fromCIDR - fromCIDRSet - fromEntities no identities should be selected, thus falling back to default deny for an allow policy. Signed-off-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
In case of L4 egress policies with an explicit (non-nil) empty slice in one of: - toEndpoints - toCIDR - toCIDRSet - toEntities no identities should be selected, thus falling back to default deny for an allow policy. Signed-off-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
Add a unit test to check that a non-nil empty ToEndpoints slice in an egress CiliumNetworkPolicy does not select any identity. Signed-off-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
Following the changes in previous commits, where the semantic of an empty non-nil slice in CNPs has been changed, an upgrade note is added to the upgrade guide. Signed-off-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
aafebcb
to
015b71b
Compare
/test |
ci-runtime failure tracked in #28415 (comment), rerunning |
👋 if this is a bug fix, do we need backports? |
As reported in ciliumGH-33432, do not skip other selectors in the case ToEndpoints is empty. For example, if the user defined a ToCIDR with an empty ToEndpoints, then getDestinationEndpointSelectorsWithRequirements() / GetSourceEndpointSelectorsWithRequirements() returns nil, causing the ToCIDRs section to be skipped. Instead, return the aggregated selectors, which aggregates selectors such as ToCIDRs, prior to the call to the aforementioned functions inside SetAggregatedSelectors(). Fixes: e97df7b ("policy: Do not select any identity with ingress empty slices") Fixes: 6ccd044 ("policy: Do not select any identity with egress empty slices") Fixes: cilium#29608 Signed-off-by: Chris Tarazi <chris@isovalent.com>
As reported in ciliumGH-33432, do not skip other selectors in the case ToEndpoints is empty. For example, if the user defined a ToCIDR with an empty ToEndpoints, then getDestinationEndpointSelectorsWithRequirements() / GetSourceEndpointSelectorsWithRequirements() returns nil, causing the ToCIDRs section to be skipped. Instead, return the aggregated selectors, which aggregates selectors such as ToCIDRs, prior to the call to the aforementioned functions inside SetAggregatedSelectors(). Fixes: e97df7b ("policy: Do not select any identity with ingress empty slices") Fixes: 6ccd044 ("policy: Do not select any identity with egress empty slices") Fixes: cilium#29608 Signed-off-by: Chris Tarazi <chris@isovalent.com>
As reported in ciliumGH-33432, do not skip other selectors in the case ToEndpoints is empty. For example, if the user defined a ToCIDR with an empty ToEndpoints, then getDestinationEndpointSelectorsWithRequirements() / GetSourceEndpointSelectorsWithRequirements() returns nil, causing the ToCIDRs section to be skipped. Instead, return the aggregated selectors, which aggregates selectors such as ToCIDRs, prior to the call to the aforementioned functions inside SetAggregatedSelectors(). Fixes: e97df7b ("policy: Do not select any identity with ingress empty slices") Fixes: 6ccd044 ("policy: Do not select any identity with egress empty slices") Fixes: cilium#29608 Signed-off-by: Chris Tarazi <chris@isovalent.com>
This PR aims to redefine the semantic of a non-nil empty slice in CNP/CCNP. Specifically, In case of egress/ingress policies with an explicit (non-nil) empty slice in one of:
no identities should be selected, thus falling back to default deny for an allow policy.
An example of the different behavior introduced with this PR can be seen with the following two L4 ingress policies:
The first one, with an explicit empty
fromCIDR
slice, does not select any identity (thus resulting in default deny) while the second one keeps the current behavior and allow traffic to port 80 for all identities.This behavior also fixes a bug in policies referencing a CiliumCIDRGroup in the
fromCIDRSet/cidrGroupRef
field. If the referenced CIDR Group is empty or non-existent, the policy is equivalent to the first one, and therefore it won't select any identities.