Exemplo n.º 1
0
class SecurityReport(BaseModel, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    report_id = db.Column(db.Integer, nullable=False)
    issue_hash = db.Column(db.String(80), unique=False)
    tool_name = db.Column(db.String(80), unique=False)
    description = db.Column(db.String(80), unique=False)
    severity = db.Column(db.String(10), unique=False)
    details = db.Column(db.Integer, unique=False)
    endpoints = db.Column(db.Text, unique=False)
    false_positive = db.Column(db.Integer, unique=False)
    info_finding = db.Column(db.Integer, unique=False)
    excluded_finding = db.Column(db.Integer, unique=False)

    def to_json(self):
        return dict(id=self.id,
                    report_id=self.report_id,
                    issue_hash=self.issue_hash,
                    tool_name=self.tool_name,
                    description=self.description,
                    severity=self.severity,
                    details=self.details,
                    endpoints=self.endpoints,
                    false_positive=self.false_positive,
                    info_finding=self.info_finding,
                    excluded_finding=self.excluded_finding)
Exemplo n.º 2
0
class APIRelease(BaseModel, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    release_date = db.Column(db.String(80), unique=False)
    release_name = db.Column(db.String(80), unique=False)

    def to_json(self):
        return dict(id=self.id,
                    release_date=self.release_date,
                    release_name=self.release_name)
Exemplo n.º 3
0
class Results(BaseModel, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    task_id = db.Column(db.String(80), unique=False, nullable=False)
    ts = db.Column(db.Integer, unique=False, nullable=False)
    results = db.Column(db.String(80), unique=False, nullable=False)
    log = db.Column(db.String(256), unique=False, nullable=False)

    def to_json(self):
        return dict(id=self.id,
                    task_id=self.task_id,
                    ts=self.ts,
                    results=self.results,
                    log=self.log)
Exemplo n.º 4
0
class SecurityDetails(BaseModel, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    detail_hash = db.Column(db.String(80), unique=False)
    details = db.Column(db.Text, unique=False)

    def to_json(self):
        return dict(id=self.id,
                    detail_hash=self.detail_hash,
                    details=self.details)
Exemplo n.º 5
0
class Results(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    task_id = db.Column(db.String(80), unique=False, nullable=False)
    ts = db.Column(db.Integer, unique=False, nullable=False)
    results = db.Column(db.String(80), unique=False, nullable=False)
    log = db.Column(db.String(256), unique=False, nullable=False)

    def __repr__(self):
        return dumps(dict(task_id=self.task_id,
                          ts=self.ts,
                          results=self.results),
                     indent=2)

    def insert(self):
        db.session.add(self)
        db.session.commit()

    def delete(self):
        db.session.delete(self)
        db.session.commit()

    @staticmethod
    def commit():
        db.session.commit()
Exemplo n.º 6
0
class APIReport(BaseModel, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), unique=False)
    environment = db.Column(db.String(80), unique=False)
    type = db.Column(db.String(80), unique=False)
    end_time = db.Column(db.String(80), unique=False)
    start_time = db.Column(db.String(80), unique=False)
    failures = db.Column(db.Integer, unique=False)
    total = db.Column(db.Integer, unique=False)
    thresholds_missed = db.Column(db.Integer, unique=False, nullable=True)
    throughput = db.Column(db.Float, unique=False)
    vusers = db.Column(db.Integer, unique=False)
    pct95 = db.Column(db.Float, unique=False)
    duration = db.Column(db.Integer, unique=False)
    build_id = db.Column(db.String(80), unique=True)
    lg_type = db.Column(db.String(12), unique=False)
    onexx = db.Column(db.Integer, unique=False)
    twoxx = db.Column(db.Integer, unique=False)
    threexx = db.Column(db.Integer, unique=False)
    fourxx = db.Column(db.Integer, unique=False)
    fivexx = db.Column(db.Integer, unique=False)
    requests = db.Column(db.Text, unique=False)
    release_id = db.Column(db.Integer, nullable=True)

    def to_json(self):
        return {
            "id": self.id,
            "start_time": self.start_time,
            "name": self.name,
            "environment": self.environment,
            "type": self.type,
            "end_time": self.end_time,
            "failures": self.failures,
            "total": self.total,
            "thresholds_missed": self.thresholds_missed,
            "throughput": self.throughput,
            "vusers": self.vusers,
            "pct95": self.pct95,
            "duration": self.duration,
            "lg_type": self.lg_type,
            "build_id": self.build_id,
            "1xx": self.onexx,
            "2xx": self.twoxx,
            "3xx": self.threexx,
            "4xx": self.fourxx,
            "5xx": self.fivexx,
            "requests": self.requests.split(";"),
            "release_id": self.release_id
        }
Exemplo n.º 7
0
class Task(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    task_id = db.Column(db.String(80), unique=True, nullable=False)
    zippath = db.Column(db.String(80), unique=True, nullable=False)
    task_name = db.Column(db.String(80), unique=False, nullable=False)
    task_handler = db.Column(db.String(80), unique=False, nullable=False)
    runtime = db.Column(db.String(80), unique=False, nullable=False)
    schedule = db.Column(db.String(80), unique=False, nullable=True)
    next_run = db.Column(db.Integer, unique=False, nullable=True)
    webhook = db.Column(db.String(80), unique=False, nullable=True)
    last_run = db.Column(db.Integer, unique=False, nullable=True)
    status = db.Column(db.String(80), unique=False, nullable=True)
    token = db.Column(db.String(80), unique=False, nullable=True)
    func_args = db.Column(db.Text, unique=False, nullable=True)
    callback = db.Column(db.String(80), unique=False, nullable=True)

    def __repr__(self):
        return dumps(self.to_json(), indent=2)

    def to_json(self):
        if self.schedule and self.schedule in ['None', 'none', '']:
            self.schedule = None
        if self.callback and self.callback in ['None', 'none', '']:
            self.callback = None
        return dict(task_id=self.task_id,
                    task_name=self.task_name,
                    task_handler=self.task_handler,
                    runtime=self.runtime,
                    schedule=self.schedule,
                    webhook=self.webhook,
                    zippath=self.zippath,
                    last_run=self.last_run,
                    status=self.status,
                    token=self.token,
                    func_args=self.func_args,
                    callback=self.callback)

    def insert(self):
        if self.schedule and self.schedule in ['None', 'none']:
            self.schedule = None
        if self.callback and self.callback in ['None', 'none']:
            self.callback = None
        if not self.webhook:
            self.webhook = f'/task/{self.task_id}'
        if not self.status:
            self.status = 'suspended'
        if not self.token:
            self.token = str(uuid4())
        if not self.func_args:
            self.func_args = "{}"
        db.session.add(self)
        db.session.commit()

    def suspend(self):
        self.status = 'suspended'
        db.session.commit()

    def activate(self):
        self.status = 'active'
        db.session.commit()

    def set_last_run(self, ts):
        self.last_run = ts
        db.session.commit()

    def delete(self):
        db.session.delete(self)
        db.session.commit()

    @staticmethod
    def commit():
        db.session.commit()