|
| 1 | +#### IP-Groups feature as part of Override Rules feature. |
| 2 | +The Override Rules feature allows overriding of the original or parent policy settings. |
| 3 | +This can be done by defining override rules in the designated section, based on specific override conditions. |
| 4 | +Override rule condition with IP group based on JSON schema defined by the declarative policy and applied to "clientIp" attribute using “matches” function. |
| 5 | +'clientIp.matches(ipAddressLists["standalone"])' |
| 6 | + |
| 7 | +The policy example |
| 8 | +```json |
| 9 | +{ |
| 10 | + "policy": { |
| 11 | + "name": "ip_group_override_rule", |
| 12 | + "template": { |
| 13 | + "name": "POLICY_TEMPLATE_NGINX_BASE" |
| 14 | + }, |
| 15 | + "applicationLanguage": "utf-8", |
| 16 | + "caseInsensitive": false, |
| 17 | + "enforcementMode": "blocking", |
| 18 | + "ip-address-lists": [ |
| 19 | + { |
| 20 | + "name": "standalone", |
| 21 | + "description": "This is my list of IP addresses", |
| 22 | + "ipAddresses": [ |
| 23 | + { |
| 24 | + "ipAddress": "6.5.3.3/32" |
| 25 | + }, |
| 26 | + { |
| 27 | + "ipAddress": "6.5.4.2" |
| 28 | + } |
| 29 | + ] |
| 30 | + } |
| 31 | + ], |
| 32 | + "override-rules": [ |
| 33 | + { |
| 34 | + "name": "myFirstRule", |
| 35 | + "condition": "clientIp.matches(ipAddressLists['standalone'])", |
| 36 | + "actionType": "violation", |
| 37 | + "violation": { |
| 38 | + "block": true, |
| 39 | + "alarm": true, |
| 40 | + "attackType": { |
| 41 | + "name": "Forceful Browsing" |
| 42 | + }, |
| 43 | + "description": "Attempt to access from clientIp", |
| 44 | + "rating": 4 |
| 45 | + } |
| 46 | + } |
| 47 | + ], |
| 48 | + "general": { |
| 49 | + "trustXff": true |
| 50 | + } |
| 51 | + } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +The above policy contains ip group with the name "standalone" which is used in override rule condition "clientIp.matches(ipAddressLists['standalone'])". |
| 56 | +The condition means that the rule enforcement is applied when clientIp is matched to one of ipAddresses in ipAddressList with name "standalone". |
| 57 | +The value used in override rule condition must exist and be exactly equal the name in "ip-address-lists". |
| 58 | + |
| 59 | +#### Several error cases are verified: |
| 60 | +- Using another keyword instead of ipAddressLists; |
| 61 | + example: clientIp.matches(invalidList['standalone']); |
| 62 | + error_message: " Invalid field invalidList" |
| 63 | + |
| 64 | +- Using empty name; |
| 65 | + example: clientIp.matches(ipAddressLists['']); |
| 66 | + error_message: " Invalid value empty string" |
| 67 | + |
| 68 | +- Using ipAddressLists with attribute otherwise then clientIp; |
| 69 | + example: uri.matches(ipAddressLists['standalone']); |
| 70 | + error_message: "Failed to compile policy - 'ipGroupOverridePolicy'" |
| 71 | + |
| 72 | + |
| 73 | + |
0 commit comments