本文整理汇总了PHP中ossim_get_error_clean函数的典型用法代码示例。如果您正苦于以下问题:PHP ossim_get_error_clean函数的具体用法?PHP ossim_get_error_clean怎么用?PHP ossim_get_error_clean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ossim_get_error_clean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_pulse_detail_from_id
function get_pulse_detail_from_id($conn)
{
$type = POST('type');
$pulse = POST('pulse');
$id = POST('id');
ossim_valid($type, 'alarm|event|alarm_event', 'illegal:' . _('Type'));
ossim_valid($pulse, OSS_HEX, 'illegal:' . _('Pulse'));
ossim_valid($id, OSS_HEX, 'illegal:' . _('ID'));
if (ossim_error()) {
Av_exception::throw_error(Av_exception::USER_ERROR, ossim_get_error_clean());
}
if ($type == 'alarm') {
$pulse = Alarm::get_pulse_data_from_alarm($conn, $id, $pulse, TRUE);
} elseif ($type == 'event') {
$pulse = Siem::get_pulse_data_from_event($conn, $id, $pulse, FALSE, TRUE);
} elseif ($type == 'alarm_event') {
$pulse = Siem::get_pulse_data_from_event($conn, $id, $pulse, TRUE, TRUE);
}
return array('name' => $pulse['name'], 'descr' => $pulse['descr'], 'iocs' => array_values($pulse['iocs']));
}
示例2: dirname
require_once dirname(__FILE__) . '/../../conf/config.inc';
session_write_close();
Session::logcheck('environment-menu', 'EventsHidsConfig');
$events_hids_config = Session::menu_perms('environment-menu', 'EventsHidsConfig');
try {
$db = new ossim_db();
$conn = $db->connect();
$sensor_id = POST('sensor_id');
ossim_valid($sensor_id, OSS_HEX, 'illegal:' . _('Sensor ID'));
if (!ossim_error()) {
if (!Ossec_utilities::is_sensor_allowed($conn, $sensor_id)) {
$e_msg = _('Error! Sensor not allowed');
Av_exception::throw_error(Av_exception::USER_ERROR, $e_msg);
}
} else {
$e_msg = ossim_get_error_clean();
Av_exception::throw_error(Av_exception::USER_ERROR, $e_msg);
}
$agents = Ossec_agent::get_list($sensor_id);
$data = array();
if (is_array($agents) && !empty($agents)) {
foreach ($agents as $agent_id => $a_data) {
if (empty($a_data)) {
continue;
}
$a_unique_id = md5($agent_id);
$agent_actions = Ossec_agent::get_actions($agent_id, $a_data);
if (!empty($a_data['host_id'])) {
$asset_name = Asset_host::get_name_by_id($conn, $a_data['host_id']);
} else {
$asset_name = '-';
示例3: set_include_path
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Common/functions.php';
require_once 'Various/general.php';
// DB
$db = new ossim_db();
$conn = $db->connect();
$geoloc = new Geolocation('/usr/share/geoip/GeoLiteCity.dat');
//Initialize var
$report_name = $report_data['report_name'];
$subreport_name = $report_data['subreports'][$subreport_id]['name'];
$date_from = POST($report_data['parameters'][0]['date_from_id']);
$date_to = POST($report_data['parameters'][0]['date_to_id']);
ossim_valid($date_from, OSS_DATE, OSS_NULLABLE, 'illegal:' . _('Date From'));
ossim_valid($date_to, OSS_DATE, OSS_NULLABLE, 'illegal:' . _('Date To'));
if (ossim_error()) {
echo 'error###' . ossim_get_error_clean();
exit;
}
$query_temp = array();
//
// select src_ip from alarm table and not defined into nets
//
$ips = array();
$plugin_id = NULL;
$plugin_groups = NULL;
$source_type = NULL;
$category = NULL;
$subcategory = NULL;
$limit = 20;
// Taxonomy filters
$plugin_list = Plugin_sid::get_all_sids($conn, $plugin_id, $source_type, $category, $subcategory, $plugin_groups);
示例4: import_assets_csv
function import_assets_csv($filename)
{
require_once 'classes/Util.inc';
$response = array();
$db = new ossim_db();
$conn = $db->connect();
if (($content = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)) == false) {
$response['file_errors'] = "Failed to read file";
$response['status'] = false;
return $response;
} else {
foreach ($content as $k => $v) {
$data[] = explode(";", $v);
}
}
$cont = 0;
ini_set('max_execution_time', 180);
ids_valid($data);
if (count($data) <= 0) {
$response['file_errors'] = _("Incompatible file format");
$response['status'] = false;
return $response;
}
$allowed_sensors = Session::allowedSensors();
if (!empty($allowed_sensors)) {
$my_allowed_sensors = explode(',', $allowed_sensors);
} else {
$response['file_errors'] = _("You need at least one sensor assigned");
$response['status'] = false;
return $response;
}
foreach ($data as $k => $v) {
$response['status'] = true;
$response['read_line'] = $cont;
$cont++;
if (count($v) != 8) {
$response['line_errors'][$cont][] = array("Line", _("Format not allowed"));
$response['status'] = false;
}
$param = array();
foreach ($v as $i => $field) {
$parameter = trim($field);
$pattern = '/^\\"|\\"$|^\'|\'$/';
$param[] = preg_replace($pattern, '', $parameter);
}
//IP
if (!ossim_valid($param[0], OSS_IP_ADDR, 'illegal:' . _("IP"))) {
$response['line_errors'][$cont][] = array("IP", ossim_get_error_clean());
$response['status'] = false;
}
//Hostname
if (empty($param[1])) {
$param[1] = $param[0];
} else {
if (!ossim_valid($param[1], OSS_SCORE, OSS_ALPHA, OSS_PUNC, 'illegal:' . _("Hostname"))) {
$response['line_errors'][$cont][] = array("Hostname", ossim_get_error_clean());
$response['status'] = false;
ossim_clean_error();
}
}
//FQDNs
if (!empty($param[2])) {
$fqdns_list = explode(",", $param[2]);
foreach ($fqdns_list as $k => $fqdn) {
if (!ossim_valid(trim($fqdn), OSS_NULLABLE, OSS_ALPHA, OSS_PUNC, 'illegal:' . _("FQDN/Aliases"))) {
$response['line_errors'][$cont][] = array("FQDN/Aliases", ossim_get_error_clean());
$response['status'] = false;
ossim_clean_error();
}
}
}
//Description
if (!ossim_valid($param[3], OSS_NULLABLE, OSS_SCORE, OSS_ALPHA, OSS_PUNC, OSS_AT, 'illegal:' . _("Description"))) {
$response['line_errors'][$cont][] = array("Description", ossim_get_error_clean());
$response['status'] = false;
ossim_clean_error();
}
//Asset
if ($param[4] == '') {
$param[4] = 2;
} else {
if (!ossim_valid($param[4], OSS_NULLABLE, OSS_DIGIT, 'illegal:' . _("Asset value"))) {
$response['line_errors'][$cont][] = array("Asset", ossim_get_error_clean());
$response['status'] = false;
ossim_clean_error();
}
}
//NAT
if (!ossim_valid($param[5], OSS_NULLABLE, OSS_IP_ADDR, 'illegal:' . _("NAT"))) {
$response['line_errors'][$cont][] = array("NAT", ossim_get_error_clean());
$response['status'] = false;
ossim_clean_error();
}
//Sensors
$sensors = array();
if (!empty($param[6])) {
$sensor_name = array();
$list = explode(",", $param[6]);
$sensors_list = array_intersect($list, $my_allowed_sensors);
if (!empty($sensors_list)) {
//.........这里部分代码省略.........
示例5: foreach
foreach ($assets as $asset) {
// Validate UUID#IP or IP, other cases will fail
$_asset = explode('#', $asset);
if (count($_asset) == 1) {
$_asset_ip = $_asset[0];
ossim_valid($_asset_ip, OSS_IP_ADDRCIDR, 'illegal:' . _('Asset IP'));
} elseif (count($_asset) == 2) {
$_asset_ip = $_asset[1];
$_asset_id = $_asset[0];
ossim_valid($_asset_ip, OSS_IP_ADDRCIDR, 'illegal:' . _('Asset IP'));
ossim_valid($_asset_id, OSS_HEX, 'illegal:' . _('Asset ID'));
} else {
ossim_set_error(_('Asset not allowed'));
}
if (ossim_error()) {
$validation_errors['assets[]'] = ossim_get_error_clean();
break;
} else {
//IP_CIDR and ID is pushed
array_push($assets_string, $asset);
}
}
$assets_p = implode(' ', $assets_string);
} else {
$validation_errors['assets[]'] = _("Error in the 'Target selection' field (missing required field)");
}
}
if (is_array($validation_errors) && !empty($validation_errors)) {
//Formatted message
$error_msg = '<div>' . _('The following errors occurred') . ":</div>\n <div style='padding: 5px;'>" . implode('<br/>', $validation_errors) . '</div>';
Util::response_bad_request($error_msg);
示例6: import_assets_from_csv
function import_assets_from_csv($filename, $iic, $ctx, $import_type)
{
//Process status
$summary = array('general' => array('status' => '', 'data' => '', 'statistics' => array('total' => 0, 'warnings' => 0, 'errors' => 0, 'saved' => 0)), 'by_nets' => array());
$db = new ossim_db();
$conn = $db->connect();
$str_data = file_get_contents($filename);
if ($str_data === FALSE) {
$summary['general']['status'] = 'error';
$summary['general']['data']['errors'] = _('Failed to read data from CSV file');
$summary['general']['statistics']['errors'] = 1;
return $summary;
}
$array_data = preg_split('/\\n|\\r/', $str_data);
foreach ($array_data as $k => $v) {
if (trim($v) != '') {
$data[] = explode('";"', trim($v));
}
}
set_time_limit(360);
/*********************************************************************************************************************
* From net section:
* - Version 4.x.x: "Netname"*;"CIDRs(CIDR1,CIDR2,...)"*;"Description";"Asset value"*;"Net ID"
* - Version 3.x.x: "Netname"*;"CIDRs(CIDR1,CIDR2,...)"*;"Description";"Asset value";"Sensors(Sensor1,Sensor2,...)"*
*
* From welcome wizard:
* - Version 4.x.x: "Netname"*;"CIDRs(CIDR1,CIDR2,...)"*;"Description"
*
*********************************************************************************************************************/
//Check file size
if (count($data) <= 0 || count($data) == 1 && preg_match('/Netname/', $data[0][0])) {
$summary['general']['status'] = 'error';
$summary['general']['data'] = _('CSV file is empty');
$summary['general']['statistics']['errors'] = 1;
return $summary;
}
//Check importation type and headers
$csv_headers = array();
if ($import_type == 'networks') {
if (preg_match('/Net ID/', $data[0][4]) || preg_match('/Sensors/', $data[0][4])) {
$csv_headers = array_shift($data);
} else {
$summary['general']['status'] = 'error';
$summary['general']['data'] = _('Headers not found');
$summary['general']['statistics']['errors'] = 1;
return $summary;
}
}
//Setting total nets to import
$summary['general']['statistics']['total'] = count($data);
//Allowed sensors
$filters = array('where' => "acl_sensors.entity_id = UNHEX('{$ctx}')");
$a_sensors = Av_sensor::get_basic_list($conn, $filters);
$sensor_ids = array_keys($a_sensors);
if (count($sensor_ids) == 0) {
$summary['general']['status'] = 'error';
$s_error_msg = Session::is_pro() ? _('There is no sensor for this context') : _('There is no sensor for this net');
$summary['general']['data'] = $s_error_msg;
$summary['general']['statistics']['errors'] = 1;
return $summary;
}
Util::disable_perm_triggers($conn, TRUE);
foreach ($data as $k => $v) {
//Clean previous errors
ossim_clean_error();
$num_line = $k + 1;
//Set default status
$summary['by_nets'][$num_line]['status'] = 'error';
//Check file format
$cnd_1 = $import_type == 'networks' && count($v) < 5;
$cnd_2 = $import_type == 'welcome_wizard_nets' && count($v) < 3;
if ($cnd_1 || $cnd_2) {
$summary['by_nets'][$num_line]['errors']['Format'] = _('Number of fields is incorrect');
$summary['general']['statistics']['errors']++;
continue;
}
//Clean values
$param = array();
foreach ($v as $field) {
$parameter = trim($field);
$pattern = '/^\\"|\\"$|^\'|\'$/';
$param[] = preg_replace($pattern, '', $parameter);
}
//Values
$is_in_db = FALSE;
$net_id = '';
$name = $param[0];
$cidrs = preg_replace("/[\n\r\t]+/", '', $param[1]);
$descr = $param[2];
$asset_value = $param[3] == '' ? 2 : intval($param[3]);
$sensors = $sensor_ids;
//Permissions
$can_i_create_assets = Session::can_i_create_assets();
$can_i_modify_ips = TRUE;
//CIDRs
if (!ossim_valid($cidrs, OSS_IP_CIDR, 'illegal:' . _('CIDR'))) {
$summary['by_nets'][$num_line]['errors']['CIDRs'] = ossim_get_error_clean();
$summary['general']['statistics']['errors']++;
continue;
}
//.........这里部分代码省略.........
示例7: POST
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
require_once 'av_init.php';
require_once 'os_report_common.php';
Session::logcheck('report-menu', 'ReportsReportServer');
$action = POST('action');
$data = POST('data');
if ($action == 'check_file') {
$data = explode('###', base64_decode($data));
$report_name = trim($data[0]);
$filename = trim($data[1]);
ossim_valid($report_name, OSS_SCORE, OSS_NULLABLE, OSS_ALPHA, OSS_PUNC, 'illegal:' . _('Report name'));
if (ossim_error()) {
echo 'error###' . ossim_get_error_clean();
exit;
}
// Init PDF Report
$pdfReport = new Pdf_report($report_name, 'P', 'A4', NULL, FALSE);
if (isset($filename) && !empty($filename)) {
ossim_valid($filename, OSS_FILENAME, 'illegal:' . _('Filename'));
//Get complete path
$path = $pdfReport->getpath() . $filename;
$res = !ossim_error() && file_exists($path) ? 1 : _('Unable to access to PDF Report');
echo $res;
}
} elseif ($action == 'check_email') {
ossim_valid($data, OSS_MAIL_ADDR, 'illegal:' . _('Email address'));
$res = !ossim_error() ? 1 : ossim_get_error_clean();
echo $res;
}
示例8: dirname
*
*/
require_once dirname(__FILE__) . '/../../conf/config.inc';
Session::logcheck('environment-menu', 'EventsHidsConfig');
$sensor_id = POST('sensor_id');
ossim_valid($sensor_id, OSS_HEX, 'illegal:' . _('Sensor ID'));
if (!ossim_error()) {
$db = new ossim_db();
$conn = $db->connect();
if (!Ossec_utilities::is_sensor_allowed($conn, $sensor_id)) {
ossim_set_error(_('Error! Sensor not allowed'));
}
$db->close();
}
if (ossim_error()) {
echo '2###' . _('We found the followings errors') . ": <div style='padding-left: 15px; text-align:left;'>" . ossim_get_error_clean() . '</div>';
exit;
}
//Current sensor
$_SESSION['ossec_sensor'] = $sensor_id;
echo '1###';
try {
$rules = Ossec::get_rule_files($sensor_id, FALSE);
$options_e .= "<optgroup label='" . _('Editable rule file') . "'>\n";
$options_ne .= "<optgroup label='" . _('Rules files read-only') . "'>\n";
foreach ($rules as $rule) {
if (Ossec::is_editable($rule)) {
$options_e .= "<option style='text-align: left;' value='{$rule}'>{$rule}</option>\n";
} else {
$options_ne .= "<option style='text-align: left;' value='{$rule}'>{$rule}</option>\n";
}
示例9: ossim_valid
// Filters
ossim_valid($view, OSS_LETTER, 'illegal:' . _('View Param'));
ossim_valid($type, OSS_LETTER, ',', OSS_NULLABLE, 'illegal:' . _('Type Param'));
ossim_valid($level, OSS_LETTER, ',', OSS_NULLABLE, 'illegal:' . _('Level Param'));
/***************************
****** RESPONSE VARS ******
***************************/
// Response array
$response = array();
// Array to store data
$data = array();
$total_messages = 0;
try {
// If validation errors throw new exception with error details
if (ossim_error()) {
Av_exception::throw_error(Av_exception::USER_ERROR, ossim_get_error_clean());
}
if (strlen($search_str) > 30) {
Av_exception::throw_error(Av_exception::USER_ERROR, 'Search string very long. Max length 30 characters');
}
/*********************
****** Filters ******
*********************/
/**
* Returns order_by string by column
*
* @param integer $order
*
* @return string
*/
$order_by = function ($order) {
示例10: json_encode
echo json_encode($data);
exit;
}
$assets_string = '';
$data['status'] = 'OK';
$data['data'] = NULL;
$error = FALSE;
$aux = array();
$db = new ossim_db();
$conn = $db->connect();
if (is_array($assets) && count($assets) > 0) {
foreach ($assets as $asset) {
ossim_valid($asset, OSS_IP_ADDRCIDR, 'illegal:' . _('Asset'));
if (ossim_error()) {
$data['status'] = 'error';
$data['data'] = "<div style='text-align: left; padding: 0px 0px 3px 10px;'>" . _('We found the following errors') . ":</div>\n\t\t\t\t\t\t<div class='error_item'>" . ossim_get_error_clean() . "</div>";
echo json_encode($data);
exit;
} else {
if (!preg_match('/\\/\\d{1,2}$/', $asset)) {
$aux[] = $asset . '/32';
} else {
$aux[] = $asset;
}
}
}
}
$assets_string .= implode(' ', $aux);
$db->close();
$assets = $assets_string;
$scan_path_log = "/tmp/nmap_scanning_" . md5(Session::get_secure_id()) . '.log';
示例11: session_write_close
* @copyright 2003-2006 ossim.net
* @copyright 2007-2013 AlienVault
* @link https://www.alienvault.com/
*/
require_once 'av_init.php';
Session::logcheck("environment-menu", "PolicyHosts");
// Close session write for real background loading
session_write_close();
$asset_id = GET('asset_id');
$service = GET('service');
$port = GET('port');
ossim_valid($asset_id, OSS_HEX, 'illegal: ' . _('Asset ID'));
ossim_valid($service, OSS_ALPHA, OSS_PUNC_EXT, 'illegal: ' . _('Service name'));
ossim_valid($port, OSS_DIGIT, 'illegal: ' . _('Port number'));
if (ossim_error()) {
throw new Exception(ossim_get_error_clean());
}
$db = new ossim_db();
$conn = $db->connect();
$filters = array('where' => "h.id = UNHEX('{$asset_id}') AND host_services.port = {$port} AND host_services.service = '" . escape_sql($service, $conn) . "'");
$_list_data = Asset_host_services::get_list($conn, $filters);
$services = $_list_data[0];
if (empty($services[$asset_id][0])) {
$db->close();
throw new Exception(_('Service not found'));
}
$service_data = $services[$asset_id][0];
$_host_aux = Asset_host::get_object($conn, $asset_id);
$_ips_aux = array_keys($_host_aux->get_ips()->get_ips());
$_ctx_aux = $_host_aux->get_ctx();
$vulns = Asset_host_services::get_vulns_by_service($conn, $_ips_aux, $_ctx_aux, $service, $port);
示例12: POST
*****************************/
// Get params
$action = POST('action');
$component_ids = POST('component_ids');
$tag_id = POST('tag_id');
$select_from_filter = POST('select_from_filter');
$component_type = POST('component_type') ? POST('component_type') : 'asset';
// Validate action type
ossim_valid($action, OSS_LETTER, '_', 'illegal: ' . _('Action'));
ossim_valid($component_ids, OSS_HEX, OSS_NULLABLE, 'illegal: ' . _('Component ID'));
ossim_valid($tag_id, OSS_HEX, 'illegal: ' . _('Label ID'));
ossim_valid($select_from_filter, OSS_LETTER, 'illegal: ' . _('Filter value'));
ossim_valid($component_type, OSS_LETTER, 'illegal: ' . _('Component type'));
if (ossim_error()) {
$response['status'] = 'error';
$response['data'] = ossim_get_error_clean();
echo json_encode($response);
exit;
}
// Validate Token
if (Token::verify('tk_av_dropdown_tag_token', POST('token')) == FALSE) {
$response['status'] = 'error';
$response['data'] = Token::create_error_message();
echo json_encode($response);
exit;
}
/************************
****** DO ACTIONS ******
************************/
// Database access object
$db = new ossim_db();
示例13: dirname
require_once dirname(__FILE__) . '/../../conf/config.inc';
Session::logcheck('environment-menu', 'EventsHidsConfig');
$file = POST('file');
$sensor_id = POST('sensor_id');
ossim_valid($sensor_id, OSS_HEX, 'illegal:' . _('Sensor ID'));
ossim_valid($file, OSS_ALPHA, OSS_SCORE, OSS_DOT, 'illegal:' . _('File'));
if (!ossim_error()) {
$db = new ossim_db();
$conn = $db->connect();
if (!Ossec_utilities::is_sensor_allowed($conn, $sensor_id)) {
ossim_set_error(_('Error! Sensor not allowed'));
}
$db->close();
}
if (ossim_error()) {
$data['status'] = 'error';
$data['data'] = _('We found the followings errors:') . "<div style='padding-left: 15px; text-align:left;'>" . ossim_get_error_clean() . '</div>';
echo json_encode($data);
exit;
}
//Rule file
$_SESSION['_current_file'] = $file;
try {
$rule_data = Ossec::get_rule_file($sensor_id, $file);
$data['status'] = 'success';
$data['data'] = $rule_data['data'];
} catch (Exception $e) {
$data['status'] = 'error';
$data['data'] = $e->getMessage();
}
echo json_encode($data);
示例14: ossim_get_error_clean
}
#update_notification
{
text-align: center;
width:90%;
margin:0 auto;
}
</style>
</head>
<body>
<?php
if (($action == "migrate" || $action == "update") && Session::am_i_admin()) {
if (!ossim_valid($smethod, 'rsync', 'wget', 'illegal:' . _("synchronization method"))) {
$error_message .= ossim_get_error_clean() . "<br/>";
ossim_clean_error();
} else {
$result_check = CheckScanner();
if ($result_check != "") {
$config_nt = array('content' => $result_check, 'options' => array('type' => 'nf_warning', 'cancel_button' => false), 'style' => 'width: 98%; margin:5px auto; text-align: center;');
$nt = new Notification('nt_1', $config_nt);
$nt->show();
} else {
exec("export HOME='/tmp';cd /usr/share/ossim/scripts/vulnmeter/;nohup perl updateplugins.pl {$action} {$smethod} > /var/tmp/openvas_update 2>&1 &");
}
}
}
if ($action == "create" && $error_message == "") {
$show_notification = true;
$message = _("Credential created successfully");
示例15: POST
$remoteurl = POST('remoteurl');
$setssh = POST('setssh') ? 1 : 0;
$rservers = POST('rservers');
$rservers = $_POST['rservers'];
unset($_POST['rservers']);
$validation_errors = validate_form_fields('POST', $validate);
$fwrd_server = array();
if (is_array($rservers) && !empty($rservers)) {
foreach ($rservers as $rserver) {
$rserver = explode('@', $rserver);
$fwr_ser = $rserver[0];
$fwr_prio = $rserver[1];
ossim_valid($fwr_ser, OSS_HEX, 'illegal:' . _("Forward Servers"));
ossim_valid($fwr_prio, OSS_DIGIT, 'illegal:' . _("Forward Priority"));
if (ossim_error()) {
$validation_errors['rservers[]'] = ossim_get_error_clean();
ossim_clean_error();
} else {
$fwrd_server[$fwr_ser] = $fwr_prio;
}
}
}
$data['status'] = 'OK';
$data['data'] = $validation_errors;
if (POST('ajax_validation_all') == TRUE) {
if (is_array($validation_errors) && !empty($validation_errors)) {
$data['status'] = 'error';
echo json_encode($data);
} else {
$data['status'] = 'OK';
echo json_encode($data);