Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

root_api_doc.rb 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. require 'swagger/blocks'
  2. module RootApiDoc
  3. include Swagger::Blocks
  4. ID_DESC = 'The primary key used to identify this object in the database.'
  5. CREATED_AT_DESC = 'The date and time this record was added to the database.'
  6. UPDATED_AT_DESC = 'The date and time this record was last updated in the database.'
  7. WORKSPACE_ID_DESC = 'The ID of the workspace this credential belongs to.'
  8. WORKSPACE_POST_DESC = 'The name of the workspace where this record should be created.'
  9. WORKSPACE_POST_EXAMPLE = 'default'
  10. HOST_EXAMPLE = '127.0.0.1'
  11. CODE_DESC = 'The error code that was generated.'
  12. CODE_EXAMPLE = 500
  13. MESSAGE_DESC = 'A message describing the error that occurred.'
  14. MESSAGE_EXAMPLE = 'Undefined method \'empty?\' for nil:NilClass'
  15. AUTH_CODE_DESC = 'The authentication error code that was generated.'
  16. AUTH_CODE_EXAMPLE = 401
  17. AUTH_MESSAGE_DESC = 'A message describing the authentication error that occurred.'
  18. LIMIT_DEFAULT = 100
  19. LIMIT_DESC = "The maximum number of results that will be retrieved from the query. (Default: #{LIMIT_DEFAULT})"
  20. OFFSET_DEFAULT = 0
  21. OFFSET_DESC = "The number of results the query will begin reading from the beginning of the set. (Default: #{OFFSET_DEFAULT})"
  22. ORDER_DESC = 'The order in which results are returned, based on the created_at datetime. (Default: desc)'
  23. ORDER_ENUM = [
  24. 'asc',
  25. 'desc'
  26. ]
  27. DEFAULT_RESPONSE_200 = 'Successful operation.'
  28. DEFAULT_RESPONSE_401 = 'Authenticate to access this resource.'
  29. DEFAULT_RESPONSE_500 = 'An error occurred during the operation. See the message for more details.'
  30. swagger_root do
  31. key :swagger, '2.0'
  32. info do
  33. key :version, '1.0.0'
  34. key :title, 'Metasploit API'
  35. key :description, 'An API for interacting with Metasploit\'s data models.'
  36. license do
  37. key :name, 'BSD-3-clause'
  38. end
  39. end
  40. key :consumes, ['application/json']
  41. key :produces, ['application/json']
  42. security_definition :api_key do
  43. key :type, :apiKey
  44. key :name, :Authorization
  45. key :in, :header
  46. end
  47. security do
  48. key :api_key, []
  49. end
  50. #################################
  51. #
  52. # Documentation Tags
  53. #
  54. #################################
  55. tag name: 'auth', description: 'Authorization operations.'
  56. tag name: 'credential', description: 'Credential operations.'
  57. tag name: 'db_export', description: 'Endpoint for generating and retrieving a database backup.'
  58. tag name: 'event', description: 'Event operations.'
  59. tag name: 'exploit', description: 'Exploit operations.'
  60. tag name: 'host', description: 'Host operations.'
  61. tag name: 'login', description: 'Login operations.'
  62. tag name: 'loot', description: 'Loot operations.'
  63. tag name: 'module', description: 'Module search operations.'
  64. tag name: 'msf', description: 'Utility operations around Metasploit Framework.'
  65. tag name: 'nmap', description: 'Nmap operations.'
  66. tag name: 'note', description: 'Note operations.'
  67. tag name: 'service', description: 'Service operations.'
  68. tag name: 'session', description: 'Session operations.'
  69. tag name: 'session_event', description: 'Session Event operations.'
  70. tag name: 'user', description: 'User operations.'
  71. tag name: 'vuln', description: 'Vuln operations.'
  72. tag name: 'vuln_attempt', description: 'Vuln Attempt operations.'
  73. tag name: 'workspace', description: 'Workspace operations.'
  74. #################################
  75. #
  76. # Global parameters
  77. #
  78. #################################
  79. parameter :workspace do
  80. key :name, :workspace
  81. key :in, :query
  82. key :description, 'The workspace from which the data should be gathered from.'
  83. key :required, true
  84. key :type, :string
  85. end
  86. parameter :update_id do
  87. key :name, :id
  88. key :in, :path
  89. key :description, 'ID of the object to update'
  90. key :required, true
  91. key :type, :integer
  92. key :format, :int32
  93. end
  94. parameter :delete_opts do
  95. key :in, :body
  96. key :name, :delete_opts
  97. key :description, 'The IDs of the objects you want to delete.'
  98. key :required, true
  99. schema do
  100. key :required, [:ids]
  101. property :ids do
  102. key :type, :array
  103. items do
  104. key :type, :integer
  105. end
  106. end
  107. end
  108. end
  109. #################################
  110. #
  111. # Host related parameters
  112. #
  113. #################################
  114. parameter :non_dead do
  115. key :name, :non_dead
  116. key :in, :query
  117. key :description, 'true to return only hosts which are up, false for all hosts.'
  118. key :required, false
  119. key :type, :boolean
  120. end
  121. parameter :address do
  122. key :name, :address
  123. key :in, :query
  124. key :description, 'Return hosts matching the given IP address.'
  125. key :required, false
  126. key :type, :string
  127. end
  128. end
  129. swagger_schema :ErrorModel do
  130. key :required, [:message]
  131. property :error do
  132. property :code do
  133. key :type, :int32
  134. key :description, CODE_DESC
  135. key :example, CODE_EXAMPLE
  136. end
  137. property :message do
  138. key :type, :string
  139. key :description, MESSAGE_DESC
  140. key :example, MESSAGE_EXAMPLE
  141. end
  142. end
  143. end
  144. swagger_schema :AuthErrorModel do
  145. key :required, [:message]
  146. property :error do
  147. property :code do
  148. key :type, :int32
  149. key :description, AUTH_CODE_DESC
  150. key :example, AUTH_CODE_EXAMPLE
  151. end
  152. property :message do
  153. key :type, :string
  154. key :description, AUTH_MESSAGE_DESC
  155. key :example, DEFAULT_RESPONSE_401
  156. end
  157. end
  158. end
  159. end