Validate ModSecurity rule

This function checks a ModSecurity™ rule's validity.

Important:

When you disable the Web Server role, the system disables this function.

SecurityBasicAuth
Request
query Parameters
rule
required
string

The ModSecurity rule to check.

Example: rule=SecAction "pass,id:1234567"
Responses
200

HTTP Request was successful.

Response Schema: application/json
object
object
get/modsec_check_rule
Request samples
whmapi1 --output=jsonpretty \
  modsec_check_rule \
  rule='SecAction "pass,id:1234567"'
Response samples
application/json
{
  • "data": {
    • "problem": "The rule is invalid. Apache returned the following error: AH00526: Syntax error on line 1 of /var/tmp/15500._USR_LOCAL_CPANEL_WHOSTMGR_BIN_XML_API__.gl2t8wZ1.tmp/validate.conf:\nInvalid command ''OWASP'', perhaps misspelled or defined by a module not included in the server configuration\n'",
    • "valid": 0
    },
  • "metadata": {
    • "command": "modsec_check_rule",
    • "reason": "OK Invalid Rule",
    • "result": 1,
    • "version": 1
    }
}