Skip to content

Commit

Permalink
Added Swagger auto-documentation support to Recon-API.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanmaster53 committed Oct 26, 2019
1 parent e0b227d commit 7396c2c
Show file tree
Hide file tree
Showing 5 changed files with 431 additions and 11 deletions.
1 change: 1 addition & 0 deletions REQUIREMENTS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ requests
# web
flask
flask-restful
flasgger
dicttoxml
XlsxWriter
unicodecsv
Expand Down
1 change: 1 addition & 0 deletions recon/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
*************************************************************************
* Welcome to Recon-web, the analytics and reporting engine for Recon-ng!
* This is a web-based user interface. Open the URL below in your browser to begin.
* Recon-web includes the Recon-API, which can be accessed via the `/api/` URL.
*************************************************************************\
'''
13 changes: 13 additions & 0 deletions recon/core/web/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from flask import Flask, request, abort, cli
from flasgger import Swagger
from recon.core import base
from recon.core.constants import BANNER_WEB
from recon.core.web.db import Tasks
Expand All @@ -21,6 +22,16 @@
SECRET_KEY = 'we keep no secrets here.'
JSON_SORT_KEYS = False
REDIS_URL = 'redis://'
SWAGGER = {
'title': 'Swagger',
'info': {
'title': 'Recon-API',
'description': 'A RESTful API for Recon-ng',
'version': '0.0.1',
},
'uiversion': 3,
'specs_route': '/api/',
}
WORKSPACE = recon.workspace.split('/')[-1]
print((f" * Workspace initialized: {WORKSPACE}"))

Expand All @@ -30,6 +41,8 @@ def create_app():
app = Flask(__name__, static_url_path='')
app.config.from_object(__name__)

Swagger(app, template_file='definitions.yaml')

app.redis = Redis.from_url(app.config['REDIS_URL'])
app.task_queue = rq.Queue('recon-tasks', connection=app.redis)

Expand Down
137 changes: 137 additions & 0 deletions recon/core/web/definitions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
definitions:
Error:
properties:
type:
type: string
message:
type: string
traceback:
type: string
required:
- type
- message
- traceback
Result:
properties:
error:
$ref: '#/definitions/Error'
summary:
type: object
required:
- summary
Task:
properties:
id:
type: string
status:
type: string
result:
$ref: '#/definitions/Result'
required:
- id
- status
- result
Option:
properties:
name:
type: string
value:
type: string
required:
type: boolean
description:
type: string
required:
- name
- value
- required
- description
Module:
properties:
name:
type: string
author:
type: string
version:
type: string
description:
type: string
required_keys:
type: array
items:
type: string
dependencies:
type: array
items:
type: string
comments:
type: array
items:
type: string
query:
type: string
options:
type: array
items:
$ref: '#/definitions/Option'
files:
type: array
items:
type: string
required:
- name
- author
- version
- description
Workspace:
properties:
name:
type: string
status:
type: string
options:
type: array
items:
$ref: '#/definitions/Option'
Dashboard:
properties:
workspace:
type: string
records:
type: array
items:
type: object
properties:
name:
type: string
count:
type: integer
activity:
type: array
items:
type: object
properties:
module:
type: string
runs:
type: integer
Table:
properties:
workspace:
type: string
table:
type: string
columns:
type: array
items:
type: string
rows:
type: array
items:
type: object
required:
- workspace
- table
- columns
- rows
Loading

0 comments on commit 7396c2c

Please sign in to comment.