Skip to content

feat: add active network policy probe - #205

Merged
shreyanshjain7174 merged 1 commit into
mainfrom
feat/networkpolicy-active-probe
Sep 4, 2026
Merged

shreyanshjain7174 merged 1 commit into
mainfrom
feat/networkpolicy-active-probe

Conversation

@shreyanshjain7174

Copy link
Copy Markdown
Collaborator

Summary

  • Add passive agentctl doctor network-policy CNI detection.
  • Add explicit --active-probe packet test in a scratch namespace.
  • Require an updated operator image and clean up probe resources by default.

Safety

  • Passive mode makes no mutations.
  • Active mode requires --active-probe and --probe-image.
  • Known non-enforcing CNI fingerprints require an explicit override.
  • The verdict only covers the scratch-namespace probe policy.

Validation

  • go build ./...
  • make test-go
  • make lint
  • go test ./internal/netpolicy ./internal/netpolicy/netprobe ./cmd/agentctl
  • helm unittest charts
  • helm lint charts

go test ./... remains locally blocked only by missing envtest etcd assets.

Copilot AI lite review requested due to automatic review settings September 3, 2026 10:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are a few correctness and operability issues (error reporting and probe reliability assumptions) that should be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds an agentctl doctor network-policy command that can passively fingerprint likely NetworkPolicy enforcement, or run an opt-in active probe that creates a scratch namespace, runs a TCP control dial, applies a deny-egress policy, then re-tests connectivity.

Changes:

  • Add active NetworkPolicy probe logic and supporting netprobe runner.
  • Wire agentctl doctor network-policy and document passive vs active modes.
  • Add an operator binary entrypoint mode to run netprobe inside the operator image.
File summaries
File Description
README.md Mentions the new doctor command and active probe mode.
internal/netpolicy/probe.go Implements the scratch-namespace active probe and result classification.
internal/netpolicy/probe_test.go Unit tests for probe refusal paths, verdict classification, and restricted pod settings.
internal/netpolicy/netprobe/runner.go Implements netprobe serve and netprobe dial with distinct exit codes.
internal/netpolicy/netprobe/runner_test.go Tests for dial success, DNS failure classification, and arg validation.
docs/10-troubleshooting.md Documents how to run the passive and active NetworkPolicy checks.
docs/07-security.md Documents probe permissions and probe scope limits.
cmd/main.go Adds a netprobe fast-path to run the embedded probe command in the operator binary.
cmd/agentctl/doctor_sandbox.go Adds the doctor network-policy Cobra subcommand and output formatting.
cmd/agentctl/doctor_sandbox_test.go Adds tests for the new subcommand and passive behavior.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/agentctl/doctor_sandbox.go
Comment thread internal/netpolicy/probe.go
Comment thread internal/netpolicy/probe.go
Comment thread internal/netpolicy/probe.go
Signed-off-by: Shreyansh Sancheti <43677304+shreyanshjain7174@users.noreply.github.com>
@shreyanshjain7174
shreyanshjain7174 force-pushed the feat/networkpolicy-active-probe branch from f83721b to 738a425 Compare September 3, 2026 13:19
@shreyanshjain7174
shreyanshjain7174 merged commit 6f2635e into main Sep 4, 2026
6 checks passed
@shreyanshjain7174
shreyanshjain7174 deleted the feat/networkpolicy-active-probe branch September 24, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants