예제 #1
0
    def get(self, name):
        session_id = get_session_id(session, request)

        dao = AttackerDAO(session_id)
        attacker = dao.get_attacker_by_name(name=name)
        dao.close()

        resp = make_response(json_serialize(attacker, session_id=session_id), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
예제 #2
0
    def get(self, name):
        session_id = get_session_id(session, request)
        environment_name = request.args.get('environment', '')

        dao = AttackerDAO(session_id)
        attacker_motivation = dao.get_attacker_motivation_by_name(name=name, environment_name=environment_name)
        dao.close()

        resp = make_response(json_serialize(attacker_motivation, session_id=session_id), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
예제 #3
0
    def get(self):
        session_id = get_session_id(session, request)
        environment_name = request.args.get('environment', '')

        dao = AttackerDAO(session_id)
        assets = dao.get_attacker_motivations(environment_name=environment_name)
        dao.close()

        resp = make_response(json_serialize(assets, session_id=session_id), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
예제 #4
0
    def get(self):
        session_id = get_session_id(session, request)
        constraint_id = request.args.get('constraint_id', -1)

        dao = AttackerDAO(session_id)
        attackers = dao.get_attackers(constraint_id=constraint_id)
        dao.close()

        resp = make_response(json_serialize(attackers, session_id=session_id), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
예제 #5
0
    def put(self, name):
        session_id = get_session_id(session, request)

        dao = AttackerDAO(session_id)
        req = dao.from_json(request)
        dao.update_attacker(req, name=name)
        dao.close()

        resp_dict = {'message': 'Attacker successfully updated'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
예제 #6
0
    def put(self, name):
        session_id = get_session_id(session, request)
        environment_name = request.args.get('environment', '')

        dao = AttackerDAO(session_id)
        attacker_motivation = dao.type_from_json(request)
        dao.update_attacker_motivation(attacker_motivation, name=name, environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Attacker motivation successfully updated'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
예제 #7
0
    def delete(self, name):
        session_id = get_session_id(session, request)
        environment_name = request.args.get('environment', '')

        dao = AttackerDAO(session_id)
        dao.delete_attacker_capability(name=name, environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Attacker capability successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
예제 #8
0
    def post(self):
        session_id = get_session_id(session, request)

        dao = AttackerDAO(session_id)
        new_attacker = dao.from_json(request)
        attacker_id = dao.add_attacker(new_attacker)
        dao.close()

        resp_dict = {'message': 'Attacker successfully added', 'attacker_id': attacker_id}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
예제 #9
0
    def post(self):
        session_id = get_session_id(session, request)
        environment_name = request.args.get('environment', '')

        dao = AttackerDAO(session_id)
        new_value_type = dao.type_from_json(request)
        attacker_motivation_id = dao.add_attacker_motivation(new_value_type, environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Attacker motivation successfully added', 'attacker_motivation_id': attacker_motivation_id}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp