Move From Detect to Prevent in K8s With Many Ingress Rules
Larger K8s environments can have many ingress rules specified within the ingress resource(s) or routes defined for Kong gateway.
Here's a suggested workflow explaining how to set open-appsec to prevent to protect them after initial onboarding was done in detect mode and sufficient time has passed to gain confidence about open-appsec and allow the solution to perform the learning.
Start with your own detect policy, see following example: (Or create a new one and apply to your ingress, see Configuration Using CRDs)
apiVersion: openappsec.io/v1beta1
kind: Policy
metadata:
name: example-policy
# BEFORE moving certain ingress rules to prevent-learn
spec:
default:
triggers:
- appsec-special-log-trigger
mode: detect-learn
practices:
- webapp-best-practice
source-identifiers: my-source-identifiers
trusted-sources: my-trusted-sources
custom-response: appsec-web-user-response-example
exceptions:
- appsec-exception-example
Once sufficient confidence as well as training is reached for certain resources to move them to prevent: Create specific rules in "prevent-learn" mode in the policy object for those resources (see also the hint below the following example). The learning recommendations as shown in the WebUI will provide helpful suggestions about when to move to prevent for each protected asset, see Track Learning and Move From Learn/Detect to Prevent In the following example the following hosts/path will be protected in "prevent-learn" mode, assuming ingress rules are defined as well to allow the traffic: - web.server.com/example - web.server.com/another-example - another.webserver.com The default mode for all other resources based on existing ingress rules will remain "detect-learn", as specified in the default section of the policy example.
apiVersion: openappsec.io/v1beta1
kind: Policy
metadata:
name: example-policy
# AFTER moving certain ingress rules to prevent-learn
spec:
default:
triggers:
- appsec-special-log-trigger
mode: detect-learn
practices:
- webapp-best-practice
source-identifiers: my-source-identifiers
trusted-sources: my-trusted-sources
custom-response: appsec-web-user-response-example
exceptions:
- appsec-exception-example
specific-rules:
- host: web.server.com/example
triggers:
- appsec-special-log-trigger
mode: prevent-learn
practices:
- webapp-best-practice
source-identifiers: my-source-identifiers
trusted-sources: my-trusted-sources
custom-response: appsec-web-user-response-example
exceptions:
- appsec-exception-example
- host: web.server.com/another-example
triggers:
- appsec-special-log-trigger
mode: prevent-learn
practices:
- webapp-best-practice
source-identifiers: my-source-identifiers
trusted-sources: my-trusted-sources
custom-response: appsec-web-user-response-example
exceptions:
- appsec-exception-example
- host: another.webserver.com
triggers:
- appsec-special-log-trigger
mode: prevent-learn
practices:
- webapp-best-practice
source-identifiers: my-source-identifiers
trusted-sources: my-trusted-sources
custom-response: appsec-web-user-response-example
exceptions:
- appsec-exception-example
Last updated
Was this helpful?