feat(capture): add source/destination IP filtering to network captures - #2646
Merged
Conversation
carlotaarvela
requested review from
Mathew Merrick (matmerr) and
Vipul Singh (vipul-21)
and
a balanced review from Copilot
August 13, 2026 10:02
Contributor
There was a problem hiding this comment.
Pull request overview
Adds source/destination IP filtering for Linux and Windows captures.
Changes:
- Adds CRD fields and CLI flags for IP filtering.
- Generates BPF and netsh filter expressions.
- Adds documentation and unit tests.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/capture/crd_to_job.go |
Builds Linux and Windows filters. |
pkg/capture/crd_to_job_test.go |
Tests filter translation and job rendering. |
docs/04-Captures/03-crd.md |
Documents CRD usage. |
docs/04-Captures/02-cli.md |
Documents CLI flags. |
deploy/standard/manifests/controller/helm/retina/crds/retina.sh_captures.yaml |
Extends the CRD schema. |
crd/api/v1alpha1/zz_generated.deepcopy.go |
Deep-copies new fields. |
crd/api/v1alpha1/capture_types.go |
Defines source/destination IP fields. |
cli/cmd/capture/create.go |
Parses and validates CLI flags. |
cli/cmd/capture/create_test.go |
Tests CLI behavior. |
cli/cmd/capture/capture.go |
Adds options and errors. |
Files not reviewed (1)
- crd/api/v1alpha1/zz_generated.deepcopy.go: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Retina Code Coverage ReportTotal coverage increased from
|
| Impacted Files | Coverage | |
|---|---|---|
| cli/cmd/capture/create.go | 68.55% ... 79.65% (11.1%) |
⬆️ |
| pkg/capture/crd_to_job.go | 84.08% ... 89.56% (5.48%) |
⬆️ |
| pkg/controllers/operator/retinaendpoint/retinaendpoint_controller.go | 82.25% ... 83.28% (1.03%) |
⬆️ |
Alex Castilio (alexcastilio)
previously approved these changes
Aug 14, 2026
Alex Castilio (alexcastilio)
left a comment
Contributor
There was a problem hiding this comment.
LGTM
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 14, 2026
…om/microsoft/retina into carlota/src-dest-targeting-capture
carlotaarvela
enabled auto-merge
August 14, 2026 16:00
Alex Castilio (alexcastilio)
approved these changes
Aug 14, 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.
Description
Adds the ability to filter packet captures by source and/or destination IP address, on both Linux and Windows nodes.
CaptureOption.SourceIPs/CaptureOption.DestinationIPsfields ([]string, max 100 entries each) on theCaptureCRD.kubectl retina capture create --source-ip/--destination-ipflags (comma-separated IP lists), validated client-side against valid IP literals to prevent filter/flag injection.src host .../dst host ...) and combined with any user-supplied--pcap-filterviaand.netsh traceSourceAddress/DestinationAddressfilter groups and combined with the existing pod-IP-based filter.--tcpdump-filterflag with--source-ip/--destination-ip, since the two don't currently compose (use--pcap-filterinstead).retina.sh_captures.yaml), generated deepcopy code, and CLI/CRD docs with examples.Related Issue
Checklist
git commit -S -s ...). See this documentation on signing commits.Screenshots (if applicable) or Testing Completed
--pcap-filter, the new--tcpdump-filterincompatibility guard, and CLI CRD-population behavior.go test ./pkg/capture/... ./cli/...— all passing.Additional Notes
SourceIPs/DestinationIPsare only combinable with--pcap-filter, not the deprecated--tcpdump-filter; the CLI now returns a clear error if both are supplied together.