Skip to content
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

Validation of group as a stand-alone selector is not comprehensive #3084

Closed
GraysonWu opened this issue Dec 3, 2021 · 2 comments · Fixed by #3104
Closed

Validation of group as a stand-alone selector is not comprehensive #3084

GraysonWu opened this issue Dec 3, 2021 · 2 comments · Fixed by #3104
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@GraysonWu
Copy link
Contributor

Describe the bug
Within an ingress or egress rule, group cannot be used with any other selectors. But we only checked if group is used with podSelector, namespaceSelector, and IPBlock. So if users use group with other selectors such as fqdn, the policy will have unexpected behavior.

https://github.com/antrea-io/antrea/blob/main/pkg/apis/crd/v1alpha1/types.go#L425-L429
https://github.com/antrea-io/antrea/blob/main/pkg/controller/networkpolicy/validate.go#L473

To Reproduce
Create an Antrea-native network policy like below:

apiVersion: crd.antrea.io/v1alpha1
kind: ClusterNetworkPolicy
metadata:
  name: acnp-test
spec:
    priority: 5
    tier: SecurityOps
    appliedTo:
      - podSelector:
          matchLabels:
            app: client
    egress:
      - action: Drop
        to:
          - group: group-a
            fqdn: google.com

Pods with label app: client still can access google.com.

@GraysonWu GraysonWu added the kind/bug Categorizes issue or PR as related to a bug. label Dec 3, 2021
@GraysonWu
Copy link
Contributor Author

I'm thinking if we could use open API to control the relation between those fields instead of using validating webhook?

@GraysonWu
Copy link
Contributor Author

Didn't find a good way to solve it via API design. Mainly blocked by this rule.

Open a PR solving it by making our validating webhook more comprehensive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant