Description

This function checks a ModSecurity™ rule's validity.

Examples 




https://hostname.example.com:2087/cpsess##########/json-api/modsec_check_rule?api.version=1&rule=SecAction%20%22pass%2Cid%3A1234567%22




https://hostname.example.com:2087/cpsess##########/xml-api/modsec_check_rule?api.version=1&rule=SecAction%20%22pass%2Cid%3A1234567%22




whmapi1 modsec_check_rule rule=SecAction'"\pass,id:1234567\"'



{  
   "metadata":{  
      "reason":"OK Invalid Rule",
      "version":1,
      "result":1,
      "command":"modsec_check_rule"
   },
   "data":{  
      "problem":"(XID 2zm4ka) 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
   }
}




<result>
  <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</problem>
	<valid>0</valid>
  </data>
  <metadata>
    <version>1</version>
    <reason>OK invalid rule</reason>
    <result>1</result>
    <command>modsec_check_rule</command>
  </metadata>
</result>



Parameters

ParameterTypeDescriptionPossible valuesExample
rulestring

Required

The rule to check.

A valid ModSecurity rule.

 


SecAction "pass,id:1234567"


Returns

ReturnTypeDescriptionPossible valuesExample
problemstringA string that describes any errors with the ModSecurity rule.A string value.


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


rule

Boolean

Whether the rule is valid.

  • 1 — Valid rule.
  • 0 — Invalid rule.

0