def delete(self, type_id, module_id, r_id): t = self.abort_if_risk_occur_doesnt_exist(type_id, module_id, r_id) with app.app_context(): db.session.delete(t) db.session.commit() return "ok"
def put(self, type_id, module_id, r_id): args = self.parser.parse_args() t = self.abort_if_risk_occur_doesnt_exist(type_id, module_id, r_id) t.result = args['result'] with app.app_context(): db.session.add(t) db.session.commit() return self.abort_if_risk_occur_doesnt_exist(type_id, module_id, r_id)
def add_risk_occur(): try: type_id = request.form['type_id'] module_id = request.form['module_id'] r_id = request.form['r_id'] result = request.form['result'] except: return "Parameters missing" with app.app_context(): new_risk_occur = RiskOccurDb(type_id=type_id, module_id=module_id, r_id=r_id, result=result) db.session.add(new_risk_occur) db.session.commit() return "ok"
def put(self, type_id, module_id, r_id): args = self.parser.parse_args() t = self.abort_if_risk_doesnt_exist(type_id, module_id, r_id) if args['cve_id'] != None: t.cve_id = args['cve_id'] elif args['desc'] != None: t.desc = args['desc'] t.effected_factor = args['effected_factor'] t.effected_level = args['effected_level'] with app.app_context(): db.session.add(t) db.session.commit() return self.abort_if_risk_doesnt_exist(type_id, module_id, r_id)
def add_risk(): try: type_id = request.form['type_id'] module_id = request.form['module_id'] r_id = request.form['r_id'] desc = request.form['desc'] effected_factor = request.form['effected_factor'] effected_level = request.form['effected_level'] except: return "Parameters missing" with app.app_context(): new_risk = RiskDb(type_id=type_id, module_id=module_id, r_id=r_id, desc=desc, effected_factor=effected_factor, effected_level=effected_level) db.session.add(new_risk) db.session.commit() return "ok"
from extensions import app, db, ma, ENV import os from routes.main import main # import flask_monitoringdashboard as dashboard if ENV == 'dev': app.debug = True app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///./sql_app.db" else: app.debug = False app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.register_blueprint(main) db.init_app(app) with app.app_context(): db.create_all() # dashboard.bind(app) # add analytics to "/dashboard" if __name__ == '__main__': app.run()