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-snort-4.0_13 - Randomize rules update check to spread load on Snort.org. #818

Merged
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
2 changes: 1 addition & 1 deletion security/pfSense-pkg-snort/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

PORTNAME= pfSense-pkg-snort
PORTVERSION= 4.0
PORTREVISION= 12
PORTREVISION= 13
CATEGORIES= security
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ function snort_rules_up_install_cron($should_install) {
if (!empty($config['installedpackages']['snortglobal']['rule_update_starttime']))
$snort_rules_upd_time = $config['installedpackages']['snortglobal']['rule_update_starttime'];
else
$snort_rules_upd_time = "00:03";
$snort_rules_upd_time = "00:" . strval(random_int(0, 59));

if ($snort_rules_up_info_ck == "6h_up") {
$snort_rules_up_min = intval(substr($snort_rules_upd_time, -2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* part of pfSense (https://www.pfsense.org)
* Copyright (c) 2006-2020 Rubicon Communications, LLC (Netgate)
* Copyright (c) 2009 Robert Zelaya
* Copyright (c) 2013-2019 Bill Meeks
* Copyright (c) 2013-2020 Bill Meeks
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -426,6 +426,9 @@ function snort_copy($srcFilePathPattern, $destPath){
unlink_if_exists("{SNORT_RULES_UPD_LOGFILE}");
}

/* Sleep for random number of seconds between 0 and 35 to spread load on rules site */
sleep(random_int(0, 35));

/* Log start time for this rules update */
error_log(gettext("Starting rules update... Time: " . date("Y-m-d H:i:s") . "\n"), 3, SNORT_RULES_UPD_LOGFILE);
$last_curl_error = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* part of pfSense (https://www.pfsense.org)
* Copyright (c) 2019-2020 Rubicon Communications, LLC (Netgate)
* Copyright (c) 2013-2019 Bill Meeks
* Copyright (c) 2013-2020 Bill Meeks
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -199,6 +199,18 @@
$updated_cfg = true;
}

/**********************************************************/
/* Randomize the Rules Update Start Time minutes field */
/* per request of Snort.org team to minimize impact of */
/* large numbers of pfSense users hitting Snort.org at */
/* the same minute past the hour for rules updates. */
/**********************************************************/
if (empty($config['installedpackages']['snortglobal']['rule_update_starttime']) ||
$config['installedpackages']['snortglobal']['rule_update_starttime'] == '00:05') {
$config['installedpackages']['snortglobal']['rule_update_starttime'] = "00:" . strval(random_int(0, 59));
$updated_cfg = true;
}

/**********************************************************/
/* Migrate per interface settings if required. */
/**********************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright (c) 2011-2020 Rubicon Communications, LLC (Netgate)
* Copyright (c) 2003-2006 Manuel Kasper <[email protected]>.
* Copyright (c) 2008-2009 Robert Zelaya
* Copyright (c) 2019 Bill Meeks
* Copyright (c) 2020 Bill Meeks
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -54,7 +54,7 @@

/* Set sensible values for any empty default params */
if (!isset($pconfig['rule_update_starttime']))
$pconfig['rule_update_starttime'] = '00:05';
$pconfig['rule_update_starttime'] = '00:' . strval(random_int(0, 59));
if (!isset($config['installedpackages']['snortglobal']['forcekeepsettings']))
$pconfig['forcekeepsettings'] = 'on';
if (!isset($config['installedpackages']['snortglobal']['clearblocks']))
Expand Down Expand Up @@ -305,10 +305,11 @@
'Update Start Time',
'text',
$pconfig['rule_update_starttime']
))->setHelp('Enter the rule update start time in 24-hour format (HH:MM). Default is 00:05. ' .
))->setHelp('Enter the rule update start time in 24-hour format (HH:MM). Default is 00 hours with a randomly chosen minutes value. ' .
'Rules will update at the interval chosen above starting at the time specified here. ' .
'For example, using the default start time of 00:05 and choosing 12 Hours for the interval, ' .
'the rules will update at 00:05 and 12:05 each day.');
'For example, using a start time of 00:08 and choosing 12 Hours for the interval, ' .
'the rules will update at 00:08 and 12:08 each day. The randomized minutes value should ' .
'be retained to minimize the impact to the rules update site from large numbers of simultaneous requests.');
$section->addInput(new Form_Checkbox(
'hide_deprecated_rules',
'Hide Deprecated Rules Categories',
Expand Down