|
| 1 | +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json |
| 2 | +apiVersion: chainsaw.kyverno.io/v1alpha1 |
| 3 | +kind: Test |
| 4 | +metadata: |
| 5 | + name: trafficprotectionpolicy-paranoia-validation |
| 6 | +# Regression for issue #250: a TrafficProtectionPolicy whose blocking paranoia |
| 7 | +# level exceeds its detection paranoia level is an illegal CRS configuration |
| 8 | +# (CRS rule 901500 denies every request with HTTP 500). The CRD now carries a |
| 9 | +# CEL rule requiring detection >= blocking, so the illegal combination must be |
| 10 | +# rejected at admission rather than silently 500ing all traffic. |
| 11 | +spec: |
| 12 | + cluster: nso-standard |
| 13 | + steps: |
| 14 | + - name: Reject blocking > detection at admission |
| 15 | + try: |
| 16 | + - apply: |
| 17 | + expect: |
| 18 | + - check: |
| 19 | + ($error != null): true |
| 20 | + resource: |
| 21 | + apiVersion: networking.datumapis.com/v1alpha |
| 22 | + kind: TrafficProtectionPolicy |
| 23 | + metadata: |
| 24 | + name: inverted-paranoia |
| 25 | + spec: |
| 26 | + mode: Enforce |
| 27 | + targetRefs: |
| 28 | + - group: gateway.networking.k8s.io |
| 29 | + kind: Gateway |
| 30 | + name: waf-gw |
| 31 | + ruleSets: |
| 32 | + - type: OWASPCoreRuleSet |
| 33 | + owaspCoreRuleSet: |
| 34 | + paranoiaLevels: |
| 35 | + blocking: 2 |
| 36 | + detection: 1 |
| 37 | + |
| 38 | + - name: Reject blocking set with detection defaulted at admission |
| 39 | + try: |
| 40 | + - apply: |
| 41 | + expect: |
| 42 | + - check: |
| 43 | + ($error != null): true |
| 44 | + resource: |
| 45 | + apiVersion: networking.datumapis.com/v1alpha |
| 46 | + kind: TrafficProtectionPolicy |
| 47 | + metadata: |
| 48 | + name: default-detection-paranoia |
| 49 | + spec: |
| 50 | + mode: Enforce |
| 51 | + targetRefs: |
| 52 | + - group: gateway.networking.k8s.io |
| 53 | + kind: Gateway |
| 54 | + name: waf-gw |
| 55 | + ruleSets: |
| 56 | + - type: OWASPCoreRuleSet |
| 57 | + owaspCoreRuleSet: |
| 58 | + paranoiaLevels: |
| 59 | + blocking: 2 |
| 60 | + |
| 61 | + - name: Accept detection >= blocking |
| 62 | + try: |
| 63 | + - apply: |
| 64 | + resource: |
| 65 | + apiVersion: networking.datumapis.com/v1alpha |
| 66 | + kind: TrafficProtectionPolicy |
| 67 | + metadata: |
| 68 | + name: valid-paranoia |
| 69 | + spec: |
| 70 | + mode: Enforce |
| 71 | + targetRefs: |
| 72 | + - group: gateway.networking.k8s.io |
| 73 | + kind: Gateway |
| 74 | + name: waf-gw |
| 75 | + ruleSets: |
| 76 | + - type: OWASPCoreRuleSet |
| 77 | + owaspCoreRuleSet: |
| 78 | + paranoiaLevels: |
| 79 | + blocking: 2 |
| 80 | + detection: 3 |
| 81 | + catch: |
| 82 | + - delete: |
| 83 | + ref: |
| 84 | + apiVersion: networking.datumapis.com/v1alpha |
| 85 | + kind: TrafficProtectionPolicy |
| 86 | + name: valid-paranoia |
| 87 | + finally: |
| 88 | + - delete: |
| 89 | + ref: |
| 90 | + apiVersion: networking.datumapis.com/v1alpha |
| 91 | + kind: TrafficProtectionPolicy |
| 92 | + name: valid-paranoia |
0 commit comments