I use this API from microsoft:
https://learn.microsoft.com/en-us/rest/api/application-gateway/web-application-firewall-policies/create-or-update
{
"location": "westus",
"properties": {
"customRules": [
{
"name": "BlockSpec",
"priority": 85,
"ruleType": "MatchRule",
"action": "Block",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RemoteAddr"
}
],
"operator": "IPMatch",
"matchValues": [
"100.60.60.62"
],
"transforms": []
}
],
"skippedManagedRuleSets": [],
"state": "Enabled"
}
],
"policySettings": {
"requestBodyCheck": true,
"maxRequestBodySizeInKb": 128,
"fileUploadLimitInMb": 100,
"state": "Enabled",
"mode": "Prevention",
"requestBodyInspectLimitInKB": 128,
"fileUploadEnforcement": true,
"requestBodyEnforcement": true
},
"managedRules": {
"managedRuleSets": [
{
"ruleSetType": "OWASP",
"ruleSetVersion": "3.2",
"ruleGroupOverrides": []
}
],
"exclusions": []
}
}
}
Assume that you have a policy that has 4 custom rule. When running this API, previous 4 custom rules bing deleted and new one added.
"customRules": [
{
"name": "BlockSpec",
"priority": 85,
"ruleType": "MatchRule",
"action": "Block",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RemoteAddr"
}
],
"operator": "IPMatch",
"matchValues": [
"100.60.60.62"
],
"transforms": []
}
],
"skippedManagedRuleSets": [],
"state": "Enabled"
}
]
Before:
enter image description here
After:
enter image description here
this always delete the previous one and never update the custom rule. Is there any way to add custom rule inside existing policy without deleting previous one?
ThePoe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.