Ejemplo n.º 1
0
 def get(self):
   session_id = get_session_id(session, request)
   dao = AttackerDAO(session_id)
   objts = dao.get_attackers_summary()
   dao.close()
   resp = make_response(json_serialize(objts, session_id=session_id))
   resp.headers['Content-Type'] = "application/json"
   return resp
Ejemplo n.º 2
0
 def get(self):
   session_id = get_session_id(session, request)
   dao = AttackerDAO(session_id)
   objts = dao.get_attackers_summary()
   dao.close()
   resp = make_response(json_serialize(objts, session_id=session_id))
   resp.headers['Content-Type'] = "application/json"
   return resp
Ejemplo n.º 3
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
Ejemplo n.º 4
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), OK)
    resp.headers['Content-type'] = 'application/json'
    return resp
Ejemplo n.º 5
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), OK)
    resp.contenttype = 'application/json'
    return resp
Ejemplo n.º 6
0
    def delete(self, name):
        session_id = get_session_id(session, request)

        dao = AttackerDAO(session_id)
        dao.delete_attacker(name=name)
        dao.close()

        resp_dict = {'message': 'Attacker successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 7
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), OK)
    resp.headers['Content-type'] = 'application/json'
    return resp
Ejemplo n.º 8
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
Ejemplo n.º 9
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), OK)
    resp.contenttype = 'application/json'
    return resp
Ejemplo n.º 10
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
Ejemplo n.º 11
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
Ejemplo n.º 12
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_motivation(name=name, environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Attacker motivation successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 13
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
Ejemplo n.º 14
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
Ejemplo n.º 15
0
  def post(self):
    session_id = get_session_id(session, request)

    dao = AttackerDAO(session_id)
    new_attacker = dao.from_json(request)
    dao.add_attacker(new_attacker)
    dao.close()
    resp_dict = {'message': new_attacker.name() + ' created'}
    resp = make_response(json_serialize(resp_dict), OK)
    resp.contenttype = 'application/json'
    return resp
Ejemplo n.º 16
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': req.name() + ' updated'}
    resp = make_response(json_serialize(resp_dict), OK)
    resp.headers['Content-type'] = 'application/json'
    return resp
Ejemplo n.º 17
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), OK)
    resp.headers['Content-type'] = 'application/json'
    return resp
Ejemplo n.º 18
0
  def delete(self, name):
    session_id = get_session_id(session, request)

    dao = AttackerDAO(session_id)
    dao.delete_attacker(name=name)
    dao.close()

    resp_dict = {'message': name + ' deleted'}
    resp = make_response(json_serialize(resp_dict), OK)
    resp.headers['Content-type'] = 'application/json'
    return resp
Ejemplo n.º 19
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), OK)
    resp.headers['Content-type'] = 'application/json'
    return resp
Ejemplo n.º 20
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), OK)
    resp.headers['Content-type'] = 'application/json'
    return resp
Ejemplo n.º 21
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), OK)
    resp.contenttype = 'application/json'
    return resp
Ejemplo n.º 22
0
    def put(self, name):
        session_id = get_session_id(session, request)
        environment_name = request.args.get('environment', '')

        dao = AttackerDAO(session_id)
        attacker_capability = dao.type_from_json(request)
        dao.update_attacker_capability(attacker_capability, name=name, environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Attacker capability successfully updated'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 23
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