Files
metasploit-gs/documentation/api/v1/session_event_api_doc.rb
T

176 lines
5.4 KiB
Ruby
Raw Normal View History

2018-05-03 16:00:56 -05:00
require 'swagger/blocks'
module SessionEventApiDoc
include Swagger::Blocks
2018-05-22 14:57:21 -05:00
SESSION_ID_DESC = 'The ID of the session record that caused this event.'
2018-05-16 11:56:11 -05:00
ETYPE_DESC = 'The type of session event that occurred.'
ETYPE_ENUM = ['command', 'output', 'upload', 'download', 'filedelete']
COMMAND_DESC = 'The command that was executed for this event.'
OUTPUT_DESC = 'The resulting output of the executed command.'
LOCAL_PATH_DESC = 'Path to the associated file for upload and download events.'
LOCAL_PATH_EXAMPLE = '/path/to/file'
REMOTE_PATH_DESC = 'Path to the associated file for upload, download, and filedelete events.'
REMOTE_PATH_EXAMPLE = '/path/to/file'
2018-05-03 16:00:56 -05:00
# Swagger documentation for session events model
swagger_schema :SessionEvent do
2018-05-16 11:56:11 -05:00
key :required, [:etype, :session_id]
2018-05-22 14:57:21 -05:00
property :id, type: :integer, format: :int32, description: RootApiDoc::ID_DESC
property :session_id, type: :integer, format: :int32, description: SESSION_ID_DESC
property :etype, type: :string, description: ETYPE_DESC, enum: ETYPE_ENUM
2018-05-16 11:56:11 -05:00
property :command, type: :string, description: COMMAND_DESC
property :output, type: :string, description: OUTPUT_DESC
property :local_path, type: :string, description: LOCAL_PATH_DESC, example: LOCAL_PATH_EXAMPLE
property :remote_path, type: :string, description: REMOTE_PATH_DESC, example: REMOTE_PATH_EXAMPLE
2018-05-22 14:57:21 -05:00
property :created_at, type: :string, format: :date_time, description: RootApiDoc::CREATED_AT_DESC
2018-05-03 16:00:56 -05:00
end
swagger_path '/api/v1/session-events' do
# Swagger documentation for /api/v1/session-events GET
operation :get do
key :description, 'Return session events that are stored in the database.'
key :tags, [ 'session_event' ]
parameter do
key :name, :limit
key :in, :query
key :description, RootApiDoc::LIMIT_DESC
key :example, RootApiDoc::LIMIT_DEFAULT
key :type, :integer
key :format, :int32
key :required, false
end
parameter do
key :name, :offset
key :in, :query
key :description, RootApiDoc::OFFSET_DESC
key :example, RootApiDoc::OFFSET_DEFAULT
key :type, :integer
key :format, :int32
key :required, false
end
parameter do
key :name, :order
key :in, :query
key :description, RootApiDoc::ORDER_DESC
key :type, :string
key :required, false
key :enum, RootApiDoc::ORDER_ENUM
end
2018-05-03 16:00:56 -05:00
response 200 do
2018-05-17 16:56:22 -05:00
key :description, 'Returns session event data.'
2018-05-03 16:00:56 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
key :type, :array
items do
key :'$ref', :SessionEvent
end
2018-05-03 16:00:56 -05:00
end
end
end
2018-07-25 21:46:33 -05:00
2018-08-14 13:35:59 -05:00
response 401 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_401
2018-08-14 13:35:59 -05:00
schema do
key :'$ref', :AuthErrorModel
end
end
2018-07-25 21:46:33 -05:00
response 500 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_500
2018-07-25 21:46:33 -05:00
schema do
key :'$ref', :ErrorModel
end
end
2018-05-03 16:00:56 -05:00
end
2019-01-08 17:11:01 -05:00
# Swagger documentation for /api/v1/session-events POST
2018-05-03 16:00:56 -05:00
operation :post do
key :description, 'Create a session events entry.'
key :tags, [ 'session_event' ]
parameter do
key :in, :body
key :name, :body
2018-05-17 16:56:22 -05:00
key :description, 'The attributes to assign to the session event.'
2018-05-03 16:00:56 -05:00
key :required, true
schema do
2018-05-16 11:56:11 -05:00
property :etype, type: :string, required: true, description: ETYPE_DESC, enum: ETYPE_ENUM
2018-05-03 16:00:56 -05:00
property :session, '$ref' => :Session, required: true
2018-05-16 11:56:11 -05:00
property :command, type: :string, description: COMMAND_DESC
property :output, type: :string, description: OUTPUT_DESC
property :local_path, type: :string, description: LOCAL_PATH_DESC, example: LOCAL_PATH_EXAMPLE
property :remote_path, type: :string, description: REMOTE_PATH_DESC, example: REMOTE_PATH_EXAMPLE
2018-05-03 16:00:56 -05:00
end
end
response 200 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_200
2018-05-03 16:00:56 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
key :'$ref', :SessionEvent
end
2018-05-03 16:00:56 -05:00
end
end
2018-07-25 21:46:33 -05:00
2018-08-14 13:35:59 -05:00
response 401 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_401
2018-08-14 13:35:59 -05:00
schema do
key :'$ref', :AuthErrorModel
end
end
2018-07-25 21:46:33 -05:00
response 500 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_500
2018-07-25 21:46:33 -05:00
schema do
key :'$ref', :ErrorModel
end
end
2018-05-03 16:00:56 -05:00
end
end
2018-07-18 16:01:12 -05:00
swagger_path '/api/v1/session-events/{id}' do
2018-12-27 21:42:24 -05:00
# Swagger documentation for /api/v1/session-events/:id GET
2018-07-18 16:01:12 -05:00
operation :get do
2018-12-27 21:42:24 -05:00
key :description, 'Return a specific session event that is stored in the database.'
2018-07-18 16:01:12 -05:00
key :tags, [ 'session_event' ]
parameter do
key :name, :id
key :in, :path
2018-12-27 21:42:24 -05:00
key :description, 'ID of session event to retrieve.'
2018-07-18 16:01:12 -05:00
key :required, true
key :type, :integer
key :format, :int32
end
response 200 do
2018-07-25 18:01:05 -05:00
key :description, 'Returns session event data.'
2018-07-18 16:01:12 -05:00
schema do
2018-07-25 18:01:05 -05:00
property :data do
2018-07-31 15:43:57 -05:00
key :'$ref', :SessionEvent
2018-07-18 16:01:12 -05:00
end
end
end
2018-07-25 21:46:33 -05:00
2018-08-14 13:35:59 -05:00
response 401 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_401
2018-08-14 13:35:59 -05:00
schema do
key :'$ref', :AuthErrorModel
end
end
2018-07-25 21:46:33 -05:00
response 500 do
2018-08-15 15:26:35 -05:00
key :description, RootApiDoc::DEFAULT_RESPONSE_500
2018-07-25 21:46:33 -05:00
schema do
key :'$ref', :ErrorModel
end
end
2018-07-18 16:01:12 -05:00
end
end
2018-05-03 16:00:56 -05:00
end