Return ModSecurity rules

This function retrieves the ModSecurity™ rules from one or more ModSecurity configuration files.

Important:

  • When you disable the Web Server role, the system disables this function.
  • You must include either the vendor_id or the config parameters.
SecurityBasicAuth
Request
query Parameters
config
string

The file path to the configuration file, relative to the /usr/local/apache/conf directory.

Note:

You can use a comma-delimited list for multiple configuration files.

Examples:
config=modsec_vendor_configs/SomeVendor/config.conf,modsec_vendor_configs/AnotherVendor/config.conf
config=modsec_vendor_configs/SomeVendor/config.conf
exclude_bare_comments
integer
Default: 1

Whether to exclude comments that are not associated with any directives.

  • 1 — Exclude.
  • 0 — Do not exclude.
Enum: 1 0
Example: exclude_bare_comments=1
exclude_other_directives
integer
Default: 1

Whether the function only returns the SecRule and SecAction directives from the configuration file, and comments that are not associated with a rule.

  • 1 — Only return the SecRule and SecAction directives and comments not associated with a rule.
  • 0 — Return all directives and comments.
Enum: 1 0
Example: exclude_other_directives=1
vendor_id
string

The vendor's unique short name.

Note:

You can use a comma-delimited list for multiple vendors.

Examples:
vendor_id=vendor=SomeVendor,AnotherVendor
vendor_id=SomeVendor
Responses
200

HTTP Request was successful.

Response Schema: application/json
object
object
get/modsec_get_rules
Request samples
whmapi1 --output=jsonpretty \
  modsec_get_rules
Response samples
application/json
{
  • "data": {
    • "chunks": [
      • {
        • "config": "modsec_vendor_configs/SomeVendor/config.conf",
        • "config_active": 0,
        • "disabled": 0,
        • "id": 662452,
        • "meta_msg": "Denied dangerous config traffic",
        • "rule": "SecRule REQUEST_FILENAME \"config\" \"deny,id:662452,msg:'Denied dangerous config traffic',severity:1,auditlog\"",
        • "staged": 0,
        • "vendor_active": 0,
        • "vendor_id": "SomeVendor"
        }
      ],
    • "staged_changes": 0
    },
  • "metadata": {
    • "command": "modsec_get_rules",
    • "reason": "OK",
    • "result": 1,
    • "version": 1
    }
}