2018-05-03 21:59:30 +00:00
|
|
|
require 'swagger/blocks'
|
|
|
|
|
|
|
|
module VulnAttemptApiDoc
|
|
|
|
include Swagger::Blocks
|
|
|
|
|
2018-05-22 19:57:21 +00:00
|
|
|
VULN_ID_DESC = 'The ID of the vuln record associated with this vuln attempt was exploiting.'
|
|
|
|
SESSION_ID_DESC = 'The ID of the session record associated with this vuln attempt if it was successful.'
|
|
|
|
LOOT_ID_DESC = 'The ID of the loot record associated with this vuln attempt if loot was gathered.'
|
2018-05-16 21:57:55 +00:00
|
|
|
ATTEMPTED_AT_DESC = 'The time that this vuln attempt occurred.'
|
|
|
|
EXPLOITED_DESC = 'true if the vuln attempt was successful.'
|
|
|
|
FAIL_REASON_DESC = 'Short reason why this attempt failed.'
|
|
|
|
FAIL_DETAIL_DESC = 'Long details about why this attempt failed.'
|
|
|
|
MODULE_DESC = 'Full name of the Metasploit module that was used in this attempt.'
|
|
|
|
MODULE_EXAMPLE = 'linux/local/docker_daemon_privilege_escalation'
|
|
|
|
USERNAME_DESC = 'The username of the user who made this vuln attempt.'
|
|
|
|
|
|
|
|
|
2018-05-03 21:59:30 +00:00
|
|
|
# Swagger documentation for vuln_attempts model
|
|
|
|
swagger_schema :VulnAttempt do
|
2018-05-22 19:57:21 +00:00
|
|
|
key :required, [:vuln_id]
|
|
|
|
property :id, type: :integer, format: :int32, description: RootApiDoc::ID_DESC
|
|
|
|
property :vuln_id, type: :integer, format: :int32, description: VULN_ID_DESC
|
|
|
|
property :session_id, type: :integer, format: :int32, description: SESSION_ID_DESC
|
|
|
|
property :loot_id, type: :integer, format: :int32, description: LOOT_ID_DESC
|
2018-05-16 21:57:55 +00:00
|
|
|
property :attempted_at, type: :string, format: :date_time, description: ATTEMPTED_AT_DESC
|
|
|
|
property :exploited, type: :boolean, description: EXPLOITED_DESC
|
|
|
|
property :fail_reason, type: :string, description: FAIL_REASON_DESC
|
|
|
|
property :fail_detail, type: :string, description: FAIL_DETAIL_DESC
|
|
|
|
property :module, type: :string, description: MODULE_DESC, example: MODULE_EXAMPLE
|
|
|
|
property :username, type: :string, description: USERNAME_DESC
|
2018-05-03 21:59:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
swagger_path '/api/v1/vuln-attempts' do
|
|
|
|
# Swagger documentation for /api/v1/vuln-attempts GET
|
|
|
|
operation :get do
|
|
|
|
key :description, 'Return vuln attempts that are stored in the database.'
|
|
|
|
key :tags, [ 'vuln_attempt' ]
|
|
|
|
|
2018-05-29 17:24:53 +00:00
|
|
|
parameter :workspace
|
|
|
|
|
2018-05-03 21:59:30 +00:00
|
|
|
response 200 do
|
2018-05-16 21:57:55 +00:00
|
|
|
key :description, 'Returns vuln attempt data.'
|
2018-05-03 21:59:30 +00:00
|
|
|
schema do
|
2018-07-25 23:01:05 +00:00
|
|
|
property :data do
|
|
|
|
key :type, :array
|
|
|
|
items do
|
|
|
|
key :'$ref', :VulnAttempt
|
|
|
|
end
|
2018-05-03 21:59:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-07-26 02:46:33 +00:00
|
|
|
|
2018-08-14 18:35:59 +00:00
|
|
|
response 401 do
|
2018-08-15 20:26:35 +00:00
|
|
|
key :description, RootApiDoc::DEFAULT_RESPONSE_401
|
2018-08-14 18:35:59 +00:00
|
|
|
schema do
|
|
|
|
key :'$ref', :AuthErrorModel
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-26 02:46:33 +00:00
|
|
|
response 500 do
|
2018-08-15 20:26:35 +00:00
|
|
|
key :description, RootApiDoc::DEFAULT_RESPONSE_500
|
2018-07-26 02:46:33 +00:00
|
|
|
schema do
|
|
|
|
key :'$ref', :ErrorModel
|
|
|
|
end
|
|
|
|
end
|
2018-05-03 21:59:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Swagger documentation for /api/v1/vuln-attempts POST
|
|
|
|
operation :post do
|
|
|
|
key :description, 'Create a vuln attempt entry.'
|
|
|
|
key :tags, [ 'vuln_attempt' ]
|
|
|
|
|
|
|
|
parameter do
|
|
|
|
key :in, :body
|
|
|
|
key :name, :body
|
2018-05-16 21:57:55 +00:00
|
|
|
key :description, 'The attributes to assign to the vuln attempt.'
|
2018-05-03 21:59:30 +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 :vuln_id, type: :integer, format: :int32, description: VULN_ID_DESC
|
2018-05-16 21:57:55 +00:00
|
|
|
property :attempted_at, type: :string, format: :date_time, description: ATTEMPTED_AT_DESC
|
|
|
|
property :exploited, type: :boolean, description: EXPLOITED_DESC
|
|
|
|
property :fail_reason, type: :string, description: FAIL_REASON_DESC
|
|
|
|
property :fail_detail, type: :string, description: FAIL_DETAIL_DESC
|
|
|
|
property :module, type: :string, description: MODULE_DESC, example: MODULE_EXAMPLE
|
|
|
|
property :username, type: :string, description: USERNAME_DESC
|
2018-05-03 21:59:30 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
response 200 do
|
2018-08-15 20:26:35 +00:00
|
|
|
key :description, RootApiDoc::DEFAULT_RESPONSE_200
|
2018-05-03 21:59:30 +00:00
|
|
|
schema do
|
2018-07-25 23:01:05 +00:00
|
|
|
property :data do
|
|
|
|
key :'$ref', :VulnAttempt
|
|
|
|
end
|
2018-05-03 21:59:30 +00:00
|
|
|
end
|
|
|
|
end
|
2018-07-26 02:46:33 +00:00
|
|
|
|
2018-08-14 18:35:59 +00:00
|
|
|
response 401 do
|
2018-08-15 20:26:35 +00:00
|
|
|
key :description, RootApiDoc::DEFAULT_RESPONSE_401
|
2018-08-14 18:35:59 +00:00
|
|
|
schema do
|
|
|
|
key :'$ref', :AuthErrorModel
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-26 02:46:33 +00:00
|
|
|
response 500 do
|
2018-08-15 20:26:35 +00:00
|
|
|
key :description, RootApiDoc::DEFAULT_RESPONSE_500
|
2018-07-26 02:46:33 +00:00
|
|
|
schema do
|
|
|
|
key :'$ref', :ErrorModel
|
|
|
|
end
|
|
|
|
end
|
2018-05-03 21:59:30 +00:00
|
|
|
end
|
|
|
|
end
|
2018-07-18 21:01:12 +00:00
|
|
|
|
|
|
|
swagger_path '/api/v1/vuln-attempts/{id}' do
|
|
|
|
# Swagger documentation for api/v1/vuln-attempts/:id GET
|
|
|
|
operation :get do
|
|
|
|
key :description, 'Return a specific vuln attempt that is stored in the database.'
|
|
|
|
key :tags, [ 'vuln_attempt' ]
|
|
|
|
|
|
|
|
parameter do
|
|
|
|
key :name, :id
|
|
|
|
key :in, :path
|
|
|
|
key :description, 'ID of vuln attempt to retrieve.'
|
|
|
|
key :required, true
|
|
|
|
key :type, :integer
|
|
|
|
key :format, :int32
|
|
|
|
end
|
|
|
|
|
|
|
|
response 200 do
|
|
|
|
key :description, 'Returns vuln attempt data.'
|
|
|
|
schema do
|
2018-07-25 23:01:05 +00:00
|
|
|
property :data do
|
2018-07-31 20:43:57 +00:00
|
|
|
key :'$ref', :VulnAttempt
|
2018-07-18 21:01:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-07-26 02:46:33 +00:00
|
|
|
|
2018-08-14 18:35:59 +00:00
|
|
|
response 401 do
|
2018-08-15 20:26:35 +00:00
|
|
|
key :description, RootApiDoc::DEFAULT_RESPONSE_401
|
2018-08-14 18:35:59 +00:00
|
|
|
schema do
|
|
|
|
key :'$ref', :AuthErrorModel
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-26 02:46:33 +00:00
|
|
|
response 500 do
|
2018-08-15 20:26:35 +00:00
|
|
|
key :description, RootApiDoc::DEFAULT_RESPONSE_500
|
2018-07-26 02:46:33 +00:00
|
|
|
schema do
|
|
|
|
key :'$ref', :ErrorModel
|
|
|
|
end
|
|
|
|
end
|
2018-07-18 21:01:12 +00:00
|
|
|
end
|
|
|
|
end
|
2018-08-14 18:35:59 +00:00
|
|
|
end
|