Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pfSense-pkg-suricata-5.0.4-RELENG_2_4_5 - GUI update for 5.0.4 binary support and bug fixes. #989

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions security/pfSense-pkg-suricata/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# $FreeBSD$

PORTNAME= pfSense-pkg-suricata
PORTVERSION= 5.0.3
PORTVERSION= 5.0.4
CATEGORIES= security
MASTER_SITES= # empty
DISTFILES= # empty
Expand All @@ -12,7 +12,7 @@ COMMENT= pfSense package suricata

LICENSE= APACHE20

RUN_DEPENDS= suricata>=5.0.3:security/suricata
RUN_DEPENDS= suricata>=5.0.4:security/suricata

NO_BUILD= yes
NO_MTREE= yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@
if (!is_array($suricatacfg['libhtp_policy']['item']))
$suricatacfg['libhtp_policy']['item'] = array();
if (count($suricatacfg['libhtp_policy']['item']) < 1) {
$http_hosts_default_policy = " personality: IDS\n request-body-limit: 4096\n response-body-limit: 4096\n";
$http_hosts_default_policy = "personality: IDS\n request-body-limit: 4096\n response-body-limit: 4096\n";
$http_hosts_default_policy .= " double-decode-path: no\n double-decode-query: no\n uri-include-all: no\n";
}
else {
Expand Down Expand Up @@ -801,15 +801,15 @@
}
}
else {
$http_hosts_default_policy = " personality: {$v['personality']}\n request-body-limit: {$v['request-body-limit']}\n";
$http_hosts_default_policy = "personality: {$v['personality']}\n request-body-limit: {$v['request-body-limit']}\n";
$http_hosts_default_policy .= " response-body-limit: {$v['response-body-limit']}\n";
$http_hosts_default_policy .= " meta-field-limit: " . (isset($v['meta-field-limit']) ? $v['meta-field-limit'] : "18432") . "\n";
$http_hosts_default_policy .= " double-decode-path: {$v['double-decode-path']}\n";
$http_hosts_default_policy .= " double-decode-query: {$v['double-decode-query']}\n";
$http_hosts_default_policy .= " uri-include-all: {$v['uri-include-all']}\n";
}
}
// Remove trailing newline
// Remove any leading or trailing spaces and newline
$http_hosts_default_policy = trim($http_hosts_default_policy);
$http_hosts_policy = trim($http_hosts_policy);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ function build_logfile_list() {
<thead>
<tr class="sortableHeaderRowIdentifier text-nowrap">
<th data-sortable-type="date"><?=gettext("Date"); ?></th>
<th><?=gettext("Action"); ?></th>
<th data-sortable-type="numeric"><?=gettext("Pri"); ?></th>
<th><?=gettext("Proto"); ?></th>
<th><?=gettext("Class"); ?></th>
Expand Down Expand Up @@ -1053,6 +1054,42 @@ function build_logfile_list() {
/* Protocol */
$alert_proto = $fields['proto'];

/* Action */
if (isset($fields['action']) && $a_instance[$instanceid]['blockoffenders'] == 'on' && ($a_instance[$instanceid]['ips_mode'] == 'ips_mode_inline' || $a_instance[$instanceid]['block_drops_only'] == 'on')) {

switch ($fields['action']) {

case "Drop":
case "wDrop":
if (isset($dropsid[$fields['gid']][$fields['sid']])) {
$alert_action = '<i class="fa fa-thumbs-down icon-pointer text-danger text-center" title="';
$alert_action .= gettext("Rule action is User-Forced to DROP. Click to force a different action for this rule.");
}
elseif ($a_instance[$instanceid]['ips_mode'] == 'ips_mode_inline' && isset($rejectsid[$fields['gid']][$fields['sid']])) {
$alert_action = '<i class="fa fa-hand-stop-o icon-pointer text-warning text-center" title="';
$alert_action .= gettext("Rule action is User-Forced to REJECT. Click to force a different action for this rule.");
}
else {
$alert_action = '<i class="fa fa-thumbs-down icon-pointer text-danger text-center" title="';
$alert_action .= gettext("Rule action is DROP. Click to force a different action for this rule.");
}
break;

default:
$alert_action = '<i class="fa fa-question-circle icon-pointer text-danger text-center" title="' . gettext("Rule action is unrecognized!. Click to force a different action for this rule.");
}
$alert_action .= '" onClick="toggleAction(\'' . $fields['gid'] . '\', \'' . $fields['sid'] . '\');"</i>';
}
else {
if ($a_instance[$instanceid]['blockoffenders'] == 'on' && ($a_instance[$instanceid]['ips_mode'] == 'ips_mode_inline' || $a_instance[$instanceid]['block_drops_only'] == 'on')) {
$alert_action = '<i class="fa fa-exclamation-triangle icon-pointer text-warning text-center" title="' . gettext("Rule action is ALERT.");
$alert_action .= '" onClick="toggleAction(\'' . $fields['gid'] . '\', \'' . $fields['sid'] . '\');"</i>';
}
else {
$alert_action = '<i class="fa fa-exclamation-triangle text-warning text-center" title="' . gettext("Rule action is ALERT.") . '"</i>';
}
}

/* IP SRC */
if ($decoder_event == FALSE) {
$alert_ip_src = $fields['src'];
Expand Down Expand Up @@ -1174,6 +1211,7 @@ function build_logfile_list() {
<tr>
<?php endif; ?>
<td><?=$alert_date;?><br/><?=$alert_time;?></td>
<td><?=$alert_action; ?></td>
<td><?=$alert_priority;?></td>
<td style="word-wrap:break-word; white-space:normal"><?=$alert_proto;?></td>
<td style="word-wrap:break-word; white-space:normal"><?=$alert_class;?></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,26 @@
$if_real = get_real_interface($a_nat[$rulei]['interface']);
$if_friendly = convert_friendly_interface_to_friendly_descr($a_nat[$rulei]['interface']);
$suricata_uuid = $a_nat[$rulei]['uuid'];
suricata_stop($a_nat[$rulei], $if_real);
rmdir_recursive("{$suricatalogdir}suricata_{$if_real}{$suricata_uuid}");
rmdir_recursive("{$suricatadir}suricata_{$suricata_uuid}_{$if_real}");

// Check that we still have the real interface defined in pfSense.
// The real interface will return as an empty string if it has
// been removed in pfSense.
if ($if_real == "") {
rmdir_recursive("{$suricatalogdir}suricata_{$if_real}{$suricata_uuid}");
rmdir_recursive("{$suricatadir}suricata_{$suricata_uuid}_*");
syslog(LOG_NOTICE, "Deleted the Suricata instance on a previously removed pfSense interface per user request...");
}
else {
// Delete the interface sub-directories and then the instance itself
$if_friendly = convert_friendly_interface_to_friendly_descr($snortcfg['interface']);
syslog(LOG_NOTICE, "Stopping Suricata on {$if_friendly}({$if_real}) due to Suricata instance deletion...");
suricata_stop($a_nat[$rulei], $if_real);
rmdir_recursive("{$suricatalogdir}suricata_{$if_real}{$suricata_uuid}");
rmdir_recursive("{$suricatadir}suricata_{$suricata_uuid}_{$if_real}");
syslog(LOG_NOTICE, "Deleted Suricata instance on {$if_friendly}({$if_real}) per user request...");
}

// Finally, delete the interface's config entry entirely
unset($a_nat[$rulei]);
}

Expand Down Expand Up @@ -90,14 +107,27 @@
$if_real = get_real_interface($a_nat[$delbtn_list]['interface']);
$if_friendly = convert_friendly_interface_to_friendly_descr($a_nat[$delbtn_list]['interface']);
$suricata_uuid = $a_nat[$delbtn_list]['uuid'];
syslog(LOG_NOTICE, "Stopping Suricata on {$if_friendly}({$if_real}) due to interface deletion...");
suricata_stop($a_nat[$delbtn_list], $if_real);
rmdir_recursive("{$suricatalogdir}suricata_{$if_real}{$suricata_uuid}");
rmdir_recursive("{$suricatadir}suricata_{$suricata_uuid}_{$if_real}");

// Finally delete the interface's config entry entirely
unset($a_nat[$delbtn_list]);
syslog(LOG_NOTICE, "Deleted Suricata instance on {$if_friendly}({$if_real}) per user request...");
// Check that we still have the real interface defined in pfSense.
// The real interface will return as an empty string if it has
// been removed in pfSense.
if ($if_real == "") {
rmdir_recursive("{$suricatalogdir}suricata_{$if_real}{$suricata_uuid}");
rmdir_recursive("{$suricatadir}suricata_{$suricata_uuid}_*");
syslog(LOG_NOTICE, "Deleted the Suricata instance on a previously removed pfSense interface per user request...");
}
else {
// Delete the interface sub-directories and then the instance itself
$if_friendly = convert_friendly_interface_to_friendly_descr($snortcfg['interface']);
syslog(LOG_NOTICE, "Stopping Suricata on {$if_friendly}({$if_real}) due to Suricata instance deletion...");
suricata_stop($a_nat[$rulei], $if_real);
rmdir_recursive("{$suricatalogdir}suricata_{$if_real}{$suricata_uuid}");
rmdir_recursive("{$suricatadir}suricata_{$suricata_uuid}_{$if_real}");
syslog(LOG_NOTICE, "Deleted Suricata instance on {$if_friendly}({$if_real}) per user request...");
}

// Finally, delete the interface's config entry entirely
unset($a_nat[$rulei]);

// Save updated configuration
write_config("Suricata pkg: deleted one or more Suricata interfaces.");
Expand Down Expand Up @@ -185,6 +215,10 @@
// into an associative array. Return the array to the Ajax
// caller as a JSON object.
foreach ($a_nat as $intf) {
// Skip status update for any missing real interface
if (($if_real = get_real_interface($intf['interface'])) == "") {
continue;
}
$intf_key = "suricata_" . get_real_interface($intf['interface']) . $intf['uuid'];
if ($intf['enable'] == "on") {
if (suricata_is_running($intf['uuid'], get_real_interface($intf['interface']))) {
Expand Down Expand Up @@ -283,10 +317,17 @@
?>
<tr id="fr<?=$nnats?>">
<?php
/* convert fake interfaces to real and check if iface is up */
/* There has to be a smarter way to do this */
/* Convert fake interfaces to real and check if iface is up. */
/* A null real interface indicates it has been removed from system. */
$if_real = get_real_interface($natent['interface']);
$natend_friendly= convert_friendly_interface_to_friendly_descr($natent['interface']);
if (($if_real = get_real_interface($natent['interface'])) == "") {
$natent['enable'] = "off";
$natend_friendly = gettext("Missing (removed?)");
}
else {
$natend_friendly = convert_friendly_interface_to_friendly_descr($natent['interface']) . " ({$if_real})";
}

$suricata_uuid = $natent['uuid'];

/* See if interface has any rules defined and set boolean flag */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
$suricatadir = SURICATADIR;
$suricatalogdir = SURICATALOGDIR;

// Define an array of native-mode netmap compatible NIC drivers
$netmapifs = array('cc', 'cxl', 'cxgbe', 'em', 'igb', 'em', 'lem', 'ix', 'ixgbe', 'ixl', 're', 'vtnet');
if (pfs_version_compare(false, 2.4, $g['product_version'])) {
/* add FreeBSD 12 iflib(4) supported devices */
$netmapifs = array_merge($netmapifs, array('ice', 'bnxt', 'vmx'));
sort($netmapifs);
}

init_config_arr(array('installedpackages', 'suricata', 'rule'));
$suricataglob = $config['installedpackages']['suricata'];
$a_rule = &$config['installedpackages']['suricata']['rule'];
Expand Down Expand Up @@ -68,6 +76,14 @@
// Get the physical configured interfaces on the firewall
$interfaces = get_configured_interface_with_descr();

// Footnote real interface associated with each configured interface
foreach ($interfaces as $if => $desc) {
$interfaces[$if] = $interfaces[$if] . " (" . get_real_interface($if) . ")";
}

// Add a special "Unassigned" interface selection at end of list
$interfaces["Unassigned"] = gettext("Unassigned");

// See if interface is already configured, and use its values
if (isset($id) && isset($a_rule[$id])) {
/* old options */
Expand All @@ -76,6 +92,10 @@
$pconfig['configpassthru'] = base64_decode($pconfig['configpassthru']);
if (empty($pconfig['uuid']))
$pconfig['uuid'] = $suricata_uuid;
if (get_real_interface($pconfig['interface']) == "") {
$pconfig['interface'] = gettext("Unassigned");
$pconfig['enable'] = "off";
}
}

// Must be a new interface, so try to pick next available physical interface to use
Expand Down Expand Up @@ -305,6 +325,20 @@
}
}

if ($_POST['ips_mode'] == 'ips_mode_inline') {
$is_netmap = false;
$realint = get_real_interface($_POST['interface']);
foreach ($netmapifs as $if) {
if (substr($realint, 0, strlen($if)) == $if) {
$is_netmap = true;
break;
}
}
if (!$is_netmap) {
$input_errors[] = gettext("The '{$_POST['interface']}' interface does not support Inline IPS Mode with native netmap.");
}
}

// If Suricata is disabled on this interface, stop any running instance,
// save the change and exit.
if ($_POST['enable'] != 'on') {
Expand Down Expand Up @@ -653,9 +687,11 @@ function suricata_get_config_lists($lists) {
print_info_box($savemsg2);
}

// If using Inline IPS, check that CSO, TSO and LRO are all disabled
if ($pconfig['enable'] == 'on' && $pconfig['ips_mode'] == 'ips_mode_inline' && (!isset($config['system']['disablechecksumoffloading']) || !isset($config['system']['disablesegmentationoffloading']) || !isset($config['system']['disablelargereceiveoffloading']))) {
print_info_box(gettext('IPS inline mode requires that Hardware Checksum, Hardware TCP Segmentation and Hardware Large Receive Offloading ' .
'all be disabled on the ') . '<b>' . gettext('System > Advanced > Networking ') . '</b>' . gettext('tab.'));
print_info_box(gettext('WARNING! IPS inline mode requires that Hardware Checksum Offloading, Hardware TCP Segmentation Offloading and Hardware Large Receive Offloading ' .
'all be disabled for proper operation. This firewall currently has one or more of these Offloading settings NOT disabled. Visit the ') . '<a href="/system_advanced_network.php">' .
gettext('System > Advanced > Networking') . '</a>' . gettext(' tab and ensure all three of these Offloading settings are disabled.'));
}

$tab_array = array();
Expand Down