Skip to content

ROX-33673: Add missing OOTB egress network policy#19524

Open
AlexVulaj wants to merge 1 commit intomasterfrom
AlexVulaj/ROX-33673-ootb-policy-egress
Open

ROX-33673: Add missing OOTB egress network policy#19524
AlexVulaj wants to merge 1 commit intomasterfrom
AlexVulaj/ROX-33673-ootb-policy-egress

Conversation

@AlexVulaj
Copy link
Contributor

Description

This PR adds a missing OOTB policy to detect deployments that lack egress network policies. While StackRox added network policy detection capabilities and shipped the "Deployments should have at least one ingress Network Policy" policy (ID: 38bf79e7-48bf-4ab1-b72f-38e8ad8b4ec3) several versions ago, the corresponding egress policy was never created despite the underlying field support existing in the codebase.

The new policy "Deployments should have at least one egress Network Policy" (ID: dae95df3-ce8e-435c-8e16-c5197943db6e) mirrors the structure and behavior of its ingress counterpart. It alerts when deployments are missing egress network policies, helping enforce zero-trust networking principles by identifying workloads with unrestricted outbound network access that could potentially exfiltrate data or communicate with untrusted endpoints.

Related JIRA: https://redhat.atlassian.net/browse/ROX-33673

User-facing documentation

CHANGELOG entry added. User documentation update may be needed to document the new policy alongside the existing ingress policy documentation.

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature
    flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

Updated test data in sensor/tests/resource/networkpolicy/data/policies.json to include the new egress policy. The underlying "Has Egress Network Policy" field already has existing test coverage in pkg/booleanpolicy/network_criteria_test.go. Policy loading is validated by existing tests in pkg/defaults/policies/policies_test.go which verify MITRE exception list consistency and policy structure.

How I validated my change

  • Verified the new policy JSON follows the exact structure of the existing ingress policy
  • Confirmed the "Has Egress Network Policy" field exists in pkg/booleanpolicy/augmentedobjs/custom_types.go and pkg/booleanpolicy/fieldnames/list.go
  • Ran existing policy tests to ensure the new policy loads correctly and doesn't conflict with existing policies
  • Validated MITRE exception list entry prevents test failures for policies without MITRE ATT&CK mappings
  • CI will validate policy loading, JSON schema correctness, and integration with network policy detection

@openshift-ci
Copy link

openshift-ci bot commented Mar 20, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="CHANGELOG.md" line_range="24" />
<code_context>
 - ROX-33099: New Operator Helm Chart is now the only recommended way to install on non-OpenShift clusters.
 - ROX-33098 (Tech Preview): Effective path and Actual Path have been combined into a single File Path policy criterion.
 - ROX-33156 (Tech Preview): A new default policy category called "File Activity Monitoring" is now available.
+- ROX-33673: A new default policy added to detect missing egress NetworkPolicy associated with deployments. The policy is disabled by default.

 ### Removed Features
</code_context>
<issue_to_address>
**issue (typo):** Consider adding a verb for grammatical correctness (e.g., "has been added").

Rephrase to include a verb, e.g.: "A new default policy has been added to detect missing egress NetworkPolicy associated with deployments."
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@AlexVulaj AlexVulaj marked this pull request as ready for review March 20, 2026 16:06
@AlexVulaj AlexVulaj requested review from a team as code owners March 20, 2026 16:06
@AlexVulaj AlexVulaj force-pushed the AlexVulaj/ROX-33673-ootb-policy-egress branch from 5cdd9ca to 0a3a034 Compare March 20, 2026 16:09
@rhacs-bot
Copy link
Contributor

rhacs-bot commented Mar 20, 2026

Images are ready for the commit at 0a3a034.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-395-g0a3a034881.

@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.24%. Comparing base (c2045aa) to head (0a3a034).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19524      +/-   ##
==========================================
+ Coverage   49.23%   49.24%   +0.01%     
==========================================
  Files        2727     2727              
  Lines      205764   205778      +14     
==========================================
+ Hits       101304   101342      +38     
+ Misses      96921    96900      -21     
+ Partials     7539     7536       -3     
Flag Coverage Δ
go-unit-tests 49.24% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@openshift-ci
Copy link

openshift-ci bot commented Mar 20, 2026

@AlexVulaj: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ocp-4-12-operator-e2e-tests 0a3a034 link false /test ocp-4-12-operator-e2e-tests

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants