|
8 | 8 | * License: GNU/GPLv2
|
9 | 9 | * @see LICENSE.txt
|
10 | 10 | *
|
11 |
| - * This file: The scanner (last modified: 2020.07.11). |
| 11 | + * This file: The scanner (last modified: 2020.07.12). |
12 | 12 | */
|
13 | 13 |
|
14 | 14 | namespace phpMussel\Core;
|
@@ -495,6 +495,7 @@ private function recursor($Files = '', int $Depth = -1)
|
495 | 495 | $this->Loader->InstanceCache['ThisScanDone']++;
|
496 | 496 | $this->Loader->Events->fireEvent('countersChanged');
|
497 | 497 | $this->Loader->atHit('', $fS, $OriginalFilenameClean, '', 1, $Depth + 1);
|
| 498 | + return; |
498 | 499 | }
|
499 | 500 |
|
500 | 501 | /** Process filetype blacklisting and greylisting. */
|
@@ -1439,6 +1440,7 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
|
1439 | 1440 | $SigFile
|
1440 | 1441 | )
|
1441 | 1442 | ), -3, $Depth);
|
| 1443 | + return; |
1442 | 1444 | }
|
1443 | 1445 | } elseif ($ThisConf[1] === 0) {
|
1444 | 1446 | if (substr($this->Loader->InstanceCache[$SigFile], 0, 9) === 'phpMussel') {
|
@@ -1823,6 +1825,7 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
|
1823 | 1825 | $SigFile
|
1824 | 1826 | )
|
1825 | 1827 | ), -3, $Depth);
|
| 1828 | + return; |
1826 | 1829 | }
|
1827 | 1830 | continue;
|
1828 | 1831 | }
|
@@ -2079,7 +2082,11 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
|
2079 | 2082 | }
|
2080 | 2083 | $this->Loader->InstanceCache['urlscanner_domains'] .= $URLScanner['Domains'][$i] . $URLExpiry . ':;';
|
2081 | 2084 | }
|
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 | + ); |
2083 | 2090 | }
|
2084 | 2091 |
|
2085 | 2092 | $URLScanner['URLsCount'] = count($URLScanner['URLParts']);
|
@@ -2308,12 +2315,12 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
|
2308 | 2315 | '&resource=' . $md5,
|
2309 | 2316 | $VTParams, 12);
|
2310 | 2317 | $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) . ';'; |
2313 | 2320 | while (substr_count($this->Loader->InstanceCache['vt_quota'], ';;')) {
|
2314 | 2321 | $this->Loader->InstanceCache['vt_quota'] = str_ireplace(';;', ';', $this->Loader->InstanceCache['vt_quota']);
|
2315 | 2322 | }
|
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); |
2317 | 2324 | if (isset($VTJSON['response_code'])) {
|
2318 | 2325 | $VTJSON['response_code'] = (int)$VTJSON['response_code'];
|
2319 | 2326 | if (
|
@@ -2856,11 +2863,12 @@ private function prescanDecode(string $str): string
|
2856 | 2863 |
|
2857 | 2864 | /**
|
2858 | 2865 | * Uses iterators to generate an array of the contents of a specified directory.
|
| 2866 | + * Used both by the scanner as well as by CLI. |
2859 | 2867 | *
|
2860 | 2868 | * @param string $Base Directory root.
|
2861 | 2869 | * @return array Directory tree.
|
2862 | 2870 | */
|
2863 |
| - private function directoryRecursiveList(string $Base): array |
| 2871 | + public function directoryRecursiveList(string $Base): array |
2864 | 2872 | {
|
2865 | 2873 | $Arr = [];
|
2866 | 2874 | $Offset = strlen($Base);
|
@@ -3238,6 +3246,9 @@ private function getShorthand(string $VN): string
|
3238 | 3246 | return $VN;
|
3239 | 3247 | }
|
3240 | 3248 |
|
| 3249 | + /** Will be populated by the signature name. */ |
| 3250 | + $Out = ''; |
| 3251 | + |
3241 | 3252 | /** Byte 1 contains vendor name and signature metadata information. */
|
3242 | 3253 | $Nibbles = $this->splitNibble($VN[1]);
|
3243 | 3254 |
|
@@ -3533,7 +3544,7 @@ private function safeBrowseLookup(array $URLs, array $URLsNoLookup = [], array $
|
3533 | 3544 | $this->Loader->InstanceCache['LookupCount']++;
|
3534 | 3545 |
|
3535 | 3546 | /** Generate new cache expiry time. */
|
3536 |
| - $newExpiry = $this->Loader->Time + $this->Loader->Configuration['urlscanner']['cache_time']; |
| 3547 | + $newExpiry = $this->Loader->Configuration['urlscanner']['cache_time']; |
3537 | 3548 |
|
3538 | 3549 | /** Potentially harmful URL detected. */
|
3539 | 3550 | if (strpos($Response, '"matches":') !== false) {
|
@@ -3596,7 +3607,7 @@ private function safeBrowseLookup(array $URLs, array $URLsNoLookup = [], array $
|
3596 | 3607 |
|
3597 | 3608 | /** Update the cache entry for Google Safe Browsing. */
|
3598 | 3609 | $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); |
3600 | 3611 |
|
3601 | 3612 | return $returnVal;
|
3602 | 3613 | }
|
|
0 commit comments