def post(self, data=None): """ .. http:post:: /analysis The current list of analysiss **Example request**: .. sourcecode:: http GET /analysis HTTP/1.1 Host: example.com Accept: application/json, text/javascript **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript # TODO :statuscode 200: no error :statuscode 403: unauthenticated """ try: return analysis(**data) except TargetNotFound as ex: return {'message': ex.message}, 404
def analysis(target_key, analysis_plugin, target_plugin, persistence_plugin, collection_plugin, payload_plugin, incident_id, **kwargs): """Creates a new analysis based on collected data.""" result = analysis(target_key, incident_id, target_plugin, persistence_plugin, collection_plugin, payload_plugin, analysis_plugin, **kwargs) for r in result: if r['diff']: click.secho(r['instance_id'] + ': Differences found.', fg='red') click.secho(json.dumps(r['diff'], indent=2), fg='red') else: click.secho(r['instance_id'] + ': No Differences Found.', fg='green')
def analysis_command(target_key, analysis_plugin, target_plugin, persistence_plugin, collection_plugin, payload_plugin, incident_id, **kwargs): """Creates a new analysis based on collected data.""" result = analysis( target_key, target_plugin, payload_plugin, collection_plugin, persistence_plugin, analysis_plugin, **kwargs, ) for r in result['analysis']: if r['diff']: click.secho( r['instance_id'] + ': Differences found.', fg='red') click.secho(json.dumps(r['diff'], indent=2), fg='red') else: click.secho(r["instance_id"] + ": No Differences Found.", fg="green")
def async_analysis(kwargs): """Wrapper job around our standard analysis task.""" # we can't pickle our objects for remote works so we pickle the raw request and then load it here. data = analysis_input_schema.load(kwargs).data return analysis(**data)