function logprint($conn) { $policys = Policy::get_list($conn, "order by policy.order"); foreach ($policys as $p) { echo " policy: order:" . $p->get_order() . " group:" . $p->get_group() . "<br>"; } }
$db = new ossim_db(); $conn = $db->connect(); $policy_list = Policy::get_list($conn); foreach ($policy_list as $policy) { $id_group = $policy->get_group(); $id = $policy->get_id(); $rs = $conn->Execute("SELECT name FROM policy_group WHERE group_id={$id_group}"); if ($rs->fields["name"] == "") { $conn->Execute("UPDATE policy SET policy.group=0 WHERE id={$id}"); } } // $neworder = 1; $policy_groups = Policy::get_policy_groups($conn); foreach ($policy_groups as $group) { $policy_list = Policy::get_list($conn, "WHERE policy.group=" . $group->get_group_id() . " ORDER BY policy.priority"); foreach ($policy_list as $policy) { $id = $policy->get_id(); $conn->Execute("UPDATE policy SET policy.order={$neworder} WHERE id={$id}"); $neworder++; } } $reorderpolicygrps = Policy::get_policy_groups($conn, "ORDER BY order"); $neworder = 1000; foreach ($reorderpolicygrps as $policy) { if (intval($policy->get_group_id()) != 0) { $conn->Execute("UPDATE policy_group SET policy_group.order={$neworder} WHERE group_id=" . $policy->get_group_id()); $neworder++; } } $db->close($conn);
if ($group_dst != $group_src) { $order_dst = Policy::get_next_order($conn, $ctx, $group_dst); } else { $where = " AND ctx=UNHEX('{$ctx}') AND policy.group=UNHEX('{$group_dst}') ORDER BY policy.order DESC LIMIT 1"; $policy_dst = Policy::get_list($conn, $where); if (is_array($policy_dst) && !empty($policy_dst)) { $policy_dst = array_shift($policy_dst); } } } else { ossim_valid($policy_dst, OSS_HEX, 'illegal:' . _("Dst")); if (ossim_error()) { die(ossim_error()); } $group_dst = Policy::get_group_from_id($conn, $policy_dst); $policy_dst = Policy::get_list($conn, " AND id=UNHEX('{$policy_dst}')"); if (is_array($policy_dst) && !empty($policy_dst)) { $policy_dst = array_shift($policy_dst); $order_dst = $policy_dst->get_order(); } else { die('Source was an incorrect parameter.'); } $log_dst = $order_dst . " (" . $policy_dst->get_id() . ")"; } if ($group_src == $group_dst) { // same group => swap Policy::swap_simple_orders($conn, $policy_src, $policy_dst); } else { // different group => especial swap if ($order_src < $order_dst) { // Only change group (do not change order value)
echo "<rows>\n<page>1</page>\n<total>0</total>\n</rows>\n"; exit; } if (!empty($order)) { $order .= POST('sortorder') == "asc" ? "" : " desc"; } else { $order = "priority"; } $where = $group != "0" ? "AND policy.group=UNHEX('{$group}')" : "AND policy.group=UNHEX('00000000000000000000000000000000')"; $start = ($page - 1) * $rp; $limit = "LIMIT {$start}, {$rp}"; $db = new ossim_db(); $conn = $db->connect(); $xml = ""; $filter = get_filters_names($conn); $policy_list = Policy::get_list($conn, "AND ctx=UNHEX('{$ctx}') {$where} ORDER BY policy.{$order}"); if ($policy_list[0]) { $total = $policy_list[0]->get_foundrows(); if ($total == 0) { $total = count($policy_list); } } else { $total = 0; } $engine = is_ctx_engine($conn, $ctx) ? 'engine' : 'ctx'; $xml .= "<rows>\n"; $xml .= "<page>{$page}</page>\n"; $xml .= "<total>{$total}</total>\n"; if ($total > 0) { list($conds_list, $pol_conds) = Policy::get_conditions_hash($conn, $ctx); }
* * Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt * */ require_once 'av_init.php'; Session::logcheck("configuration-menu", "PolicyPolicy"); $db = new ossim_db(); $conn = $db->connect(); //Getting the policies… $ctxs = array(); $ctxs = Policy::get_all_ctx($conn); foreach ($ctxs as $ctx) { $neworder = 1; $policy_groups = Policy_group::get_list($conn, " AND ctx=UNHEX('{$ctx}')", true); foreach ($policy_groups as $group) { $policy_list = Policy::get_list($conn, "AND ctx=UNHEX('{$ctx}') AND policy.group=UNHEX('" . $group->get_group_id() . "') ORDER BY policy.order, priority"); foreach ($policy_list as $policy) { $id = $policy->get_id(); $conn->Execute("UPDATE policy SET policy.order={$neworder} WHERE id=UNHEX('{$id}')"); $neworder++; } } $reorderpolicygrps = Policy_group::get_list($conn, " AND ctx=UNHEX('{$ctx}')", FALSE); $neworder = 1; foreach ($reorderpolicygrps as $policy) { $conn->Execute("UPDATE policy_group SET policy_group.order={$neworder} WHERE id=UNHEX('" . $policy->get_group_id() . "')"); $neworder++; } } $db->close(); header("Location: " . Menu::get_menu_url('/ossim/policy/policy.php', 'configuration', 'threat_intelligence', 'policy'));
$date_type = 1; //Assets Filters $ports_source[] = "ANY"; $ports_destiny[] = "ANY"; $targets['00000000000000000000000000000000'] = "ANY"; $sensors['00000000000000000000000000000000'] = "ANY"; $plugingroups[] = '00000000000000000000000000000000'; } if ($utz == "0" || $utz == "") { $utz = 'UTC'; } if (preg_match("/Localtime/", $utz)) { $utz = trim(`head -1 /etc/timezone`); } if ($insert != "") { if ($policies = Policy::get_list($conn, " AND id=UNHEX('{$insert}')")) { $order = $policies[0]->get_order(); $group = $policies[0]->get_group(); if (GET('insertafter') != "") { $order++; } // insert after } } if (!$open_source) { $def_server = Server::get_deafault_server($conn); if (!empty($def_server)) { $def_server = str_replace('-', '', $def_server); } $server_h = Server::get_my_hierarchy($conn, $def_server); }
ossim_valid($search, OSS_TEXT, OSS_NULLABLE, 'illegal:' . _("search")); ossim_valid($field, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("field")); if (ossim_error()) { die(ossim_error()); } if (empty($order)) { $order = "priority"; } $where = $group != "" ? "WHERE policy.group={$group}" : ""; $start = ($page - 1) * $rp; $limit = "LIMIT {$start}, {$rp}"; // do not use $db = new ossim_db(); $conn = $db->connect(); $xml = ""; $policy_list = Policy::get_list($conn, "{$where} ORDER BY policy.{$order}"); if ($policy_list[0]) { $total = $policy_list[0]->get_foundrows(); if ($total == 0) { $total = count($policy_list); } } else { $total = 0; } $xml .= "<rows>\n"; $xml .= "<page>{$page}</page>\n"; $xml .= "<total>{$total}</total>\n"; foreach ($policy_list as $policy) { $id = $policy->get_id(); $order = $policy->get_order(); $xml .= "<row id='{$order}'>";
require_once 'classes/Host.inc'; require_once 'classes/Net.inc'; require_once 'classes/Port_group.inc'; require_once 'classes/Sensor.inc'; require_once 'classes/Server.inc'; require_once 'ossim_db.inc'; require_once 'classes/Security.inc'; $id = GET('id'); ossim_valid($id, OSS_ALPHA, OSS_PUNC, OSS_SPACE, 'illegal:' . _("Policy id")); if (ossim_error()) { die(ossim_error()); } $db = new ossim_db(); $conn = $db->connect(); settype($id, "int"); if ($policy_list = Policy::get_list($conn, "WHERE id = {$id}")) { $policy = $policy_list[0]; } ?> </p> <form method="post" action="modifypolicy.php?id=<?php echo $id; ?> "> <table align="center"> <input type="hidden" name="insert" value="insert"> <tr> <th> <?php echo gettext("Source");
} } $db->close($conn); } $OssimWebIndicator->update_display(); exit; } require_once 'ossim_db.inc'; require_once 'classes/Policy.inc'; require_once 'classes/Response.inc'; $db = new ossim_db(); $conn = $db->connect(); $ids = explode(",", $id); foreach ($ids as $id) { if ($id != "") { $list = Policy::get_list($conn, "WHERE policy.order={$id}"); if ($list[0]) { $pid = $list[0]->get_id(); Policy::delete($conn, $pid); // Response/Actions $response_list = Response::get_list($conn, "WHERE descr='policy {$pid}'"); if ($response_list[0]) { Response::delete($conn, $response_list[0]->get_id()); } } } } $db->close($conn); ?> <p> <?php
function get_targets($conn, $data) { $id = $data['id']; ossim_valid($id, OSS_HEX, OSS_NULLABLE, 'illegal:' . _("CTX")); if (ossim_error()) { $info_error = "Error: " . ossim_get_error(); ossim_clean_error(); $return['error'] = TRUE; $return['msg'] = $info_error; return $return; } $result = ""; $servers = array(); $targets = array(); //Getting all the serves: $server_list = Server::get_list($conn); foreach ($server_list as $server) { $servers[$server->get_id()] = $server->get_name(); } if ($policies = Policy::get_list($conn, "AND id=UNHEX('{$id}')")) { $policy = $policies[0]; if ($target_list = $policy->get_targets($conn)) { foreach ($target_list as $target) { $targets[$target->get_target_id()] = $servers[$target->get_target_id()] == "" ? _("ANY") : $servers[$target->get_target_id()]; } } } $i = 1; if ($server_list = Server::get_list($conn, "ORDER BY name")) { foreach ($server_list as $server) { $server_name = $server->get_name(); $server_id = $server->get_id(); $server_ip = $server->get_ip(); if ($i == 1) { $result .= "<input type='hidden' name='targetserver' value='" . count($server_list) . "'/>"; } $name = "targboxserver" . $i; $result .= "<input type='checkbox' onclick='drawpolicy()' id='target_{$server_ip} ({$server_name})' name='{$name}' value='{$server_id}'" . ($targets[$server_id] != '' ? "checked='checked'" : "") . "/>{$server_ip}({$server_name})<br/>"; $i++; } } /* == ANY target == */ $return['error'] = FALSE; $return['data'] = $result; return $return; }
$active = 1; $order = 0; $resend_alarm = 1; $resend_event = 1; $sign = 0; $sem = 0; $sim = 1; if ($group == "") { $group = 1; } $desc = ""; $sources = $dests = $ports = $plugingroups = $sensors = $targets = $actions = array(); $timearr = array(1, 0, 7, 23); if ($id != "") { settype($id, "int"); if ($policies = Policy::get_list($conn, "WHERE policy.order={$id}")) { $policy = $policies[0]; $id = $policy->get_id(); $priority = $policy->get_priority(); $active = $policy->get_active(); $group = $policy->get_group(); $order = $policy->get_order(); if ($source_host_list = $policy->get_hosts($conn, 'source')) { foreach ($source_host_list as $source_host) { //$host = Host::ip2hostname($conn, $source_host->get_host_ip()); $sources[] = $host == "any" ? "ANY" : "HOST:" . $source_host->get_host_ip(); } } if ($source_net_list = $policy->get_nets($conn, 'source')) { foreach ($source_net_list as $source_net) { $sources[] = "NETWORK:" . $source_net->get_net_name();