Skip to content

Commit 5403d6d

Browse files
committed
Fix some small typos and various minor bugs.
1 parent 89ddddb commit 5403d6d

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/Scanner.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: The scanner (last modified: 2020.07.11).
11+
* This file: The scanner (last modified: 2020.07.12).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -495,6 +495,7 @@ private function recursor($Files = '', int $Depth = -1)
495495
$this->Loader->InstanceCache['ThisScanDone']++;
496496
$this->Loader->Events->fireEvent('countersChanged');
497497
$this->Loader->atHit('', $fS, $OriginalFilenameClean, '', 1, $Depth + 1);
498+
return;
498499
}
499500

500501
/** Process filetype blacklisting and greylisting. */
@@ -1439,6 +1440,7 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
14391440
$SigFile
14401441
)
14411442
), -3, $Depth);
1443+
return;
14421444
}
14431445
} elseif ($ThisConf[1] === 0) {
14441446
if (substr($this->Loader->InstanceCache[$SigFile], 0, 9) === 'phpMussel') {
@@ -1823,6 +1825,7 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
18231825
$SigFile
18241826
)
18251827
), -3, $Depth);
1828+
return;
18261829
}
18271830
continue;
18281831
}
@@ -2079,7 +2082,11 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
20792082
}
20802083
$this->Loader->InstanceCache['urlscanner_domains'] .= $URLScanner['Domains'][$i] . $URLExpiry . ':;';
20812084
}
2082-
$this->Loader->Cache->setEntry('urlscanner_domains', $this->Loader->InstanceCache['urlscanner_domains'], $URLExpiry);
2085+
$this->Loader->Cache->setEntry(
2086+
'urlscanner_domains',
2087+
$this->Loader->InstanceCache['urlscanner_domains'],
2088+
$this->Loader->Configuration['urlscanner']['cache_time']
2089+
);
20832090
}
20842091

20852092
$URLScanner['URLsCount'] = count($URLScanner['URLParts']);
@@ -2308,12 +2315,12 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
23082315
'&resource=' . $md5,
23092316
$VTParams, 12);
23102317
$VTJSON = json_decode($VTRequest, true);
2311-
$y = $this->Loader->Time + ($this->Loader->Configuration['virustotal']['vt_quota_time'] * 60);
2312-
$this->Loader->InstanceCache['vt_quota'] .= $y . ';';
2318+
$VTCacheTime = $this->Loader->Configuration['virustotal']['vt_quota_time'] * 60;
2319+
$this->Loader->InstanceCache['vt_quota'] .= ($this->Loader->Time + $VTCacheTime) . ';';
23132320
while (substr_count($this->Loader->InstanceCache['vt_quota'], ';;')) {
23142321
$this->Loader->InstanceCache['vt_quota'] = str_ireplace(';;', ';', $this->Loader->InstanceCache['vt_quota']);
23152322
}
2316-
$this->Loader->Cache->setEntry('vt_quota', $this->Loader->InstanceCache['vt_quota'], $y + 60);
2323+
$this->Loader->Cache->setEntry('vt_quota', $this->Loader->InstanceCache['vt_quota'], $VTCacheTime + 60);
23172324
if (isset($VTJSON['response_code'])) {
23182325
$VTJSON['response_code'] = (int)$VTJSON['response_code'];
23192326
if (
@@ -2856,11 +2863,12 @@ private function prescanDecode(string $str): string
28562863

28572864
/**
28582865
* Uses iterators to generate an array of the contents of a specified directory.
2866+
* Used both by the scanner as well as by CLI.
28592867
*
28602868
* @param string $Base Directory root.
28612869
* @return array Directory tree.
28622870
*/
2863-
private function directoryRecursiveList(string $Base): array
2871+
public function directoryRecursiveList(string $Base): array
28642872
{
28652873
$Arr = [];
28662874
$Offset = strlen($Base);
@@ -3238,6 +3246,9 @@ private function getShorthand(string $VN): string
32383246
return $VN;
32393247
}
32403248

3249+
/** Will be populated by the signature name. */
3250+
$Out = '';
3251+
32413252
/** Byte 1 contains vendor name and signature metadata information. */
32423253
$Nibbles = $this->splitNibble($VN[1]);
32433254

@@ -3533,7 +3544,7 @@ private function safeBrowseLookup(array $URLs, array $URLsNoLookup = [], array $
35333544
$this->Loader->InstanceCache['LookupCount']++;
35343545

35353546
/** Generate new cache expiry time. */
3536-
$newExpiry = $this->Loader->Time + $this->Loader->Configuration['urlscanner']['cache_time'];
3547+
$newExpiry = $this->Loader->Configuration['urlscanner']['cache_time'];
35373548

35383549
/** Potentially harmful URL detected. */
35393550
if (strpos($Response, '"matches":') !== false) {
@@ -3596,7 +3607,7 @@ private function safeBrowseLookup(array $URLs, array $URLsNoLookup = [], array $
35963607

35973608
/** Update the cache entry for Google Safe Browsing. */
35983609
$this->Loader->InstanceCache['urlscanner_google'] .= $cacheRef . ':' . $newExpiry . ':' . $returnVal . ';';
3599-
$this->Loader->Cache->setEntry('urlscanner_google', $newExpiry, $this->Loader->InstanceCache['urlscanner_google']);
3610+
$this->Loader->Cache->setEntry('urlscanner_google', $this->Loader->InstanceCache['urlscanner_google'], $newExpiry);
36003611

36013612
return $returnVal;
36023613
}

0 commit comments

Comments
 (0)