Beispiel #1
0
 def send_report_request(self, workspace_name, report_json, user):
     logger.info("Send Report data to workspace [%s]", workspace_name)
     from faraday.server.web import app  # pylint:disable=import-outside-toplevel
     with app.app_context():
         ws = Workspace.query.filter_by(name=workspace_name).one()
         schema = BulkCreateSchema()
         data = schema.load(report_json)
         data = add_creator(data, user)
         bulk_create(ws, data, True)
Beispiel #2
0
def send_report_data(workspace_name: str, command_id: int, report_json: dict,
                     user_id: Optional[int], set_end_date: bool):
    logger.info("Send Report data to workspace [%s]", workspace_name)
    ws = Workspace.query.filter_by(name=workspace_name).one()
    command = Command.query.filter_by(id=command_id).one()
    schema = BulkCreateSchema()
    data = schema.load(report_json)
    if user_id:
        user = User.query.filter_by(id=user_id).one()
        data = add_creator(data, user)
    bulk_create(ws, command, data, True, set_end_date)
Beispiel #3
0
 def send_report_request(self, workspace_name: str, command_id: int,
                         report_json: dict, user_id: int):
     logger.info("Send Report data to workspace [%s]", workspace_name)
     from faraday.server.web import get_app  # pylint:disable=import-outside-toplevel
     with get_app().app_context():
         ws = Workspace.query.filter_by(name=workspace_name).one()
         command = Command.query.filter_by(id=command_id).one()
         user = User.query.filter_by(id=user_id).one()
         schema = BulkCreateSchema()
         data = schema.load(report_json)
         data = add_creator(data, user)
         bulk_create(ws, command, data, True, True)
Beispiel #4
0
def test_schema_on_all_reports(report_filename):
    plugin, plugin_json = get_report_json_from_cache(report_filename)
    if plugin_json:
        serializer = BulkCreateSchema()
        res = serializer.loads(json.dumps(plugin_json))
        assert set(res.keys()) == {'hosts', 'command'}