ossim_valid($asset_filter, OSS_NULLABLE, OSS_NOECHARS, OSS_ALPHA, OSS_SCORE, OSS_PUNC, '()', 'illegal:' . _('Asset filter')); ossim_valid($sensor_id, OSS_HEX, 'illegal:' . _('Sensor ID')); if (!ossim_error()) { $_assets = array(); $db = new ossim_db(); $conn = $db->connect(); $q_where = "hsr.host_id = host.id AND hsr.sensor_id=UNHEX('{$sensor_id}')\n AND NOT exists (select 1 FROM hids_agents ha WHERE ha.host_id = host.id)"; if (!empty($asset_filter)) { $pos = strpos($asset_filter, ' '); if ($pos === FALSE) { $asset_filter = escape_sql($asset_filter, $conn, TRUE); $asset_name = $asset_filter; $asset_ip = $asset_filter; $q_where .= " AND (host.hostname LIKE '%{$asset_name}%' OR INET6_NTOA(hi.ip) LIKE '%{$asset_ip}%')"; } else { $aux_asset_filter = explode(' ', $asset_filter, 2); $asset_name = $aux_asset_filter[0]; $asset_ip = str_replace(array('(', ')'), '', $aux_asset_filter[1]); $asset_name = escape_sql($asset_name, $conn, TRUE); $asset_ip = escape_sql($asset_ip, $conn, TRUE); $q_where .= " AND (host.hostname LIKE '%{$asset_name}%' AND INET6_NTOA(hi.ip) LIKE '%{$asset_ip}%')"; } } $q_filters = array('where' => $q_where, 'limit' => 20); $_assets = Asset_host::get_list_tree($conn, ', host_sensor_reference hsr', $q_filters); $db->close(); $assets = array(); foreach ($_assets as $asset_id => $asset_data) { echo $asset_id . '###' . $asset_data[2] . '###' . $asset_data[3] . '###' . $asset_data[3] . ' (' . $asset_data[2] . ")\n"; } }
function get_allowed_hosts($conn, $tables = '', $filters = array()) { $filters['order_by'] = 'hostname'; $hosts = Asset_host::get_list_tree($conn, $tables, $filters, FALSE, FALSE); return $hosts; }
} if ($total_selected == $total_assets) { //All assets were selected, so we filter them by OS $os_filters = array('where' => '(host_properties.value NOT LIKE "windows%" AND host_properties.value NOT LIKE "microsoft%")'); list($os_list, $total_os) = Asset_host_properties::get_property_values($conn, 3, $os_filters); $filters->modify_filter(20, 'unknown', 0); foreach ($os_list as $os_key => $os_value) { $filters->modify_filter(20, $os_value, 0); } } else { //Not all assets were selected, so we filter by asset //Getting assets with unknown or Linux/UNIX Operating System $tables = 'LEFT JOIN host_properties hp ON hp.host_id=host.id AND hp.property_ref=3 INNER JOIN user_component_filter f ON f.asset_id = host.id'; $os_filters = array('where' => '((hp.host_id IS NULL OR hp.value IS NULL OR hp.value LIKE "%unknown%") OR (hp.value NOT LIKE "windows%" AND hp.value NOT LIKE "microsoft%")) AND f.asset_type="asset" AND f.session_id = "' . session_id() . '"'); $unsupported_assets = Asset_host::get_list_tree($conn, $tables, $os_filters, FALSE, TRUE); foreach ($unsupported_assets as $a_data) { $filters->modify_filter(11, $a_data[2], 0); } } $filters->store_filter_list_session(); } catch (Exception $e) { $db->close(); $error_msg = '<div style="padding-left:5px">' . _('The following errors occurred') . ":</div>\n <div style='padding: 5px 5px 5px 15px;'>" . $e->getMessage() . '</div>'; Util::response_bad_request($error_msg); } break; case 'remove_unsupported': $data['status'] = 'success'; $data['data'] = _('Your changes have been saved'); try {