Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions applications/openshift/networking/routes_rate_limit/rule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ title: Ensure that all Routes has rate limit enabled

description: |-
OpenShift has an option to set the rate limit for Routes [1] when creating new Routes.
All routes outside the openshift namespaces and the kube namespaces should use the
rate-limiting annotations.
All routes outside the excluded namespaces (as defined by the variable
<tt>ocp4-var-routes-excluded-namespaces-regex</tt>) should use the rate-limiting annotations.

[1] https://docs.openshift.com/container-platform/4.9/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration
[1] https://docs.openshift.com/container-platform/latest/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

rationale: |-
The usage of rate limit for Routes provides basic protection against distributed denial-of-service (DDoS) attacks.
Expand All @@ -19,14 +19,17 @@ references:
nist: SC-5,SC-5(1),SC-5(2)
srg: SRG-APP-000246-CTR-000605,SRG-APP-000435-CTR-001070

{{% set jqfilter = '[.items[] | select(.metadata.namespace | startswith("kube-") or startswith("openshift-") | not) | select(.metadata.annotations["haproxy.router.openshift.io/rate-limit-connections"] == "true" | not) | .metadata.name]' %}}
{{% set jqfilter = '[.items[] | select(.metadata.namespace | test("{{.var_routes_excluded_namespaces_regex}}"; "") | not) | select(.metadata.annotations["haproxy.router.openshift.io/rate-limit-connections"] == "true" | not) | .metadata.name]' %}}

ocil_clause: 'Rate limit is not enabled for all routes outside the openshift namespaces'
ocil_clause: 'Rate limit is not enabled for all routes outside the excluded namespaces'

ocil: |-
Run the following command to retrieve a list routes that does not have rate limit enabled:
<pre>$ oc get routes --all-namespaces -o json | jq '{{{ jqfilter }}}'</pre>
Make sure that there is output nothing in the result.
This rule checks routes that do not have rate limiting enabled and fails if there are
routes outside the excluded namespaces (as defined by the variable
<tt>ocp4-var-routes-excluded-namespaces-regex</tt>) without rate limiting annotations.
Use following command to list the routes that would fail the test:
<tt>{{{ ocil_oc_pipe_jq_filter('routes --all-namespaces', jqfilter) }}}</tt>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for updating this so it returns all routes.



severity: medium

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
documentation_complete: true

title: 'Excluded Namespaces for Routes Rate Limit Check'

description: |-
A regular expression that lists all namespaces that should be excluded
from the routes rate limit compliance check. This is particularly useful
for namespaces managed by operators where direct route modifications
are not recommended.

type: string

operator: equals

interactive: false

options:
default: "^kube-.*|openshift-.*"
Loading