本文整理汇总了PHP中Av_exception::write_log方法的典型用法代码示例。如果您正苦于以下问题:PHP Av_exception::write_log方法的具体用法?PHP Av_exception::write_log怎么用?PHP Av_exception::write_log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Av_exception
的用法示例。
在下文中一共展示了Av_exception::write_log方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$curid = $rs->fields['id'];
}
}
$id = Av_report::get_new_report_module_id($conn);
if ($curid > 0) {
$sql = "UPDATE custom_report_types SET name=?,type='Custom Security Events',file='SIEM/CustomList.php',inputs='Number of Events:top:text:OSS_DIGIT:25:1000',custom_report_types.sql=? WHERE id=?";
$params = array($name, "{$query1};{$query2};{$columns}", $curid);
} else {
$sql = "INSERT INTO custom_report_types (id,name,type,file,inputs,custom_report_types.sql) VALUES (?,?,'Custom Security Events','SIEM/CustomList.php','Number of Events:top:text:OSS_DIGIT:25:1000',?)";
$params = array($id, $name, "{$query1};{$query2};{$columns}");
}
if ($conn->Execute($sql, $params)) {
$msg = $curid > 0 ? _("Report Module") . " <b>'Custom Security Events - {$name}'</b> " . _("successfully updated") : _("Report Module successfully created as") . " <b>'Custom Security Events - {$name}'</b>";
$msg_type = 'nf_success';
} else {
Av_exception::write_log(Av_exception::DB_ERROR, $conn->ErrorMsg());
$msg = _("Error creating a new report type.");
$msg_type = 'nf_error';
}
$db->close();
} else {
$msg = _("Error creating a new report type.");
$msg_type = 'nf_error';
}
}
}
$tags = get_tags($idm_enabled);
if ($opensource) {
unset($tags['PLUGIN_SOURCE_TYPE']);
unset($tags['PLUGIN_SID_CATEGORY']);
unset($tags['PLUGIN_SID_SUBCATEGORY']);
示例2: DisplayProcessing
//.........这里部分代码省略.........
print "$line\n";
}
}
foreach ( $cmd_out['nfdump'] as $line ) {
print preg_replace($patterns, $replacements, $line) . "\n";
}*/
# parse command line
#2009-12-09 17:08:17.596 40.262 TCP 192.168.1.9:80 -> 217.126.167.80:51694 .AP.SF 0 70 180978 1 35960 2585 1
$list = preg_match("/\\-o extended/", $cmd_out['arg']) ? 1 : 0;
$regex = $list ? "/(\\d\\d\\d\\d\\-.*?\\s.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+->\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?\\s*[KMG]?)\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*)/" : "/(\\d\\d\\d\\d\\-.*?\\s.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?\\s*[KMGT]?)\\s+(.*?)\\s+(.*?)\\s+(.*)/";
echo '<div class="nfsen_list_title">' . _('Flows Info') . '</div>';
echo "<table class='table_list'>";
$geotools = false;
if ($list && file_exists("../kml/GoogleEarth.php")) {
$geotools = true;
$geoips = array();
$geotools_src = " <a href='' onclick='window.open(\"../kml/TourConfig.php?type=ip_src&ip=&flows=1\",\"Flows sources - Goggle Earth API\",\"width=1024,height=700,scrollbars=NO,toolbar=1\");return false'><img align='absmiddle' src='../pixmaps/google_earth_icon.png' border='0'></a> <a href='' onclick='window.open(\"../kml/IPGoogleMap.php?type=ip_src&ip=&flows=1\",\"Flows sources - Goggle Maps API\",\"width=1024,height=700,scrollbars=NO,toolbar=1\");return false'><img align='absmiddle' src='../pixmaps/google_maps_icon.png' border='0'></a>";
$geotools_dst = " <a href='' onclick='window.open(\"../kml/TourConfig.php?type=ip_dst&ip=&flows=1\",\"Flows destinations - Goggle Earth API\",\"width=1024,height=700,scrollbars=NO,toolbar=1\");return false'><img align='absmiddle' src='../pixmaps/google_earth_icon.png' border='0'></a> <a href='' onclick='window.open(\"../kml/IPGoogleMap.php?type=ip_dst&ip=&flows=1\",\"Flows destinations - Goggle Maps API\",\"width=1024,height=700,scrollbars=NO,toolbar=1\");return false'><img align='absmiddle' src='../pixmaps/google_maps_icon.png' border='0'></a>";
}
echo $list ? "\n \n <tr>\n <th>" . _("Date flow start") . "<br><span style='font-size:8px'>" . Util::timezone($tz) . "</style></th>\n <th>" . _("Duration") . "</th>\n <th>" . _("Proto") . "</th>\n <th>" . _("Src IP Addr:Port") . "{$geotools_src}</th>\n <th>" . _("Dst IP Addr:Port") . "{$geotools_dst}</th>\n <th>" . _("Flags") . "</th>\n <th>" . _("Tos") . "</th>\n <th>" . _("Packets") . "</th>\n <th>" . _("Bytes") . "</th>\n <th>" . _("pps") . "</th>\n <th>" . _("bps") . "</th>\n <th>" . _("Bpp") . "</th>\n <th>" . _("Flows") . "</th>\n \t" . ($solera ? "<th></th>" : "") . "\n </tr>" : "<tr>\n <th>" . _("Date flow seen") . "<br><span style='font-size:8px'>" . Util::timezone($tz) . "</style></th>\n <th>" . _("Duration") . "</th>\n <th>" . _("Proto") . "</th>\n <th>" . $titcol . "</th>\n <th>" . _("Flows") . "(%)</th>\n <th>" . _("Packets") . "(%)</th>\n <th>" . _("Bytes") . "(%)</th>\n <th>" . _("pps") . "</th>\n <th>" . _("bps") . "</th>\n <th>" . _("Bpp") . "</th>\n \t" . ($solera ? "<th></th>" : "") . "\n </tr>";
$status = $errors = array();
$rep = new Reputation();
//print_r($cmd_out['arg']);
//print_r($cmd_out['nfdump']);
foreach ($cmd_out['nfdump'] as $k => $line) {
#capture status
if (preg_match("/^(Summary|Time window|Total flows processed|Sys)\\:/", $line, $found)) {
$status[$found[1]] = str_replace($found[1] . ":", "", $line);
}
# capture errors
if (preg_match("/ error /i", $line, $found)) {
if (preg_match("/stat\\(\\) error/i", $line)) {
$errors[] = _('The netflow information you are trying to access either has not been processed yet or does not exist. Please check your date filters.');
Av_exception::write_log(Av_exception::USER_ERROR, $line);
} else {
$errors[] = $line;
}
}
# print results
$line = preg_replace("/\\(\\s(\\d)/", "(\\1", $line);
// Patch for ( 0.3)
$line = preg_replace("/(\\d)\\s*([KMGT])/", "\\1\\2", $line);
// Patch for 1.2 M(99.6)
$line = preg_replace("/(\\d+)(TCP|UDP|ICMP|IGMP)\\s/", "\\1 \\2 ", $line);
// Patch for 9.003TCP
$start = $end = $proto = "";
$ips = $ports = array();
if (preg_match($regex, preg_replace('/\\s*/', ' ', $line), $found)) {
echo "<tr class='tr_flow_data'>\n";
foreach ($found as $ki => $field) {
if ($ki > 0) {
$wrap = $ki == 1 ? "nowrap" : "";
$field = Util::htmlentities(preg_replace("/(\\:\\d+)\\.0\$/", "\\1", $field));
if (preg_match("/(\\d+\\.\\d+\\.\\d+\\.\\d+)(.*)/", $field, $fnd)) {
# match ip (resolve and geolocalize)
$ip = $fnd[1];
$port = $fnd[2];
list($name, $ctx, $host_id) = GetDataFromSingleIp($ip, $hosts);
if ($name == "" && $sensors[$ip] != "") {
$name = $sensors[$ip];
}
$output = Asset_host::get_extended_name($conn, $geoloc, $ip, $ctx, $host_id, '');
$homelan = $output['is_internal'] || $name != "" && $name != $ip;
$icon = $output['html_icon'];
# reputation info
if (!is_array($_SESSION["_repinfo_ips"][$ip])) {
示例3: baseExecute
function baseExecute($sql, $start_row = 0, $num_rows = -1, $die_on_error = true, $params = array())
{
if (preg_match("/\\s+(WHERE|AND)\\s+1\\s*=\\s*1\\s*\$/i", $sql)) {
$sql = preg_replace("/(WHERE|AND)\\s+1\\s*=\\s*1\\s*\$/i", "", $sql);
}
global $debug_mode, $sql_trace_mode;
/* ** Begin DB specific SQL fix-up ** */
if ($this->DB_type == "mssql") {
$sql = preg_replace("/''/i", "NULL", $sql);
}
$this->lastSQL = $sql;
$limit_str = "";
$cache_secs = preg_match("/FOUND_ROWS/i", $sql) ? -1 : $this->DB_memcache;
//file_put_contents("/tmp/fr", "$cache_secs-$sql\n", FILE_APPEND);
/* Check whether need to add a LIMIT / TOP / ROWNUM clause */
if ($num_rows == -1) {
// If we have $params we must force not-cache
if ($this->DB_memcache > 0 && count($params) == 0) {
$rs = new baseRS($this->DB->CacheExecute($cache_secs, $sql), $this->DB_type);
} else {
$rs = new baseRS($this->DB->Execute($sql, $params), $this->DB_type);
}
} else {
if ($this->DB_type == "mysql" || $this->DB_type == "mysqli" || $this->DB_type == "mysqlt" || $this->DB_type == "maxsql") {
//echo "Objeto DB:".var_dump($this->DB)."<br>";
//echo "<br>EJECUTANDO($cache_secs): ".$sql . " LIMIT " . $start_row . ", " . $num_rows." en ".$this->DB_type."<br>";
if ($this->DB_memcache > 0) {
$tmprow = $this->DB->CacheExecute($cache_secs, $sql . " LIMIT " . $start_row . ", " . $num_rows);
} else {
$tmprow = $this->DB->Execute($sql . " LIMIT " . $start_row . ", " . $num_rows);
}
//print_r($_GET);
//print_r($_SESSION);
$rs = new baseRS($tmprow, $this->DB_type);
$limit_str = " LIMIT " . $start_row . ", " . $num_rows;
//echo "<br>ROW:";
//var_dump($tmprow);
//echo "<br>ERROR MSG: " . $this->baseErrorMessage(). "<br>";
} else {
if ($this->DB_type == "oci8") {
$rs = new baseRS($this->DB->Execute($sql), $this->DB_type);
$limit_str = " LIMIT " . $start_row . ", " . $num_rows;
} else {
if ($this->DB_type == "postgres") {
$rs = new baseRS($this->DB->Execute($sql . " LIMIT " . $num_rows . " OFFSET " . $start_row), $this->DB_type);
$limit_str = " LIMIT " . $num_rows . " OFFSET " . $start_row;
} else {
if ($this->DB_memcache > 0) {
$rs = new baseRS($this->DB->CacheExecute($cache_secs, $sql), $this->DB_type);
} else {
$rs = new baseRS($this->DB->Execute($sql), $this->DB_type);
}
$i = 0;
while ($i < $start_row && $rs) {
if (!$rs->row->EOF) {
$rs->row->MoveNext();
}
$i++;
}
}
}
}
}
if ($sql_trace_mode > 0) {
fputs($this->sql_trace, $sql . "{$limit_str}\n");
fflush($this->sql_trace);
}
if ((!$rs || $this->baseErrorMessage() != "") && $die_on_error) {
Av_exception::write_log(Av_exception::DB_ERROR, $this->DB->ErrorMsg());
echo '</TABLE></TABLE></TABLE><CENTER><span style="font-size:11px;color:#555555"><B><br>' . gettext("Unable to query the database to retrieve some table information. Try fewer conditions.") . '</B></span></CENTER><script>$("#actions_link").prop("disabled",true);</script>';
die;
} else {
return $rs;
}
}
示例4: check_deploy_status
function check_deploy_status($conn, $wizard)
{
$data = array();
$os = $wizard->get_step_data('deploy_os');
//Linux Deployment Status --> Apply Configuration
if ($os == 'linux') {
$sensor_id = get_sensor_id();
$error_apply = FALSE;
try {
list($agentless_list, $al_total) = Ossec_agentless::get_list($conn, $sensor_id, ' AND status = 1');
if ($al_total > 0) {
Ossec_agentless::save_in_config($conn, $sensor_id, $agentless_list);
}
//Enabling agentless
Ossec_control::execute_action($sensor_id, 'enable_al');
//Restarting ossec
Ossec_control::execute_action($sensor_id, 'restart');
// Delete "/var/tmp/.reload_<sensor_id>" file in order to hide the "Apply Changes" button
@unlink('/var/tmp/.reload_' . $sensor_id);
} catch (Exception $e) {
$error_apply = $e->getMessage();
}
//If there was an error applying the configuration we show the error
if ($error_apply !== FALSE) {
$error_apply_msg = _('Error Applying Agentless Configuration');
set_scan_error_message($wizard, $error_apply_msg);
Av_exception::write_log(Av_exception::USER_ERROR, $error_apply);
$response['error'] = TRUE;
return $response;
}
//If everything was right, the percent is 100% and the remaining is 0
$data['finish'] = TRUE;
$data['percent'] = 100;
$data['remaining'] = 0;
//Setting the deployment status to 3 --> Finished
$wizard->set_step_data('deploy_step', 3);
} elseif ($os == 'windows') {
$jobs = $wizard->get_step_data('deploy_jobs');
//If the array of jobs IDs is empty, we are finished
if (!is_array($jobs) || count($jobs) == 0) {
$data['finish'] = TRUE;
$data['percent'] = 100;
$data['remaining'] = 0;
//Setting the deployment status to 3 --> Finished
$wizard->set_step_data('deploy_step', 3);
} else {
$succes = 0;
//Going through the jobs
foreach ($jobs as $id => $job) {
try {
//Getting the status of the job
$state = Welcome_wizard::current_jobs($job['job_id']);
if ($state['job_status'] == 'task-succeeded') {
//If it is success, we count it and we delete it from the jobs array
if ($state['job_result'][0] === TRUE) {
unset($jobs[$id]);
$succes++;
} elseif ($state['job_result'][0] === FALSE) {
unset($jobs[$id]);
Av_exception::write_log(Av_exception::USER_ERROR, $job['agent'] . ': ' . $state['job_result'][1]);
}
} elseif ($state['job_status'] == 'task-failed' || $state['job_status'] == 'task-revoked') {
unset($jobs[$id]);
$_msg = $job['agent'] . ': ' . _("Couldn't complete windows OSSEC agent deploy: ") . $state['job_status'];
Av_exception::write_log(Av_exception::USER_ERROR, $_msg);
}
} catch (Exception $e) {
//In case of critical error we delete from the array to avoid loops
unset($jobs[$id]);
Av_exception::write_log(Av_exception::USER_ERROR, $job['agent'] . ': ' . $e->getMessage());
}
}
//IF after checking the status, the array is empty, we are finished
if (!is_array($jobs) || count($jobs) == 0) {
$data['finish'] = TRUE;
$data['percent'] = 100;
$data['remaining'] = 0;
//Setting the deployment status to 3 --> Finished
$wizard->set_step_data('deploy_step', 3);
} else {
//Total number of host that were selected to be deployed
$total = $wizard->get_step_data('deploy_total_ips');
$total = $total < 1 ? 1 : $total;
//Number of host left to be deployed --> Pending jobs
$current = count($jobs);
//Percentage of the remaining hosts
$pending = $total - $current;
$percent = round(100 * ($pending / $total));
$data['finish'] = FALSE;
$data['percent'] = $percent;
$data['remaining'] = $current;
}
//Updating the number of host successfully deployed
$deployed = $wizard->get_step_data('deploy_success');
$deployed += $succes;
$wizard->set_step_data('deploy_success', $deployed);
//Updating the array of jobs left
$wizard->set_step_data('deploy_jobs', $jobs);
}
}
//.........这里部分代码省略.........
示例5: import_assets_from_csv
//.........这里部分代码省略.........
$summary['general']['statistics']['errors']++;
continue;
}
}
//Check IPs
if ($can_i_modify_ips == TRUE) {
$aux_ips = explode(',', $csv_ips);
foreach ($aux_ips as $ip) {
$host_ids = Asset_host::get_id_by_ips($conn, $ip, $ctx);
unset($host_ids[$host_id]);
if (!empty($host_ids)) {
$c_error_msg = _('IP') . ' ' . $csv_ips . ' ' . _("not allowed. IP {$ip} already exists for this entity");
$summary['by_hosts'][$num_line]['errors']['IP'] = $c_error_msg;
$summary['general']['statistics']['errors']++;
break;
} else {
$cnd_1 = Session::get_net_where() != '' && !Session::only_ff_net();
$cnd_2 = Asset_host::is_ip_in_cache_cidr($conn, $ip, $ctx, TRUE);
if ($cnd_1 && !$cnd_2) {
$c_error_msg = sprintf(_("Error! The IP %s is not allowed. Please check with your account admin for more information"), $csv_ips);
$summary['by_hosts'][$num_line]['errors']['IP'] = $c_error_msg;
$summary['general']['statistics']['errors']++;
break;
}
}
}
} else {
$c_error_msg = _('Host') . ' ' . $name . ': ' . _("IP address not allowed. IP address cannot be modified");
$summary['by_hosts'][$num_line]['status'] = 'warning';
$summary['general']['warnings']['errors']++;
$summary['by_hosts'][$num_line]['warnings']['IP'] = $c_error_msg;
}
//Setting new values
if (count($summary['by_hosts'][$num_line]['errors']) == 0) {
$host->set_ctx($ctx);
$host->set_name($name);
$host->set_descr($descr);
if ($is_in_db == FALSE) {
if ($can_i_modify_ips == TRUE) {
if (is_array($aux_ips) && !empty($aux_ips)) {
$ips = array();
foreach ($aux_ips as $ip) {
$ips[$ip] = array('ip' => $ip, 'mac' => NULL);
}
$host->set_ips($ips);
}
}
$host->set_sensors($sensors);
}
if (!empty($fqdns)) {
$host->set_fqdns($fqdns);
}
$host->set_external($external);
$host->set_location($latitude, $longitude);
$host->set_asset_value($asset_value);
$host->set_devices($devices);
$host->save_in_db($conn, FALSE);
//Save Operating System
if (!empty($os)) {
Asset_host_properties::save_property_in_db($conn, $host_id, 3, $os, 2);
}
$summary['general']['statistics']['saved']++;
$summary['by_hosts'][$num_line]['data'] = $is_in_db == TRUE ? _('Asset updated') : _('New asset inserted');
//Keep warnings
if ($summary['by_hosts'][$num_line]['status'] != 'warning') {
$summary['by_hosts'][$num_line]['status'] = 'success';
}
}
} catch (Exception $e) {
$summary['by_hosts'][$num_line]['errors']['Database error'] = $e->getMessage();
$summary['general']['statistics']['errors']++;
}
}
}
if ($summary['general']['statistics']['saved'] > 0) {
if ($summary['general']['statistics']['errors'] == 0) {
$summary['general']['status'] = 'success';
$summary['general']['data'] = _('All assets have been successfully imported ');
} else {
$summary['general']['status'] = 'warning';
$summary['general']['data'] = _('Some assets cannot be imported');
}
Util::disable_perm_triggers($conn, FALSE);
try {
Asset_host::report_changes($conn, 'hosts');
} catch (Exception $e) {
Av_exception::write_log(Av_exception::USER_ERROR, $e->getMessage());
}
} else {
$summary['general']['statistics']['errors'] = count($data);
//CSV file is not empty, but all lines are wrong
if (empty($summary['general']['status'])) {
$summary['general']['status'] = 'error';
$summary['general']['data'] = _('Assets cannot be imported');
}
}
@$conn->Execute("REPLACE INTO alienvault.host_net_reference SELECT host.id,net_id FROM alienvault.host, alienvault.host_ip, alienvault.net_cidrs WHERE host.id = host_ip.host_id AND host_ip.ip >= net_cidrs.begin AND host_ip.ip <= net_cidrs.end");
$db->close();
return $summary;
}
示例6: get_map_objects
function get_map_objects($conn, $map, $map_array = array(), $obj_array = array())
{
$map_array[$map]++;
$query = "select * from risk_indicators where name <> 'rect' AND map = UNHEX(?)";
$rs4 = $conn->Execute($query, array($map));
if (!$rs4) {
Av_exception::write_log(Av_exception::DB_ERROR, $conn->ErrorMsg());
} else {
while (!$rs4->EOF) {
//It's a map
if (preg_match("/view\\.php\\?map\\=([a-fA-F0-9]*)/", $rs4->fields['url'], $found)) {
if (!$map_array[$found[1]]) {
list($map_array, $obj_array) = get_map_objects($conn, $found[1], $map_array, $obj_array);
}
} else {
if (!$obj_array[$rs4->fields['id']]) {
$obj_array[$rs4->fields['id']] = $rs4->fields;
}
}
$rs4->MoveNext();
}
}
return array($map_array, $obj_array);
}
示例7: foreach
} else {
foreach ($active_plugins[$asset_id_canonical] as $pdata) {
$models = array();
$versions = array();
if ($pdata['vendor'] != '') {
try {
$models = Software::get_models_by_vendor($pdata['vendor']);
} catch (Exception $e) {
Av_exception::write_log(Av_exception::USER_ERROR, $e->getMessage());
}
}
if ($pdata['model'] != '') {
try {
$versions = Software::get_versions_by_model($pdata['vendor'] . ':' . $pdata['model']);
} catch (Exception $e) {
Av_exception::write_log(Av_exception::USER_ERROR, $e->getMessage());
}
}
$plugin_list[$asset_id][] = array('vendor' => $pdata['vendor'], 'model' => $pdata['vendor'] . ':' . $pdata['model'], 'version' => $pdata['vendor'] . ':' . $pdata['model'] . ':' . $pdata['version'], 'model_list' => $models, 'version_list' => $versions);
}
}
$device_list[$asset_id] = array("name" => $host['name'], "ips" => Asset::format_to_print($host['ips']), "plugins" => $plugin_list[$asset_id]);
}
} else {
$empty_msg = _('There are no network devices found. Return to the asset discovery step by clicking back to either discover or add network devices.');
}
/* Subtitle Texts */
$subtitle_1 = '';
$subtitle_2 = '';
if ($total == 1) {
$subtitle_1 = _('During the asset discovery scan we found 1 network device on your network');
示例8: import_assets_from_csv
//.........这里部分代码省略.........
if (!ossim_valid($asset_value, OSS_DIGIT, 'illegal:' . _('Asset value'))) {
$summary['by_nets'][$num_line]['errors']['Asset value'] = ossim_get_error_clean();
$summary['general']['statistics']['errors']++;
continue;
}
}
//Insert/Update net in database
if (count($summary['by_nets'][$num_line]['errors']) == 0) {
try {
$net = new Asset_net($net_id);
if ($is_in_db == TRUE) {
$net->load_from_db($conn, $net_id);
$can_i_modify_ips = Asset_net::can_i_modify_ips($conn, $net_id);
} else {
if ($can_i_create_assets == FALSE) {
$n_error_msg = _('Net') . ' ' . $name . ' ' . _("not allowed. You don't have permissions to import this net");
$summary['by_nets'][$num_line]['errors']['Net'] = $n_error_msg;
$summary['general']['statistics']['errors']++;
continue;
}
}
//Check CIDRs
if ($can_i_modify_ips == TRUE) {
$aux_cidr = explode(',', $cidrs);
foreach ($aux_cidr as $cidr) {
$net_ids = Asset_net::get_id_by_ips($conn, $cidr, $ctx);
unset($net_ids[$net_id]);
if (!empty($net_ids)) {
$c_error_msg = _('CIDR') . ' ' . $cidrs . ' ' . _("not allowed. CIDR {$cidr} already exists for this entity");
$summary['by_nets'][$num_line]['errors']['CIDRs'] = $c_error_msg;
$summary['general']['statistics']['errors']++;
break;
} else {
if (Session::get_net_where() != '') {
if (!Asset_net::is_cidr_in_my_nets($conn, $cidr, $ctx)) {
$c_error_msg = sprintf(_("Error! The CIDR %s is not allowed. Please check with your account admin for more information"), $cidrs);
$summary['by_nets'][$num_line]['errors']['CIDRs'] = $c_error_msg;
$summary['general']['statistics']['errors']++;
break;
}
}
}
}
} else {
$c_error_msg = _('Net') . ' ' . $name . ': ' . _("CIDRs not allowed. CIDRs cannot be modified");
$summary['by_nets'][$num_line]['status'] = 'warning';
$summary['general']['warnings']['errors']++;
$summary['by_nets'][$num_line]['warnings']['CIDRs'] = $c_error_msg;
}
//Setting new values
if (count($summary['by_nets'][$num_line]['errors']) == 0) {
$net->set_ctx($ctx);
$net->set_name($name);
$net->set_descr($descr);
if ($is_in_db == FALSE) {
if ($can_i_modify_ips == TRUE) {
$net->set_ips($cidrs);
}
$net->set_sensors($sensors);
}
$net->set_asset_value($asset_value);
$net->save_in_db($conn, FALSE);
$summary['general']['statistics']['saved']++;
$summary['by_nets'][$num_line]['data'] = $is_in_db == TRUE ? _('Net updated') : _('New new inserted');
//Keep warnings
if ($summary['by_nets'][$num_line]['status'] != 'warning') {
$summary['by_nets'][$num_line]['status'] = 'success';
}
}
} catch (Exception $e) {
$summary['by_nets'][$num_line]['errors']['Database error'] = $e->getMessage();
$summary['general']['statistics']['errors']++;
}
}
}
if ($summary['general']['statistics']['saved'] > 0) {
if ($summary['general']['statistics']['errors'] == 0) {
$summary['general']['status'] = 'success';
$summary['general']['data'] = _('All nets have been successfully imported');
} else {
$summary['general']['status'] = 'warning';
$summary['general']['data'] = _('Some nets cannot be imported');
}
Util::disable_perm_triggers($conn, FALSE);
try {
Asset_net::report_changes($conn, 'nets');
} catch (Exception $e) {
Av_exception::write_log(Av_exception::USER_ERROR, $e->getMessage());
}
} else {
$summary['general']['statistics']['errors'] = count($data);
//CSV file is not empty, but all lines are wrong
if (empty($summary['general']['status'])) {
$summary['general']['status'] = 'error';
$summary['general']['data'] = _('Nets cannot be imported');
}
}
$db->close();
return $summary;
}
示例9: ossim_valid
ossim_valid($intent, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("Intent"));
ossim_valid($directive_id, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("Directive ID"));
ossim_valid($num_events, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("Num Events"));
ossim_valid($num_events_op, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Num Events Operator"));
ossim_valid($tag, OSS_HEX, OSS_NULLABLE, 'illegal:' . _("Tag"));
ossim_valid($no_resolv, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("No Resolv"));
ossim_valid($hide_closed, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("Hide Closed"));
ossim_valid($show_options, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("Show Options"));
if (ossim_error()) {
$response['sEcho'] = $sec;
$response['iTotalRecords'] = 0;
$response['iTotalDisplayRecords'] = 0;
$response['aaData'] = '';
$error = ossim_get_error();
ossim_clean_error();
Av_exception::write_log(Av_exception::USER_ERROR, $error);
echo json_encode($response);
exit;
}
if (empty($show_options) || ($show_options < 1 || $show_options > 4)) {
$show_options = 1;
}
$db = new ossim_db(TRUE);
$conn = $db->connect();
$db_groups = Alarm_groups::get_dbgroups($conn);
$criteria = array('group_type' => $group_type, 'show_options' => $show_options, 'hide_closed' => $hide_closed, 'from_date' => $date_from, 'to_date' => $date_to, 'ip_src' => $src_ip, 'ip_dst' => $dst_ip, 'asset_group' => $asset_group, 'sensor' => $sensor_query, 'query' => $alarm_name, 'directive_id' => $directive_id, 'intent' => $intent, 'num_events' => $num_events, 'num_events_op' => $num_events_op, 'tag' => $tag, 'limit' => "LIMIT {$offset}, {$limit}");
list($alarm_group, $total) = Alarm_groups::get_grouped_alarms($conn, $criteria, TRUE);
$results = array();
foreach ($alarm_group as $group) {
$res = array();
$group_id = $group['group_id'];
示例10: SIEM_trends_week
function SIEM_trends_week($param = '')
{
global $tz;
$tzc = Util::get_tzc($tz);
$data = array();
$plugins = '';
$plugins_sql = '';
$db = new ossim_db(TRUE);
$dbconn = $db->connect();
$_asset_where = make_asset_filter();
$asset_where = $_asset_where[1];
$sensor_where = make_ctx_filter() . $asset_where;
$tax_join = '';
if (preg_match("/taxonomy\\=(.+)/", $param, $found)) {
if ($found[1] == 'honeypot') {
$tax_join = 'alienvault.plugin_sid p, ';
$tax_where = 'AND acid_event.plugin_id = p.plugin_id AND acid_event.plugin_sid = p.sid AND p.category_id = 19';
}
$param = '';
} elseif ($param == 'ossec%') {
$plugins_sql = 'AND acid_event.plugin_id between 7000 and 7999';
$plugins = '7000-7999';
}
$sqlgraph = "SELECT COUNT(acid_event.id) as num_events, day(convert_tz(timestamp,'+00:00','{$tzc}')) AS intervalo, monthname(convert_tz(timestamp,'+00:00','{$tzc}')) AS suf \n FROM {$tax_join} alienvault_siem.acid_event \n WHERE timestamp BETWEEN '" . gmdate("Y-m-d 00:00:00", gmdate("U") - 604800) . "' AND '" . gmdate("Y-m-d 23:59:59") . "' {$plugins_sql} {$sensor_where} {$tax_where} \n GROUP BY suf, intervalo \n ORDER BY suf, intervalo";
if (!($rg =& $dbconn->CacheExecute($sqlgraph))) {
Av_exception::write_log(Av_exception::DB_ERROR, $dbconn->ErrorMsg());
} else {
while (!$rg->EOF) {
$hours = $rg->fields['intervalo'] . ' ' . substr($rg->fields['suf'], 0, 3);
$data[$hours] = $rg->fields['num_events'];
$rg->MoveNext();
}
}
$db->close();
return $param != '' ? array($data, $plugins) : $data;
}
示例11: getSourceCoordYear
function getSourceCoordYear($conn, $date_from = "", $date_to = "")
{
$data = array();
if ($date_from == "" || $date_to == "") {
// Last Month by default
$date_from = strftime("%Y-%m-%d", time() - 24 * 60 * 60 * 30);
$date_to = strftime("%Y-%m-%d", time());
}
$tab = getSourceRepartitionYear($conn, $date_from, $date_to);
if (is_array($tab)) {
foreach ($tab as $pays => $volume) {
$sql = "select distinct(g.nom),g.abs,g.ord from datawarehouse.geo g, datawarehouse.ip2country i where UPPER(g.pays)=UPPER(i.a2) and i.country = ?;";
$rs = $conn->Execute($sql, array($pays));
if (!$rs) {
Av_exception::write_log(Av_exception::DB_ERROR, $conn->ErrorMsg());
return $data;
}
$result = $rs->fields;
if ($result['ord'] && $result['abs']) {
array_push($data, array("nom" => $result['nom'], "abs" => $result['abs'], "ord" => $result['ord'], "volume" => $volume));
}
}
}
return $data;
}
示例12: session_write_close
// Close session write for real background loading
session_write_close();
$db = new Ossim_db();
$conn = $db->connect();
$asset_id = GET('asset_id');
ossim_valid($asset_id, OSS_HEX, 'illegal: Asset ID');
if (ossim_error()) {
echo 'gray';
$db->close();
exit;
}
// Get object from session
$asset_object = unserialize($_SESSION['asset_detail'][$asset_id]);
if (!is_object($asset_object)) {
echo 'gray';
Av_exception::write_log(Av_exception::USER_ERROR, _('Error retrieving the asset data from Memory'));
}
// DATA
try {
$hids = $asset_object->is_hids_enabled($conn);
$hids = intval($hids);
if ($hids == 2) {
echo 'yellow';
} elseif ($hids == 1) {
echo 'green';
} else {
echo 'red';
}
} catch (Exception $e) {
echo 'gray';
}