Ejemplo n.º 1
0
 def init_db(self):
     connect('trafalgar')
     for row in self.all_ecdc_data:
         date = row[0]
         country = str(row[6])
         geo_id = str(row[7])
         cases = row[4]
         deaths = row[5]
         report = Report(date=date, country=country, geo_id=geo_id, \
                 cases=cases, deaths=deaths)
         report.save()
     
     print("Database initialized")
Ejemplo n.º 2
0
def get_sprint_report(project_id, sprint_id):
    """Get report for sprint
    :param sprint_id: A ID of sprint
    :return Sprint report"""

    result = Report.query.with_entities(Report.description).filter(Report.sprint_id == sprint_id).first()

    if result:
        result = literal_eval(result[0])
        return jsonify(result)

    result = Task.query.with_entities(Employee.first_name, Employee.last_name, func.sum(Worklog.logged_hours)).filter(
        Task.sprint_id == sprint_id,
        ProjectEmployeeRole.project_id == project_id, ProjectEmployeeRole.employee_id == Employee.id,
        Worklog.task_id == Task.id, Employee.id == Worklog.employee_id).group_by(
        Worklog.employee_id).all()

    result = [[x, y, str(z)] for x, y, z in result]
    result_str = str(result)
    report = Report(sprint_id=sprint_id, description=result_str)
    db.session.add(report)
    db.session.commit()

    report = Report.query.filter(Report.sprint_id == sprint_id).first()
    return jsonify(result)
Ejemplo n.º 3
0
def submit_report_to_db(date, scan_id, report_filename, events_num, verbose, api_flag, report_type, graph_flag,
                        category, profile, scan_method, language, scan_cmd, ports):
    """
    this function created to submit the generated reports into db, the files are not stored in db, just the path!

    Args:
        date: date and time
        scan_id: scan hash id
        report_filename: report full path and filename
        events_num: length of events in the report
        verbose: verbose level used to generated the report
        api_flag: 0 (False) if scan run from CLI and 1 (True) if scan run from API
        report_type: could be TEXT, JSON or HTML
        graph_flag: name of the graph used (if it's HTML type)
        category: category of the modules used in scan (vuln, scan, brute)
        profile: profiles used in scan
        scan_method: modules used in scan
        language: scan report language
        scan_cmd: scan command line if run in CLI otherwise messages(language,"through_API")
        ports: selected port otherwise None

    Returns:
        return True if submitted otherwise False
    """
    info(messages(language, "inserting_report_db"))
    session = create_connection(language)
    session.add(Report(
        date=date, scan_id=scan_id, report_filename=report_filename, events_num=events_num, verbose=verbose,
        api_flag=api_flag, report_type=report_type, graph_flag=graph_flag, category=category, profile=profile,
        scan_method=scan_method, language=language, scan_cmd=scan_cmd, ports=ports
    ))
    return send_submit_query(session, language)
Ejemplo n.º 4
0
def submit_report_to_db(event):
    """
    this function created to submit the generated reports into db, the files are not stored in db, just the path!

    Args:
        event: event log

    Returns:
        return True if submitted otherwise False
    """
    verbose_info(messages("inserting_report_db"))
    session = create_connection()
    session.add(
        Report(
            date=event["date"],
            scan_unique_id=event["scan_unique_id"],
            report_path_filename=json.dumps(
                event["options"]["report_path_filename"]),
            options=json.dumps(event["options"]),
        ))
    return send_submit_query(session)
Ejemplo n.º 5
0
 def get(self):
     reports = Report.objects().to_json()
     return Response(reports, mimetype="application/json", status=200)
Ejemplo n.º 6
0
 def post(self):
     body = request.get_json()
     report = Report(**body).save()
     id = report.id
     return {'id': str(id)}, 200