require $init_file; $insert_model = Model::factory('vulndb_insert'); $vulndb = Model::factory('vulndb_main'); $vdb_config = Config::load('vulndb'); Logger::msg('info', array('message' => 'Starting the asset data report updater')); $accounts = $vulndb->getaccounts(); foreach ($accounts as $account) { $now = date('c'); $account_name = $account['account']; $username = $account['username']; $password = CryptAES::decrypt($account['password']); $url1 = 'https://' . $account['api_url'] . '/msp/'; $url2 = 'https://' . $account['api_url'] . '/api/2.0/fo/'; $api1 = new QualysAPI_v1(); Logger::msg("info", array("message" => "fetching report list", 'account' => $account_name, 'api_call' => 'report_template_list', 'api_version' => 1)); $report_template_xml = $api1->report_template_list($url1, $username, $password); // Check that we got valid XML if (!$vulndb->is_xml($report_template_xml)) { Logger::msg("error", array('message' => 'what I got back from the API call was not XML')); Logger::msg("info", array('report_template_xml' => $report_template_xml)); exit; } // Delete the current report templates in the table for this account $delete_templates = DB::query(Database::DELETE, "DELETE FROM " . REPORT_TEMPLATE_TABLE . " WHERE ACCOUNT = :account")->bind(":account", $account_name)->execute(); Logger::msg("info", array("message" => "deleted report templates", "table" => REPORT_TEMPLATE_TABLE, "account" => $account_name, "rows_deleted" => $delete_templates)); // Put the report template list in the DB $insert = $insert_model->report_templates($report_template_xml, $account_name); Logger::msg("info", array("message" => "report templates inserted for account", "table" => REPORT_TEMPLATE_TABLE, "account" => $account_name, "rows_inserted" => $insert)); // Now lets download our reports defined in config/vulndb.php // Get the reports defined in config/vulndb.php $report_ids = $vdb_config['adr_reports'][$account_name];