def get_all_vulnerabilities(information): if information['email'] is None: return ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) vulnerabilities = mongo.get_vulnerabilities_for_email(information) df = pd.DataFrame(vulnerabilities) if df.empty: return df.to_csv(ROOT_DIR + '/output.csv', index=False, columns=[ 'domain', 'resource', 'vulnerability_name', 'observation', 'extra_info', 'date_found', 'last_seen', 'language', 'cvss_score', 'vuln_type', 'state' ]) email_handler.send_email_with_attachment( ROOT_DIR + '/output.csv', information['email'], "CSV with vulnerabilities attached to email", "Orchestrator: Vulnerabilities found!") try: os.remove(ROOT_DIR + '/output.csv') except FileNotFoundError: print('ERROR Output file for resources was not found') pass return
def send_email_with_all_resources(scan_information): ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) resources = mongo.get_all_resources_for_email() df = pd.DataFrame(resources) if df.empty: return df.to_csv(ROOT_DIR + '/output.csv', index=False, columns=[ 'domain', 'subdomain', 'url', 'ip', 'priority', 'exposition', 'asset_value', 'isp', 'asn', 'country', 'region', 'city', 'org', 'geoloc', 'first_seen', 'last_seen', 'is_alive', 'has_urls', 'approved', 'scan_type' ]) email_handler.send_email_with_attachment( ROOT_DIR + '/output.csv', scan_information['email'], "CSV with resources attached to email", "Orchestrator: Returning all resources") try: os.remove(ROOT_DIR + '/output.csv') except FileNotFoundError: print('ERROR Output file for resources was not found') pass return
def on_demand_scan_finished(results, information): add_scanned_resources(information) if information['email'] is None: return # TODO REMOVE Send email with scan results vulnerabilities = mongo.get_vulnerabilities_for_email(information) df = pd.DataFrame(vulnerabilities) if df.empty: print('No vulns found! Canceling email') return from VM_OrchestratorApp.src.utils import email_handler ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) df.to_csv(ROOT_DIR + '/output.csv', index=False, columns=[ 'domain', 'resource', 'vulnerability_name', 'extra_info', 'date_found', 'last_seen', 'language', 'state' ]) email_handler.send_email_with_attachment( ROOT_DIR + '/output.csv', information['email'], "CSV with vulnerabilities attached to email", "Orchestrator: Vulnerabilities found!") try: os.remove(ROOT_DIR + '/output.csv') except FileNotFoundError: print('ERROR:Output for on demand scan was not found') pass slack.send_notification_to_channel( '_ On demand scan against %s finished! _' % information['resource'], '#vm-ondemand') return