Skip to content

Commit

Permalink
Bug-fixes.
Browse files Browse the repository at this point in the history
[2017.01.15; Bug-fixes; Maikuolan]: Bug found whereby false positives
against search engines could occasionally be generated as a result of
failed and incorrect DNS lookups (possible since the 2017.01.12 update);
Code therefore modified as such to prevent this from occurring; Timeout
limit increased and timed out lookups now result in no action being
taken. Bug found whereby logging banned IPs which had exceeded the
infraction limit could result in no log entry ID being parsed into log
entries; Fixed.
  • Loading branch information
Maikuolan committed Jan 15, 2017
1 parent 60fe39b commit 1b3745b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
8 changes: 8 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ Versioning guidelines for SemVer can be found at: http://www.semver.org/
timed DNS lookups, both forward and reverse, along with the ability to cache
the results of these lookups. Added a new directive: "default_dns".

- [2017.01.15; Bug-fixes; Maikuolan]: Bug found whereby false positives against
search engines could occasionally be generated as a result of failed and
incorrect DNS lookups (possible since the 2017.01.12 update); Code therefore
modified as such to prevent this from occurring; Timeout limit increased and
timed out lookups now result in no action being taken. Bug found whereby
logging banned IPs which had exceeded the infraction limit could result in no
log entry ID being parsed into log entries; Fixed.

=== Version/Release 0.6.1 ===
PATCH RELEASE.

Expand Down
6 changes: 3 additions & 3 deletions vault/components.dat
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CIDRAM:
vi: Các gói thầu chính (mà không có các tập tin chữ ký, tài liệu, và cấu hình).
zh: 主包(没有签名文件,文档,和配置)。
zh-tw: 主包(沒有簽名文件,文檔,和配置)。
Version: 0.7.0-DEV+170113
Version: 0.7.0-DEV+170115
Minimum Required: 0.6.0-DEV
Minimum Required PHP: 5.4.0
Changelog: https://raw.githubusercontent.com/Maikuolan/CIDRAM/master/Changelog.txt
Expand Down Expand Up @@ -119,11 +119,11 @@ CIDRAM:
- ca4d53f3b38dbecbf636b5c67594ac74:2102
- f02846bee1e737178f55f8e67d312d53:931
- 21ae679406c71bf78296fce4a8ce7509:100112
- df7d672465298c59c2fe5c75688c4fb5:79296
- dc6ae8f9488838615d98c0d6801b3f90:79874
- 90f4e2597e0dfa411b65c4a1e8849c13:17575
- 5b6bbb6c353196a5cf2fe336fde2dc5a:2750
- 8e03209e7fc6641b45094e584340feff:83
- dbb1a60c7239f849740c87be0233db6f:21342
- 40fb18147811b328dfce9a9b81843384:21408
- 10a8f11f9c09873ab71e50e128940503:1729
- 2f007322fe51be35be62b2931ac2ee93:11237
- c6dbda70eb05f08e2dd0ca41fe57661a:2810
Expand Down
23 changes: 17 additions & 6 deletions vault/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* License: GNU/GPLv2
* @see LICENSE.txt
*
* This file: Functions file (last modified: 2017.01.13).
* This file: Functions file (last modified: 2017.01.15).
*/

/**
Expand Down Expand Up @@ -972,10 +972,10 @@
*
* @param string $Addr The IPv4 IP address to look up.
* @param string $DNS The DNS server to use (optional; defaults to 8.8.8.8).
* @param string $Timeout The timeout limit (optional; defaults to 3 seconds).
* @param string $Timeout The timeout limit (optional; defaults to 5 seconds).
* @return string The hostname on success, or the IP address on failure.
*/
$CIDRAM['DNS-Reverse-IPv4'] = function ($Addr, $DNS = '', $Timeout = 3) use (&$CIDRAM) {
$CIDRAM['DNS-Reverse-IPv4'] = function ($Addr, $DNS = '', $Timeout = 5) use (&$CIDRAM) {
if (isset($CIDRAM['Cache']['DNS-Reverses'][$Addr]['Host'])) {
return $CIDRAM['Cache']['DNS-Reverses'][$Addr]['Host'];
}
Expand Down Expand Up @@ -1035,10 +1035,10 @@
* problems normally associated with using "gethostbyname").
*
* @param string $Host The hostname to look up.
* @param string $Timeout The timeout limit (optional; defaults to 3 seconds).
* @param string $Timeout The timeout limit (optional; defaults to 5 seconds).
* @return string The IP address on success, or an empty string on failure.
*/
$CIDRAM['DNS-Resolve'] = function ($Host, $Timeout = 3) use (&$CIDRAM) {
$CIDRAM['DNS-Resolve'] = function ($Host, $Timeout = 5) use (&$CIDRAM) {
if (isset($CIDRAM['Cache']['DNS-Forwards'][$Host]['IPAddr'])) {
return $CIDRAM['Cache']['DNS-Forwards'][$Host]['IPAddr'];
}
Expand Down Expand Up @@ -1072,17 +1072,27 @@
/**
* Distinguishes between bots masquerading as popular search engines and real,
* legitimate search engines. Tracking is disabled for real, legitimate search
* engines, and those masquerading as them are blocked. Has no return value.
* engines, and those masquerading as them are blocked. If DNS is unresolvable
* and/or if it can't be determined whether a request has originated from a
* fake or a legitimate source, it takes no action (ie, doesn't mess with
* tracking and doesn't block anything).
*
* @param string|array $Domains Accepted domain/hostname partials.
* @param string $Friendly A friendly name to use in logfiles.
* @return bool Returns true when a determination is successfully made, and
* false when a determination isn't able to be made.
*/
$CIDRAM['DNS-Reverse-Forward'] = function ($Domains, $Friendly) use (&$CIDRAM) {
if (empty($CIDRAM['Hostname'])) {
/** Fetch the hostname. */
$CIDRAM['Hostname'] = $CIDRAM['DNS-Reverse-IPv4']($CIDRAM['BlockInfo']['IPAddr']);
}
/** Force domains to be an array. */
$CIDRAM['Arrayify']($Domains);
/** Do nothing more if we weren't able to resolve the DNS hostname. */
if (!$CIDRAM['Hostname'] || $CIDRAM['Hostname'] === $CIDRAM['BlockInfo']['IPAddr']) {
return false;
}
$Pass = false;
/** Compare the hostname against the accepted domain/hostname partials. */
while (($Domain = each($Domains)) !== false) {
Expand Down Expand Up @@ -1111,6 +1121,7 @@
$CIDRAM['BlockInfo']['Signatures'] .= basename($Debug['file']) . ':L' . $Debug['line'];
$CIDRAM['BlockInfo']['SignatureCount']++;
}
return true;
};

/**
Expand Down
6 changes: 4 additions & 2 deletions vault/outgen.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* License: GNU/GPLv2
* @see LICENSE.txt
*
* This file: Output generator (last modified: 2017.01.13).
* This file: Output generator (last modified: 2017.01.15).
*/

$CIDRAM['CacheModified'] = false;
Expand Down Expand Up @@ -250,7 +250,9 @@
$CIDRAM['Config']['template_data']['recaptcha_div_include'] = '';
}

if (empty($CIDRAM['reCAPTCHA']['Bypass']) && empty($CIDRAM['Banned'])) {
if (empty($CIDRAM['reCAPTCHA']['Bypass']) && (
$CIDRAM['Config']['general']['log_banned_ips'] || empty($CIDRAM['Banned'])
)) {

/** If logging is enabled, increment the counter. */
if (
Expand Down

0 comments on commit 1b3745b

Please sign in to comment.