From 728850c61a540db31ec7724063148df780279825 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Thu, 3 May 2018 16:00:56 -0500 Subject: [PATCH] First pass at Session Event API doc --- documentation/api/v1/root_api_doc.rb | 1 + documentation/api/v1/session_event_api_doc.rb | 63 +++++++++++++++++++ .../http/servlet/api_docs_servlet.rb | 2 + 3 files changed, 66 insertions(+) create mode 100644 documentation/api/v1/session_event_api_doc.rb diff --git a/documentation/api/v1/root_api_doc.rb b/documentation/api/v1/root_api_doc.rb index 8e3fbe5a19..8bc04a27db 100644 --- a/documentation/api/v1/root_api_doc.rb +++ b/documentation/api/v1/root_api_doc.rb @@ -32,6 +32,7 @@ module RootApiDoc tag name: 'note', description: 'Note operations.' tag name: 'service', description: 'Service operations.' tag name: 'session', description: 'Session operations.' + tag name: 'session_event', description: 'Session Event operations.' tag name: 'vuln', description: 'Vuln operations.' tag name: 'workspace', description: 'Workspace operations.' diff --git a/documentation/api/v1/session_event_api_doc.rb b/documentation/api/v1/session_event_api_doc.rb new file mode 100644 index 0000000000..e98ca3681a --- /dev/null +++ b/documentation/api/v1/session_event_api_doc.rb @@ -0,0 +1,63 @@ +require 'swagger/blocks' + +module SessionEventApiDoc + include Swagger::Blocks + +# Swagger documentation for session events model + swagger_schema :SessionEvent do + key :required, [:id, :etype] + property :id, type: :integer, format: :int32 + property :created_at, type: :string, format: :date_time + property :session_id, type: :integer, format: :int32 + property :etype, type: :string + property :command, type: :string + property :output, type: :string + property :remote_path, type: :string + property :local_path, type: :string + 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' ] + + response 200 do + key :description, 'Returns session events data.' + schema do + key :type, :array + items do + key :'$ref', :SessionEvent + end + end + end + end + + # Swagger documentation for /api/v1/session events POST + operation :post do + key :description, 'Create a session events entry.' + key :tags, [ 'session_event' ] + + parameter do + key :in, :body + key :name, :body + key :description, 'The attributes to assign to the session.' + key :required, true + schema do + property :etype, type: :string, required: true + property :local_path, type: :string + property :command, type: :string + property :session, '$ref' => :Session, required: true + end + end + + response 200 do + key :description, 'Successful operation.' + schema do + key :type, :object + key :'$ref', :SessionEvent + end + end + end + end +end diff --git a/lib/msf/core/db_manager/http/servlet/api_docs_servlet.rb b/lib/msf/core/db_manager/http/servlet/api_docs_servlet.rb index 62be60fb96..47ef1b24d8 100644 --- a/lib/msf/core/db_manager/http/servlet/api_docs_servlet.rb +++ b/lib/msf/core/db_manager/http/servlet/api_docs_servlet.rb @@ -10,6 +10,7 @@ load 'documentation/api/v1/nmap_api_doc.rb' load 'documentation/api/v1/note_api_doc.rb' load 'documentation/api/v1/service_api_doc.rb' load 'documentation/api/v1/session_api_doc.rb' +load 'documentation/api/v1/session_event_api_doc.rb' load 'documentation/api/v1/vuln_api_doc.rb' load 'documentation/api/v1/workspace_api_doc.rb' @@ -48,6 +49,7 @@ module ApiDocsServlet NoteApiDoc, ServiceApiDoc, SessionApiDoc, + SessionEventApiDoc, VulnApiDoc, WorkspaceApiDoc ].freeze