Ejemplo n.º 1
0
    def post(self):
        args = parser_assessment.parse_args()
        o = Assessment()
        o.name = args["name"]

        try:
            db.session.add(o)
            db.session.commit()
        except IntegrityError, exc:
            return {"error": exc.message}, 500
Ejemplo n.º 2
0
    def post(self):
        args = parser_assessment.parse_args()
        o = Assessment()
        o.name = args["name"]

        try:
            db.session.add(o)
            db.session.commit()
        except IntegrityError, exc:
            return {"error": exc.message}, 500
Ejemplo n.º 3
0
    def post(self):
        args = parser_assessment.parse_args()
        o = Assessment()
        o.name = args["name"]
        o.access_log_enabled = args["access_log_enabled"]
        o.snooze = args["snooze"]
        o.run_once = args["run_once"]

        try:
            db.session.add(o)
            db.session.commit()
        except IntegrityError, exc:
            app.logger.warn(exc.message)
            return {"error": exc.message}, 500
Ejemplo n.º 4
0
    def post(self):
        args = parser_assessment.parse_args()
        o = Assessment()
        o.name = args["name"]
        o.access_log_enabled = args["access_log_enabled"]
        o.snooze = args["snooze"]
        o.run_once = args["run_once"]

        try:
            db.session.add(o)
            db.session.commit()
        except IntegrityError, exc:
            app.logger.warn(exc.message)
            return {"error": exc.message}, 500
Ejemplo n.º 5
0
def create_bootstrap_assessment(name="General", add_default_payloads=True):
    """
    Creates an assessment and attaches a few default payloads.
    """
    from sleepypuppy.admin.assessment.models import Assessment
    from sleepypuppy.admin.payload.models import Payload
    assessment = Assessment.query.filter(Assessment.name == name).first()
    if assessment:
        print("Assessment with name", name, "already exists.")
    else:
        assessment = Assessment(name=name)

    if add_default_payloads:
        for payload in DEFAULT_PAYLOADS:
            payload = Payload(payload=payload.payload,
                              url=payload.url,
                              method=payload.method,
                              parameter=payload.parameter,
                              notes=payload.notes)
            assessment.payloads.append(payload)
    db.session.add(assessment)
    db.session.commit()