Child pages
  • WHM API 1 Functions - modsec_clone_rule
Skip to end of metadata
Go to start of metadata

Description

This function copies a ModSecurity™ rule with a new rule ID.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/modsec_clone_rule?api.version=1&config=modsec2.user.conf&id=123456789
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/modsec_clone_rule?api.version=1&config=modsec2.user.conf&id=123456789
 Command Line
whmapi1 modsec_clone_rule config=modsec2.user.conf id=123456789


Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command. 

 Output (JSON)
 {
    "data": {
        "rule": {
            "disabled": 0,
            "vendor_id": "",
            "vendor_active": "1",
            "rule": "SecRule REQUEST_URI "/rejected.php" "deny,auditlog,msg:'Rejected request',id:'1'"n",
            "config_active": "1",
            "staged": 0,
            "id": "1",
            "config": "modsec2.user.conf",
            "meta_msg": "Rejected request"
        }
    },
    "metadata": {
        "version": 1,
        "reason": "OK",
        "result": 1,
        "command": "modsec_clone_rule"
    }
}
 Output (XML)
 <result>
   <data>
      <rule>
         <config>modsec2.user.conf</config>
         <config_active>1</config_active>
         <disabled>0</disabled>
         <id>1</id>
         <meta_msg>Rejected request</meta_msg>
         <rule>SecRule REQUEST_URI "/rejected.php" "deny,auditlog,msg:'Rejected request',id:'1'"</rule>
         <staged>0</staged>
         <vendor_active>1</vendor_active>
         <vendor_id />
      </rule>
   </data>
   <metadata>
      <command>modsec_clone_rule</command>
      <reason>OK</reason>
      <result>1</result>
      <version>1</version>
   </metadata>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
configstring

Required

The rule's ModSecurity configuration file.

A valid ModSecurity configuration file.

modsec2.user.conf

id

string

Required

The existing rule's ID.

A valid ModSecurity rule ID.123456789

Returns

ReturnTypeDescriptionPossible valuesExample
rulehashA hash of information about the cloned rule.This hash contains the disabled, vendor_id, vendor_active, rule, config_active, staged, id, config, and meta_msg returns. 

disabled

Boolean

Whether the rule is disabled.

The function returns this value in the rule hash.

  • 1 — Disabled.
  • 0 — Enabled.
0

vendor_id

string

The vendor's unique short name.

The function returns this value in the rule hash.

Note:

Any rule that does not belong to a vendor rule set will not return a value.

A valid string.YourVendor

vendor_active

Boolean

Whether the vendor is active.

The function returns this value in the rule hash.

  • 1 — Active.
  • 0Not active.
0

rule

string

The rule's text.

The function returns this value in the rule hash.

The text of the new rule that includes the new rule ID.
 Click to view...
SecRule REQUEST_URI "/rejected.php" "deny,auditlog,msg:'Rejected request',id:'1'"

config_active

Boolean

Whether the configuration file is active.

The function returns this value in the rule hash.

  • 1 — Active.
  • 0Not active.

1

staged

Boolean

Whether the rule is staged.

The function returns this value in the rule hash.

  • 1 — Staged.
  • 0Not staged.

1

id

integer

The rule's ID number.

The function returns this value in the rule hash.

A positive integer.123456789

config

string

The rule's configuration file.

The function returns this value in the rule hash.

A valid ModSecurity configuration file.

modsec2.user.conf

meta_msg

string

The rule's description.

The function returns this value in the rule hash.

A valid string.

Rejected request