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:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "script.getscriptsbyevents",
  4. "params": [
  5. "632",
  6. "614"
  7. ],
  8. "id": 1
  9. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "632": [
  5. {
  6. "scriptid": "3",
  7. "name": "Detect operating system",
  8. "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
  9. "host_access": "2",
  10. "usrgrpid": "7",
  11. "groupid": "0",
  12. "description": "",
  13. "confirmation": "",
  14. "type": "0",
  15. "execute_on": "1",
  16. "timeout": "30s",
  17. "scope": "4",
  18. "port": "",
  19. "authtype": "0",
  20. "username": "",
  21. "password": "",
  22. "publickey": "",
  23. "privatekey": "",
  24. "menu_path": "",
  25. "url": "",
  26. "new_window": "1",
  27. "parameters": []
  28. },
  29. {
  30. "scriptid": "1",
  31. "name": "Ping",
  32. "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
  33. "host_access": "2",
  34. "usrgrpid": "0",
  35. "groupid": "0",
  36. "description": "",
  37. "confirmation": "",
  38. "type": "0",
  39. "execute_on": "1",
  40. "timeout": "30s",
  41. "scope": "4",
  42. "port": "",
  43. "authtype": "0",
  44. "username": "",
  45. "password": "",
  46. "publickey": "",
  47. "privatekey": "",
  48. "menu_path": "",
  49. "url": "",
  50. "new_window": "1",
  51. "parameters": []
  52. },
  53. {
  54. "scriptid": "2",
  55. "name": "Traceroute",
  56. "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
  57. "host_access": "2",
  58. "usrgrpid": "0",
  59. "groupid": "0",
  60. "description": "",
  61. "confirmation": "",
  62. "type": "0",
  63. "execute_on": "1",
  64. "timeout": "30s",
  65. "scope": "4",
  66. "port": "",
  67. "authtype": "0",
  68. "username": "",
  69. "password": "",
  70. "publickey": "",
  71. "privatekey": "",
  72. "menu_path": "",
  73. "url": "",
  74. "new_window": "1",
  75. "parameters": []
  76. }
  77. ],
  78. "614": [
  79. {
  80. "scriptid": "3",
  81. "name": "Detect operating system",
  82. "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
  83. "host_access": "2",
  84. "usrgrpid": "7",
  85. "groupid": "0",
  86. "description": "",
  87. "confirmation": "",
  88. "type": "0",
  89. "execute_on": "1",
  90. "timeout": "30s",
  91. "scope": "4",
  92. "port": "",
  93. "authtype": "0",
  94. "username": "",
  95. "password": "",
  96. "publickey": "",
  97. "privatekey": "",
  98. "menu_path": "",
  99. "url": "",
  100. "new_window": "1",
  101. "parameters": []
  102. },
  103. {
  104. "scriptid": "1",
  105. "name": "Ping",
  106. "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
  107. "host_access": "2",
  108. "usrgrpid": "0",
  109. "groupid": "0",
  110. "description": "",
  111. "confirmation": "",
  112. "type": "0",
  113. "execute_on": "1",
  114. "timeout": "30s",
  115. "scope": "4",
  116. "port": "",
  117. "authtype": "0",
  118. "username": "",
  119. "password": "",
  120. "publickey": "",
  121. "privatekey": "",
  122. "menu_path": "",
  123. "url": "",
  124. "new_window": "1",
  125. "parameters": []
  126. },
  127. {
  128. "scriptid": "2",
  129. "name": "Traceroute",
  130. "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
  131. "host_access": "2",
  132. "usrgrpid": "0",
  133. "groupid": "0",
  134. "description": "",
  135. "confirmation": "",
  136. "type": "0",
  137. "execute_on": "1",
  138. "timeout": "30s",
  139. "scope": "4",
  140. "port": "",
  141. "authtype": "0",
  142. "username": "",
  143. "password": "",
  144. "publickey": "",
  145. "privatekey": "",
  146. "menu_path": "",
  147. "url": "",
  148. "new_window": "1",
  149. "parameters": []
  150. }
  151. ]
  152. },
  153. "id": 1
  154. }

Source

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