WHM API.
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/
https://{host}:{port}/json-api/
Request
This function adds a new rule to a ModSecurity™ configuration staging file. For example, if you choose to add a rule for the example.conf file, the function stages the rule in the example.conf. STAGE file.
Important:
This function does not actually deploy the rule. To deploy the rule, use the WHM API 1 Functions - modsec_deploy_all_rule_changes function.
Important:
When you disable the Web Server role, the system disables this function.
- Mock server
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_add_rule
- A server running WHM.
https://whm-server.tld:2087/json-api/modsec_add_rule
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
'https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_add_rule?config=modsec2.user.conf&rule=SecAction+%22phase%3A1%2Cid%3A168%2Cnolog%2Cpass%2Csetvar%3Atx.REMOTE_ADDR%3D%2F%25{REMOTE_ADDR}%2F%22'{ "data": { "rule": { … } }, "metadata": { "command": "modsec_add_rule", "reason": "OK", "result": 1, "version": 1 } }
Request
This function checks a ModSecurity™ rule's validity.
Important:
When you disable the Web Server role, the system disables this function.
- Mock server
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_check_rule
- A server running WHM.
https://whm-server.tld:2087/json-api/modsec_check_rule
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
'https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_check_rule?rule=SecAction+%22pass%2Cid%3A1234567%22'{ "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 } }
Request
This function copies a ModSecurity™ rule with a new rule ID.
Important:
When you disable the Web Server role, the system disables this function.
- Mock server
https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_clone_rule
- A server running WHM.
https://whm-server.tld:2087/json-api/modsec_clone_rule
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
'https://api.docs.cpanel.net/_mock/specifications/whm.openapi/modsec_clone_rule?config=modsec2.user.conf&id=123456789'{ "data": { "rule": { … } }, "metadata": { "command": "modsec_clone_rule", "reason": "OK", "result": 1, "version": 1 } }