feat(enforcer): Add tld & subdomain enforcement#2618
Merged
Conversation
ede79d6 to
5d5e46d
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends DNS query enforcement to support matching subdomains and higher-level suffixes (e.g., allowing a policy for google.com to match www.google.com, and enabling TLD-style matching), primarily for the BPFLSM enforcer path, and adds an e2e test case covering subdomain blocking.
Changes:
- Add suffix-based DNS domain matching in the Go-side policy matcher to treat subdomains/TLDs as matches.
- Update the BPF enforcer’s DNS rule matching to search for matching parent-domain suffixes using a scratch buffer.
- Add a new Kubernetes policy YAML + network test to validate blocking DNS queries for subdomains.
Reviewed changes
Copilot reviewed 6 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/k8s_env/networktests/res/ksp-ubuntu-1-block-dns-subdomain.yaml |
Adds a KubeArmorPolicy used to validate subdomain DNS blocking behavior. |
tests/k8s_env/networktests/network_test.go |
Adds an e2e test asserting DNS blocking for www.google.com when the policy targets google.com. |
KubeArmor/feeder/policyMatcher.go |
Extends DNS matching logic to consider suffixes (subdomains/TLD-like matches) when correlating logs to policies. |
KubeArmor/enforcer/bpflsm/rulesHandling.go |
Normalizes DNS domains by trimming leading/trailing dots before mapping rules. |
KubeArmor/BPF/shared.h |
Adds MAX_NESTED_DNS_LABELS and increases bufk capacity for new scratch usage. |
KubeArmor/BPF/enforcer.bpf.c |
Implements iterative parent-domain matching for DNS lookups and introduces a scratch pad buffer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Aryan-sharma11
requested changes
Jun 9, 2026
Aryan-sharma11
approved these changes
Jun 9, 2026
Aryan-sharma11
approved these changes
Jun 10, 2026
Signed-off-by: Achref Ben Saad <[email protected]>
Signed-off-by: Achref Ben Saad <[email protected]>
Signed-off-by: Aryan-sharma11 <[email protected]> Signed-off-by: Achref Ben Saad <[email protected]>
Co-authored-by: Aryan Sharma <[email protected]> Signed-off-by: Achref Ben Saad <[email protected]>
charankamal20
approved these changes
Jun 14, 2026
Merged
Aryan-sharma11
added a commit
to Aryan-sharma11/KubeArmor
that referenced
this pull request
Jun 18, 2026
Signed-off-by: Aryan-sharma11 <[email protected]>
achrefbensaad
added a commit
that referenced
this pull request
Jun 19, 2026
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.
Purpose of PR?:
Fixes #
Does this PR introduce a breaking change?
If the changes in this PR are manually verified, list down the scenarios covered::
Additional information for reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs
Checklist:
<type>(<scope>): <subject>