"", "bind_to" => "", "policy" => "bsd" ); $def_libhtp_policy = array( "name" => "default", "bind_to" => "all", "personality" => "IDS", "request-body-limit" => 4096, "response-body-limit" => 4096, "double-decode-path" => "no", "double-decode-query" => "no" ); // Figure out which engine type we are importing and set up default engine array $engine = array(); switch ($eng) { case "host_os_policy": $engine = $def_os_policy; break; case "libhtp_policy": $engine = $def_libhtp_policy; break; default: $engine = ""; $input_errors[] = gettext("Invalid ENGINE TYPE passed in query string. Aborting operation."); } // See if anything was checked to import if (is_array($_POST['toimport']) && count($_POST['toimport']) > 0) { foreach ($_POST['toimport'] as $item) { $engine['name'] = strtolower($item); $engine['bind_to'] = $item; $a_nat[] = $engine; } } else $input_errors[] = gettext("No entries were selected for import. Please select one or more Aliases for import and click SAVE."); // if no errors, write new entry to conf if (!$input_errors) { // Reorder the engine array to ensure the // 'bind_to=all' entry is at the bottom if // the array contains more than one entry. if (count($a_nat) > 1) { $i = -1; foreach ($a_nat as $f => $v) { if ($v['bind_to'] == "all") { $i = $f; break; } } // Only relocate the entry if we // found it, and it's not already // at the end. if ($i > -1 && ($i < (count($a_nat) - 1))) { $tmp = $a_nat[$i]; unset($a_nat[$i]); $a_nat[] = $tmp; } } // Now write the new engine array to conf and return write_config(); header("Location: {$returl}?id={$id}"); exit; } } $pgtitle = gettext("Suricata: Import Host/Network Alias for {$title}"); include("head.inc"); ?>