Example #1
0
def update_resolved_issue_in_db(row, value):
    with db_session:
        value.status = row[Issue.status]
        value.issue_fixed_scan_id = row[Issue.issue_fixed_scan_id]
        value.issue_fixed_scan_date = convert_to_datetime(row[Issue.issue_fixed_scan_date])
        value.scan = row[Issue.scan]
        value.scan_date = convert_to_datetime(row[Issue.scan_date])
        db.commit()
Example #2
0
def save_file_contents_to_db(reader: csv.DictReader):
    for row in reader:
        if not issue_in_db(row):
            save_row_to_db(row)
        elif issue_status_change(row) or issue_severity_change(row):
            update_issue_if_required(row)
        else:
            # print("existing issue")
            pass
    db.commit()
Example #3
0
def run_project_reports():
    projects = Project.select()
    if len(projects) > 0:
        print(f"running reports for {len(projects)} projects")
        for project in projects:
            high, medium, low = report_entries(project)
            report = ProjectReport(project=project, date=datetime.now())
            report.severity_high = high
            report.severity_medium = medium
            report.severity_low = low
        db.commit()
    else:
        print("no reports found")
Example #4
0
def project_status():
    with db_session:
        projects = Project.select(
            lambda p: p.status == "New" or p.status == "Skip")
        if len(projects) > 0:
            for project in projects:
                print()
                prompt = Bullet(
                    prompt=
                    f"Run reports for {project.project}, Current status: {project.status}",
                    choices=['Include', 'Exclude', 'Skip'])
                result = prompt.launch()
                project.status = result
            db.commit()
Example #5
0
def update_issue_if_required(row):
    value: Vulnerability = Vulnerability.get(issue_id=row[Issue.issue_id])
    if value.status == Issue.open \
            and row[Issue.status] == Issue.resolved:
        update_resolved_issue_in_db(row, value)
    elif row[Issue.severity] != value.severity:
        value.severity = row[Issue.severity]
        value.cvss_score = row[Issue.cvss_score]
        db.commit()
        print("severity updated")

    elif value.issue_opened_scan_id == int(row[Issue.issue_opened_scan_id]):
        print(f"{value.project_name}: {value.vulnerability_id}: previously updated")
    else:
        print("ERROR")
        print(f"There is some thing else going on here: {value.project}: {value.vulnerability_id}")
        print(f"{value.issue_opened_scan_date} > {convert_to_datetime(row[Issue.issue_opened_scan_date])} : "
              f"{value.issue_opened_scan_date > convert_to_datetime(row[Issue.issue_opened_scan_date])}")
Example #6
0
def run():

    run_project_reports()

    # Finial report is below
    skipped_projects_note()
    exclude_projects_note()

    projects = projects_to_be_reported_on()

    if projects is not None:
        last_report = OverviewReport.select().sort_by(desc(
            OverviewReport.date)).first()
        current_report = OverviewReport(date=datetime.now())

        for project in projects:
            current_report.project_reports.add(project.latest_report())
        current_report.compile_totals()
        db.commit()

        print_summary_report(current_report, last_report)
        email_creation(current_report, last_report)