def nessus_controller_ubuntu_cpa(self): """Ubuntu controller Credentialed Patch Audit. Scenario: 1. Configure Nessus to run Credentialed Patch Audit against MOS controller on Ubuntu 2. Start scan 3. Download scan results Duration 40 min Snapshot nessus_controller_ubuntu_cpa """ self.env.revert_snapshot("deploy_neutron_tun_ha_nessus") self.enable_password_login_for_ssh_on_slaves(['slave-01']) if settings.NESSUS_ADDRESS is None: settings.NESSUS_ADDRESS = \ self.find_nessus_address(nessus_net_name='admin', nessus_port=settings.NESSUS_PORT) nessus_client = nessus.NessusClient(settings.NESSUS_ADDRESS, settings.NESSUS_PORT, settings.NESSUS_USERNAME, settings.NESSUS_PASSWORD, settings.NESSUS_SSL_VERIFY) scan_start_date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) scan_name = "Scan CPA {0}".format(scan_start_date) policies_list = nessus_client.list_policy_templates() cpa_policy_template = [ template for template in policies_list if template['title'] == 'Credentialed Patch Audit' ][0] policy_id = nessus_client.add_cpa_policy(scan_name, settings.ENV_NAME, cpa_policy_template['uuid']) slave_address = \ self.fuel_web.get_nailgun_node_by_name('slave-01')['ip'] scan_id = nessus_client.create_scan(scan_name, settings.ENV_NAME, slave_address, policy_id, cpa_policy_template['uuid']) scan_uuid = nessus_client.launch_scan(scan_id) history_id = nessus_client.list_scan_history_ids(scan_id)[scan_uuid] check_scan_complete = self.get_check_scan_complete( nessus_client, scan_id, history_id) wait(check_scan_complete, interval=10, timeout=60 * 30) file_id = nessus_client.export_scan(scan_id, history_id, 'html') nessus_client.download_scan_result(scan_id, file_id, 'controller_cpa', 'html', settings.LOGS_DIR) self.env.make_snapshot("nessus_controller_ubuntu_cpa")
def nessus_fuel_master_wat(self): """Fuel master Advanced Web Services tests. Scenario: 1. Configure Nessus to run Advanced Web Services tests againstFuel Master 2. Start scan 3. Download scan results Duration 40 min Snapshot nessus_fuel_master_wat """ self.env.revert_snapshot("deploy_neutron_tun_ha_nessus") if settings.NESSUS_ADDRESS is None: settings.NESSUS_ADDRESS = \ self.find_nessus_address(nessus_net_name='admin', nessus_port=settings.NESSUS_PORT) nessus_client = nessus.NessusClient(settings.NESSUS_ADDRESS, settings.NESSUS_PORT, settings.NESSUS_USERNAME, settings.NESSUS_PASSWORD, settings.NESSUS_SSL_VERIFY) scan_start_date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) scan_name = "Scan WAT {0}".format(scan_start_date) policies_list = nessus_client.list_policy_templates() wat_policy_template = [ template for template in policies_list if template['title'] == 'Web Application Tests' ][0] policy_id = nessus_client.add_wat_policy(scan_name, settings.ENV_NAME, wat_policy_template['uuid']) scan_id = nessus_client.create_scan(scan_name, settings.ENV_NAME, self.fuel_web.admin_node_ip, policy_id, wat_policy_template['uuid']) scan_uuid = nessus_client.launch_scan(scan_id) history_id = nessus_client.list_scan_history_ids(scan_id)[scan_uuid] check_scan_complete = self.get_check_scan_complete( nessus_client, scan_id, history_id) wait(check_scan_complete, interval=10, timeout=60 * 50, timeout_msg='Timeout: nessus scan status != completed') file_id = nessus_client.export_scan(scan_id, history_id, 'html') nessus_client.download_scan_result(scan_id, file_id, 'master_wat', 'html', settings.LOGS_DIR) self.env.make_snapshot("nessus_fuel_master_wat")
def nessus_fuel_master_cpa(self): """Fuel master Credentialed Patch Audit. Scenario: 1. Configure Nessus to run Credentialed Patch Audit against Fuel Master 2. Start scan 3. Download scan results Duration 40m Snapshot nessus_fuel_master_cpa """ self.env.revert_snapshot("deploy_neutron_tun_ha_nessus") if CONF.NESSUS_ADDRESS is None: CONF.NESSUS_ADDRESS = \ self.find_nessus_address(nessus_net_name='admin', nessus_port=CONF.NESSUS_PORT) nessus_client = nessus.NessusClient(CONF.NESSUS_ADDRESS, CONF.NESSUS_PORT, CONF.NESSUS_USERNAME, CONF.NESSUS_PASSWORD, CONF.NESSUS_SSL_VERIFY) scan_start_date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) scan_name = "Scan CPA {0}".format(scan_start_date) policies_list = nessus_client.list_policy_templates() cpa_policy_template = filter( lambda template: template['title'] == 'Credentialed Patch Audit', policies_list)[0] policy_id = nessus_client.add_cpa_policy(scan_name, CONF.ENV_NAME, cpa_policy_template['uuid']) scan_id = nessus_client.create_scan(scan_name, CONF.ENV_NAME, self.fuel_web.admin_node_ip, policy_id, cpa_policy_template['uuid']) scan_uuid = nessus_client.launch_scan(scan_id) history_id = nessus_client.list_scan_history_ids(scan_id)[scan_uuid] check_scan_complete = self.get_check_scan_complete( nessus_client, scan_id, history_id) wait(check_scan_complete, interval=10, timeout=60 * 30) file_id = nessus_client.export_scan(scan_id, history_id, 'html') nessus_client.download_scan_result(scan_id, file_id, 'master_cpa', 'html', LOGS_DIR) self.env.make_snapshot("nessus_fuel_master_cpa")