metasploit-framework/documentation/api/v1/loot_api_doc.rb

164 lines
5.6 KiB
Ruby
Raw Normal View History

2018-04-26 16:24:05 +00:00
require 'swagger/blocks'
module LootApiDoc
include Swagger::Blocks
2018-05-22 19:57:21 +00:00
HOST_ID_DESC = 'The ID of the host record this loot is associated with.'
2018-05-08 20:41:17 +00:00
HOST_DESC = 'The IP address of the host from where the loot was obtained.'
2018-05-22 19:57:21 +00:00
SERVICE_ID_DESC = 'The ID of the service record this loot is associated with.'
2018-05-08 20:41:17 +00:00
LTYPE_DESC = 'The type of loot.'
LTYPE_EXAMPLE = "'file', 'image', 'config_file', etc."
PATH_DESC = 'The on-disk path to the loot file.'
PATH_EXAMPLE = '/path/to/file.txt'
DATA_DESC = 'The contents of the file.'
CONTENT_TYPE_DESC = 'The mime/content type of the file at {#path}. Used to server the file correctly so browsers understand whether to render or download the file.'
CONTENT_TYPE_EXAMPLE = 'text/plain'
NAME_DESC = 'The name of the loot.'
NAME_EXAMPLE = 'password_file.txt'
INFO_DESC = 'Information about the loot.'
2018-05-22 19:57:21 +00:00
MODULE_RUN_ID_DESC = 'The ID of the module run record this loot is associated with.'
2018-05-08 20:41:17 +00:00
2018-04-26 16:24:05 +00:00
# Swagger documentation for loot model
swagger_schema :Loot do
2018-05-17 21:56:22 +00:00
key :required, [:name, :ltype, :path]
2018-05-22 19:57:21 +00:00
property :id, type: :integer, format: :int32, description: RootApiDoc::ID_DESC
property :workspace_id, type: :integer, format: :int32, description: RootApiDoc::WORKSPACE_ID_DESC
property :host_id, type: :integer, format: :int32, description: HOST_ID_DESC
property :service_id, type: :integer, format: :int32, description: SERVICE_ID_DESC
2018-05-08 20:41:17 +00:00
property :ltype, type: :string, description: LTYPE_DESC, example: LTYPE_EXAMPLE
property :path, type: :string, description: PATH_DESC, example: PATH_EXAMPLE
property :data, type: :string, description: DATA_DESC
property :content_type, type: :string, description: CONTENT_TYPE_DESC, example: CONTENT_TYPE_EXAMPLE
property :name, type: :string, description: NAME_DESC, example: NAME_EXAMPLE
property :info, type: :string, description: INFO_DESC
2018-05-22 19:57:21 +00:00
property :module_run_id, type: :integer, format: :int32, description: MODULE_RUN_ID_DESC
property :created_at, type: :string, format: :date_time, description: RootApiDoc::CREATED_AT_DESC
property :updated_at, type: :string, format: :date_time, description: RootApiDoc::UPDATED_AT_DESC
2018-04-26 16:24:05 +00:00
end
2018-05-08 20:41:17 +00:00
swagger_path '/api/v1/loots' do
# Swagger documentation for /api/v1/loots GET
2018-04-26 16:24:05 +00:00
operation :get do
2018-05-17 21:56:22 +00:00
key :description, 'Return loot entries that are stored in the database.'
2018-04-30 21:40:07 +00:00
key :tags, [ 'loot' ]
2018-04-26 16:24:05 +00:00
parameter :workspace
response 200 do
2018-05-17 21:56:22 +00:00
key :description, 'Returns loot data.'
2018-04-26 16:24:05 +00:00
schema do
key :type, :array
items do
key :'$ref', :Loot
end
end
end
end
2018-05-08 20:41:17 +00:00
# Swagger documentation for /api/v1/loots POST
2018-04-26 16:24:05 +00:00
operation :post do
key :description, 'Create a loot entry.'
2018-04-30 21:40:07 +00:00
key :tags, [ 'loot' ]
2018-04-26 16:24:05 +00:00
parameter do
key :in, :body
key :name, :body
2018-05-17 21:56:22 +00:00
key :description, 'The attributes to assign to the loot.'
2018-04-26 16:24:05 +00:00
key :required, true
schema do
2018-05-22 19:57:21 +00:00
property :workspace, type: :string, required: true, description: RootApiDoc::WORKSPACE_POST_DESC, example: RootApiDoc::WORKSPACE_POST_EXAMPLE
property :host, type: :string, format: :ipv4, description: HOST_DESC, example: RootApiDoc::HOST_EXAMPLE
property :service, '$ref': :Service
2018-05-08 20:41:17 +00:00
property :ltype, type: :string, description: LTYPE_DESC, example: LTYPE_EXAMPLE, required: true
property :path, type: :string, description: PATH_DESC, example: PATH_EXAMPLE, required: true
property :data, type: :string, description: DATA_DESC
property :ctype, type: :string, description: CONTENT_TYPE_DESC, example: CONTENT_TYPE_EXAMPLE
property :name, type: :string, description: NAME_DESC, example: NAME_EXAMPLE, required: true
property :info, type: :string, description: INFO_DESC
2018-04-26 16:24:05 +00:00
end
end
response 200 do
2018-05-17 21:56:22 +00:00
key :description, 'Successful operation.'
2018-04-26 16:24:05 +00:00
schema do
key :type, :object
key :'$ref', :Loot
end
end
end
# Swagger documentation for /api/v1/loot/ DELETE
operation :delete do
key :description, 'Delete the specified loot.'
2018-04-30 21:40:07 +00:00
key :tags, [ 'loot' ]
2018-04-26 16:24:05 +00:00
parameter :delete_opts
response 200 do
2018-05-17 21:56:22 +00:00
key :description, 'Successful operation.'
2018-04-26 16:24:05 +00:00
schema do
key :type, :array
items do
key :'$ref', :Loot
end
end
end
end
end
2018-05-08 20:41:17 +00:00
swagger_path '/api/v1/loot/{id}' do
# Swagger documentation for api/v1/loot/:id GET
2018-04-26 16:24:05 +00:00
operation :get do
2018-05-17 21:56:22 +00:00
key :description, 'Return specific loot entry that is stored in the database.'
2018-04-30 21:40:07 +00:00
key :tags, [ 'loot' ]
2018-04-26 16:24:05 +00:00
parameter :workspace
parameter do
key :name, :id
key :in, :path
2018-05-17 21:56:22 +00:00
key :description, 'ID of loot to retrieve.'
2018-04-26 16:24:05 +00:00
key :required, true
key :type, :integer
key :format, :int32
end
response 200 do
2018-05-17 21:56:22 +00:00
key :description, 'Returns loot data.'
2018-04-26 16:24:05 +00:00
schema do
key :type, :array
items do
key :'$ref', :Loot
end
end
end
end
2018-05-08 20:41:17 +00:00
# Swagger documentation for /api/v1/loot/{id} PUT
2018-04-26 16:24:05 +00:00
operation :put do
key :description, 'Update the attributes an existing loot.'
2018-04-30 21:40:07 +00:00
key :tags, [ 'loot' ]
2018-04-26 16:24:05 +00:00
parameter :update_id
parameter do
key :in, :body
key :name, :body
2018-05-17 21:56:22 +00:00
key :description, 'The updated attributes to overwrite to the loot.'
2018-04-26 16:24:05 +00:00
key :required, true
schema do
key :'$ref', :Loot
end
end
response 200 do
2018-05-17 21:56:22 +00:00
key :description, 'Successful operation.'
2018-04-26 16:24:05 +00:00
schema do
key :type, :object
key :'$ref', :Loot
end
end
end
end
end