script.getscriptsbyevents

Description

object script.getscriptsbyevents(array eventIds)

This method allows to retrieve scripts available to the given events.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(string/array) IDs of events to return scripts for.

Return values

(object) Returns an object with event IDs as properties and arrays of available scripts as values.

The method will automatically expand macros in the confirmation text and url.

Examples

Retrieve scripts by event IDs

Retrieve all scripts available to events "632" and "614".

Request:

{
           "jsonrpc": "2.0",
           "method": "script.getscriptsbyevents",
           "params": [
               "632",
               "614"
           ],
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
               "632": [
                   {
                       "scriptid": "3",
                       "name": "Detect operating system",
                       "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "7",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   },
                   {
                       "scriptid": "1",
                       "name": "Ping",
                       "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   },
                   {
                       "scriptid": "2",
                       "name": "Traceroute",
                       "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   }
               ],
               "614": [
                   {
                       "scriptid": "3",
                       "name": "Detect operating system",
                       "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "7",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   },
                   {
                       "scriptid": "1",
                       "name": "Ping",
                       "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   },
                   {
                       "scriptid": "2",
                       "name": "Traceroute",
                       "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   }
               ]
           },
           "id": 1
       }

Source

CScript::getScriptsByEvents() in ui/include/classes/api/services/CScript.php.