$asset_object = unserialize($_SESSION['asset_detail'][$group_id]); if (!is_object($asset_object)) { throw new Exception(_('Error retrieving the asset data from memory')); } // Get the hosts from another groups if ($asset_type == 'othergroups') { $where = " id NOT IN (SELECT host_id FROM host_group_reference WHERE host_group_id = UNHEX('" . $group_id . "')) "; $filters['where'] = !empty($filters['where']) ? $where . ' AND ' . $filters['where'] : $where; list($host_list, $total) = Asset_host::get_list($conn, '', $filters, $cache); } else { list($host_list, $total) = $asset_object->get_hosts($conn, $filters, FALSE); } // DATA $data = array(); foreach ($host_list as $host_id => $host_data) { $devices = Asset_host_devices::get_devices_to_string($conn, $host_id); // Asset Group details format if ($asset_type == 'group') { try { $asset_object->can_i_edit($conn); $asset_object->can_delete_host($conn); $delete_link = '<a href="javascript:;" onclick="del_asset_from_group(\'' . $host_id . '\');return false">'; $delete_link .= '<img class="delete_small tipinfo" txt="' . _('Remove this asset from group') . '" src="/ossim/pixmaps/delete.png" border="0"/>'; $delete_link .= '</a>'; } catch (Exception $e) { $title = $e->getMessage(); $delete_link = '<img class="delete_small img_disabled tipinfo" txt="' . $title . '" src="/ossim/pixmaps/delete.png" border="0"/>'; } $data[] = array($host_data['name'], $host_data['ips'], $host_data['fqdns'], $devices, Util::utf8_encode2($host_data['descr']), $delete_link); } elseif ($asset_type == 'net') { $data[] = array($host_data['name'], $host_data['ips'], $host_data['fqdns'], $devices, Util::utf8_encode2($host_data['descr']));
function plugin_activity($conn, $data) { $asset_id = $data['asset']; ossim_valid($asset_id, OSS_HEX, 'illegal:' . _("ASSET")); check_ossim_error(); $active_plugin = array(); $total_plugins = 0; try { $sensors = Asset_host_sensors::get_sensors_by_id($conn, $asset_id); $client = new Alienvault_client(); foreach ($sensors as $sensor_id => $s_data) { $plugins = $client->sensor(Util::uuid_format($sensor_id))->get_plugins_by_assets(); $plugins = @json_decode($plugins, TRUE); if ($plugins['status'] == 'success') { if (array_key_exists($asset_id, $plugins['data']['plugins'])) { $plugins = $plugins['data']['plugins'][$asset_id]; foreach ($plugins as $pdata) { $active = Asset_host_devices::check_device_connectivity($conn, $asset_id, $pdata['plugin_id'], $sensor_id, TRUE); if ($active) { $row_id = md5($asset_id . $pdata['cpe'] . $sensor_id); $active_plugin[$row_id] = TRUE; } $total_plugins++; } } } } } catch (Exception $e) { //nothing here } $response['error'] = FALSE; $response['data']['plugins'] = $active_plugin; $response['data']['total_p'] = $total_plugins; return $response; }
try { list($assets, $total) = Asset_host::get_full_list($conn, $tables, $filters); } catch (Exception $e) { $response = array(); $response['sEcho'] = $sec; $response['iTotalRecords'] = 0; $response['iTotalDisplayRecords'] = 0; $response['aaData'] = array(); $response['iDisplayStart'] = 0; echo json_encode($response); exit; } $detail = ''; $results = array(); foreach ($assets as $_id => $asset_data) { $d_types = Asset_host_devices::get_devices_to_string($conn, $_id); if (preg_match('/<br\\/>/', $d_types)) { $d_types = preg_replace('/<br\\/>.*/', '', $d_types) . '...'; } // COLUMNS $_res = array(); $_res['DT_RowId'] = $_id; $_res[] = ''; //Checkbox $_res[] = Util::htmlentities($asset_data['name']); //Hostname $_res[] = Util::htmlentities(Asset::format_to_print($asset_data['ips'])); //IP $_res[] = $d_types; //Device Type $_res[] = $asset_data['os'];
$total = 0; } $results = array(); foreach ($assets as $_id => $asset_data) { $_res = array(); // Get OS $os = implode(' ', Asset_host_properties::get_property_from_db($conn, $_id, 3)); $_os = ''; $_dev = ''; if (preg_match("/windows/i", $os)) { $_os = 'Windows'; } elseif (preg_match("/linux/i", $os)) { $_os = 'Linux'; } // Get device types $_devices = new Asset_host_devices($conn, $_id); $_devices->load_from_db($conn); $devices = $_devices->get_devices(); if ($_os == 'Windows') { $_dev = 'windows_'; } elseif (is_array($devices[1]) && !empty($devices[1])) { if ($_os == 'Linux') { $_dev = 'linux_server'; } else { $_dev = '_'; } } elseif (is_array($devices[4]) && !empty($devices[4])) { $_dev = '_networkdevice'; } elseif (count($devices) > 0) { $_dev = '_'; }
function net_devices_activity($conn) { $response = array(); $wizard = Welcome_wizard::get_instance(); if ($wizard === FALSE) { throw new Exception(_("There was an error, the Welcome_wizard object doesn't exist. Try again later")); } $plugins = array(); $flag_end = FALSE; $task_id = $wizard->get_step_data('task_id'); if ($task_id == 'ffffffff-ffff-ffff-ffff-ffffffffffff') { $status = 1; } else { $status = Welcome_wizard::current_jobs($task_id); $status = in_array($status['job_status'], array('task-failed', 'task-succeeded', 'task-revoked')) ? 1 : 0; } if ($status == 1) { $devices = Plugin::get_plugins_by_assets(); foreach ($devices as $h_id => $p_data) { $h_id = Util::uuid_format_nc($h_id); $p_data = is_array($p_data) ? $p_data : array(); foreach ($p_data as $pkey => $pdata) { $active = Asset_host_devices::check_device_connectivity($conn, $h_id, $pdata['plugin_id'], '', TRUE); $plugins[$h_id][$pkey] = $active; if ($flag_end) { $flag_end = TRUE; } } } } $wizard->set_step_data('net_devices_data', $flag_end); $wizard->save_status(); $response['error'] = FALSE; $response['data']['plugins'] = $plugins; $response['data']['status'] = $status; return $response; }