Exemple #1
0
# Configurations
app.config.from_object(config)

# Logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
app.logger.setLevel(app.config.get('LOG_LEVEL', "INFO"))
app.logger.addHandler(handler)

# swagger
api = swagger.docs(Api(app),
                   apiVersion=SpiderKeeper.__version__,
                   api_spec_url="/api",
                   description='SpiderKeeper')
# Define the database object which is imported
# by modules and controllers
db = SQLAlchemy(app)

# Define apscheduler
scheduler = BackgroundScheduler()


class Base(db.Model):
    __abstract__ = True

    id = db.Column(db.Integer, primary_key=True)
    date_created = db.Column(db.DateTime, default=db.func.current_timestamp())
    date_modified = db.Column(db.DateTime,
Exemple #2
0
# Configurations
app.config.from_object(config)

# Logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
app.logger.setLevel(logging.INFO)
app.logger.addHandler(handler)

# swagger
api = swagger.docs(Api(app),
                   apiVersion='1.0.0',
                   api_spec_url="/api",
                   description='SpiderKeeper')
# Define the database object which is imported
# by modules and controllers
db = SQLAlchemy(app)

# Define apscheduler
scheduler = BackgroundScheduler()


class Base(db.Model):
    __abstract__ = True

    id = db.Column(db.Integer, primary_key=True)
    date_created = db.Column(db.DateTime, default=db.func.current_timestamp())
    date_modified = db.Column(db.DateTime,
from flask.ext.restful_swagger import swagger

from cairis.core.Borg import Borg
from CairisHTTPError import CairisHTTPError, ARMHTTPError
from cairis.core.ARM import ARMException, DatabaseProxyException
from cairis.controllers import AssetController, AttackerController, CImportController, DependencyController, \
    DimensionController, EnvironmentController, GoalController, MisuseCaseController, ProjectController, \
    RequirementController, ResponseController, RiskController, RoleController, ThreatController, \
    UploadController, UserController, VulnerabilityController

__author__ = 'Robin Quetin'
''' This module uses Flask (tested using 0.10) & Flask-Restful (tested using 0.3.3) '''


app = Flask(__name__)
api = swagger.docs(Api(app), apiVersion='0.1', description='CAIRIS API', api_spec_url='/api/cairis')
cors = CORS(app)
b = Borg()


@app.route('/')
def index():
    return app.send_static_file('index.html')


@app.route('/plugins/<path:path>')
def plugin_reroute(path):
    try:
        web_image_dir = os.path.join(b.staticDir, 'plugins')
        return send_from_directory(web_image_dir, path)
    except AttributeError:
Exemple #4
0
from flask.ext.restful_swagger import swagger

from Borg import Borg
from CairisHTTPError import CairisHTTPError, ARMHTTPError
from ARM import ARMException, DatabaseProxyException
from controllers import AssetController, AttackerController, CImportController, DependencyController, \
    DimensionController, EnvironmentController, GoalController, MisuseCaseController, ProjectController, \
    RequirementController, ResponseController, RiskController, RoleController, ThreatController, \
    UploadController, UserController, VulnerabilityController

__author__ = 'Robin Quetin'
''' This module uses Flask (tested using 0.10) & Flask-Restful (tested using 0.3.3) '''

app = Flask(__name__)
api = swagger.docs(Api(app),
                   apiVersion='0.1',
                   description='CAIRIS API',
                   api_spec_url='/api/cairis')
cors = CORS(app)
b = Borg()


@app.route('/')
def index():
    return app.send_static_file('index.html')


@app.route('/plugins/<path:path>')
def plugin_reroute(path):
    try:
        web_image_dir = os.path.join(b.staticDir, 'plugins')
        return send_from_directory(web_image_dir, path)
__author__ = 'Panmax'

import json

from flask import Blueprint, current_app
from flask.ext.restful import Api, abort
from flask.ext.restful_swagger import swagger
from flask.ext.restful import Resource as BaseResource


api_v1_bp = Blueprint('api_v1', __name__)


api = swagger.docs(Api(api_v1_bp), apiVersion='v1',
                   basePath='https://api.ihaoyisheng.com',
                   resourcePath='/',
                   produces=["application/json"],
                   api_spec_url='/api/doc',
                   description='我爱好医生API')


# Api Super Class
class Resource(BaseResource):
    # decorator for all methods of subclass
    method_decorators = [login_required]

    # add method names if skips auth token_key
    auth_token_without = None

@api_v1_bp.errorhandler(Exception)
def error_page(e):
    current_app.logger.exception(e)