Version Description
Download this release
Release Info
Developer | paultgoodchild |
Plugin | Shield Security for WordPress |
Version | 11.5.4 |
Comparing to | |
See all releases |
Code changes from version 11.5.3 to 11.5.4
- cl.json +6 -0
- icwp-wpsf.php +1 -1
- plugin-spec.php +3 -3
- plugin.json +3 -3
- readme.txt +1 -1
- src/lib/src/Modules/HackGuard/Lib/ScanTables/LoadRawTableData.php +42 -46
- src/lib/src/Modules/HackGuard/Scan/Queue/CollateResults.php +8 -12
- src/lib/src/Modules/HackGuard/Scan/Queue/CompleteQueue.php +6 -5
- src/lib/src/Modules/HackGuard/Scan/Queue/QueueProcessor.php +1 -1
- src/lib/src/Scans/Base/BaseScan.php +0 -3
- src/lib/src/Scans/Base/Files/BaseFileMapScan.php +10 -16
- src/lib/src/Scans/Base/Files/BaseScanFromFileMap.php +1 -1
- src/lib/src/Scans/Mal/FileScanner.php +7 -7
- src/lib/src/Scans/Mal/Utilities/FalsePositiveQuery.php +16 -17
cl.json
CHANGED
@@ -117,6 +117,12 @@
|
|
117 |
"title": "Plugin/Theme scanning could result in large quantities of unrecognised files.",
|
118 |
"description": [],
|
119 |
"patch": "11.5.3"
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
}
|
121 |
]
|
122 |
},
|
117 |
"title": "Plugin/Theme scanning could result in large quantities of unrecognised files.",
|
118 |
"description": [],
|
119 |
"patch": "11.5.3"
|
120 |
+
},
|
121 |
+
{
|
122 |
+
"type": "improved",
|
123 |
+
"title": "Scan results were being reported, but not displayed in results tables in some cases.",
|
124 |
+
"description": [],
|
125 |
+
"patch": "11.5.4"
|
126 |
}
|
127 |
]
|
128 |
},
|
icwp-wpsf.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Shield Security
|
4 |
* Plugin URI: https://shsec.io/2f
|
5 |
* Description: Powerful, Easy-To-Use #1 Rated WordPress Security System
|
6 |
-
* Version: 11.5.
|
7 |
* Text Domain: wp-simple-firewall
|
8 |
* Domain Path: /languages
|
9 |
* Author: Shield Security
|
3 |
* Plugin Name: Shield Security
|
4 |
* Plugin URI: https://shsec.io/2f
|
5 |
* Description: Powerful, Easy-To-Use #1 Rated WordPress Security System
|
6 |
+
* Version: 11.5.4
|
7 |
* Text Domain: wp-simple-firewall
|
8 |
* Domain Path: /languages
|
9 |
* Author: Shield Security
|
plugin-spec.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{
|
2 |
"properties": {
|
3 |
-
"version": "11.5.
|
4 |
-
"release_timestamp":
|
5 |
-
"build": "202108.
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
1 |
{
|
2 |
"properties": {
|
3 |
+
"version": "11.5.4",
|
4 |
+
"release_timestamp": 1628069509,
|
5 |
+
"build": "202108.0401",
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
plugin.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{
|
2 |
"properties": {
|
3 |
-
"version": "11.5.
|
4 |
-
"release_timestamp":
|
5 |
-
"build": "202108.
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
1 |
{
|
2 |
"properties": {
|
3 |
+
"version": "11.5.4",
|
4 |
+
"release_timestamp": 1628069509,
|
5 |
+
"build": "202108.0401",
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
readme.txt
CHANGED
@@ -8,7 +8,7 @@ Requires at least: 3.7
|
|
8 |
Requires PHP: 7.0
|
9 |
Recommended PHP: 7.4
|
10 |
Tested up to: 5.8
|
11 |
-
Stable tag: 11.5.
|
12 |
|
13 |
No-Nonsense Security Hardening that protects WordPress against hackers, malicious bots, and spammers (no captchas!). Now with exclusive ShieldNET Technology.
|
14 |
|
8 |
Requires PHP: 7.0
|
9 |
Recommended PHP: 7.4
|
10 |
Tested up to: 5.8
|
11 |
+
Stable tag: 11.5.4
|
12 |
|
13 |
No-Nonsense Security Hardening that protects WordPress against hackers, malicious bots, and spammers (no captchas!). Now with exclusive ShieldNET Technology.
|
14 |
|
src/lib/src/Modules/HackGuard/Lib/ScanTables/LoadRawTableData.php
CHANGED
@@ -68,47 +68,38 @@ class LoadRawTableData {
|
|
68 |
public function loadForMalware() :array {
|
69 |
/** @var ModCon $mod */
|
70 |
$mod = $this->getMod();
|
71 |
-
|
72 |
-
$
|
73 |
-
|
74 |
-
|
75 |
-
$data = $item->getRawData();
|
76 |
-
|
77 |
-
$data[ 'rid' ] = $item->VO->id;
|
78 |
-
$data[ 'file' ] = $item->path_fragment;
|
79 |
-
$data[ 'detected_at' ] = $item->VO->created_at;
|
80 |
-
$data[ 'detected_since' ] = Services::Request()
|
81 |
-
->carbon( true )
|
82 |
-
->setTimestamp( $item->VO->created_at )
|
83 |
-
->diffForHumans();
|
84 |
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
-
|
88 |
-
$data[ 'status' ] = $this->getColumnContent_FileStatus( $item, __( 'Malware', 'wp-simple-firewall' ) );
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
return $line + 1;
|
93 |
-
},
|
94 |
-
$item->file_lines // because lines start at ZERO
|
95 |
-
) );
|
96 |
-
$data[ 'mal_sig' ] = sprintf( '<code style="white-space: nowrap">%s</code>', esc_html( base64_decode( $item->mal_sig ) ) );
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
)
|
105 |
-
|
106 |
-
|
107 |
-
catch ( \Exception $e ) {
|
108 |
-
$files = [];
|
109 |
-
}
|
110 |
|
111 |
-
|
|
|
|
|
|
|
112 |
}
|
113 |
|
114 |
public function loadForPlugin( WpPluginVo $plugin ) :array {
|
@@ -223,14 +214,15 @@ class LoadRawTableData {
|
|
223 |
* @param string $status
|
224 |
* @param Scans\Base\ResultItem $item
|
225 |
* @return array
|
|
|
226 |
*/
|
227 |
private function getActions( string $status, $item ) :array {
|
228 |
$con = $this->getCon();
|
229 |
/** @var ModCon $mod */
|
230 |
$mod = $this->getMod();
|
231 |
-
$
|
232 |
-
|
233 |
-
|
234 |
|
235 |
$actions = [];
|
236 |
|
@@ -248,14 +240,18 @@ class LoadRawTableData {
|
|
248 |
);
|
249 |
}
|
250 |
|
251 |
-
|
|
|
252 |
->canRepair() ) {
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
|
|
259 |
}
|
260 |
|
261 |
if ( in_array( $status, [ 'modified', 'unrecognised', 'malware' ] ) ) {
|
68 |
public function loadForMalware() :array {
|
69 |
/** @var ModCon $mod */
|
70 |
$mod = $this->getMod();
|
71 |
+
return array_map(
|
72 |
+
function ( $item ) {
|
73 |
+
/** @var Scans\Mal\ResultItem $item */
|
74 |
+
$data = $item->getRawData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
+
$data[ 'rid' ] = $item->VO->id;
|
77 |
+
$data[ 'file' ] = $item->path_fragment;
|
78 |
+
$data[ 'detected_at' ] = $item->VO->created_at;
|
79 |
+
$data[ 'detected_since' ] = Services::Request()
|
80 |
+
->carbon( true )
|
81 |
+
->setTimestamp( $item->VO->created_at )
|
82 |
+
->diffForHumans();
|
83 |
|
84 |
+
$data[ 'file_as_href' ] = $this->getColumnContent_File( $item );
|
|
|
85 |
|
86 |
+
$data[ 'status_slug' ] = 'malware';
|
87 |
+
$data[ 'status' ] = $this->getColumnContent_FileStatus( $item, __( 'Malware', 'wp-simple-firewall' ) );
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
+
$data[ 'line_numbers' ] = implode( ', ', array_map(
|
90 |
+
function ( $line ) {
|
91 |
+
return $line + 1;
|
92 |
+
},
|
93 |
+
$item->file_lines // because lines start at ZERO
|
94 |
+
) );
|
95 |
+
$data[ 'mal_sig' ] = sprintf( '<code style="white-space: nowrap">%s</code>', esc_html( base64_decode( $item->mal_sig ) ) );
|
96 |
+
$data[ 'file_type' ] = strtoupper( Services::Data()->getExtension( $item->path_full ) );
|
97 |
+
$data[ 'actions' ] = implode( ' ', $this->getActions( $data[ 'status_slug' ], $item ) );
|
|
|
|
|
|
|
98 |
|
99 |
+
return $data;
|
100 |
+
},
|
101 |
+
$mod->getScanCon( Mal::SCAN_SLUG )->getAllResults()->getItems()
|
102 |
+
);
|
103 |
}
|
104 |
|
105 |
public function loadForPlugin( WpPluginVo $plugin ) :array {
|
214 |
* @param string $status
|
215 |
* @param Scans\Base\ResultItem $item
|
216 |
* @return array
|
217 |
+
* @throws \Exception
|
218 |
*/
|
219 |
private function getActions( string $status, $item ) :array {
|
220 |
$con = $this->getCon();
|
221 |
/** @var ModCon $mod */
|
222 |
$mod = $this->getMod();
|
223 |
+
$actionHandler = $mod->getScanCon( $item->VO->scan )
|
224 |
+
->getItemActionHandler()
|
225 |
+
->setScanItem( $item );
|
226 |
|
227 |
$actions = [];
|
228 |
|
240 |
);
|
241 |
}
|
242 |
|
243 |
+
try {
|
244 |
+
if ( in_array( $status, [ 'modified', 'missing', 'malware' ] ) && $actionHandler->getRepairer()
|
245 |
->canRepair() ) {
|
246 |
+
$actions[] = sprintf( '<button class="btn-warning repair %s" title="%s" data-rid="%s">%s</button>',
|
247 |
+
implode( ' ', $defaultButtonClasses ),
|
248 |
+
__( 'Repair', 'wp-simple-firewall' ),
|
249 |
+
$item->VO->id,
|
250 |
+
$con->svgs->raw( 'bootstrap/tools.svg' )
|
251 |
+
);
|
252 |
+
}
|
253 |
+
}
|
254 |
+
catch ( \Exception $e ) {
|
255 |
}
|
256 |
|
257 |
if ( in_array( $status, [ 'modified', 'unrecognised', 'malware' ] ) ) {
|
src/lib/src/Modules/HackGuard/Scan/Queue/CollateResults.php
CHANGED
@@ -16,32 +16,28 @@ class CollateResults {
|
|
16 |
use ScanControllerConsumer;
|
17 |
|
18 |
/**
|
19 |
-
* @param string $
|
20 |
-
* @return Scans\Base\ResultsSet|mixed
|
21 |
*/
|
22 |
-
public function collate( $
|
23 |
/** @var Databases\ScanQueue\Handler $dbh */
|
24 |
$dbh = $this->getDbHandler();
|
25 |
/** @var Databases\ScanQueue\Select $selector */
|
26 |
$selector = $dbh->getQuerySelector();
|
27 |
-
$selector->filterByScan( $
|
28 |
->setResultsAsVo( true );
|
29 |
-
$scanCon = $this->getScanController();
|
30 |
|
31 |
-
$resultsSet =
|
|
|
32 |
/** @var Databases\ScanQueue\EntryVO $entry */
|
33 |
foreach ( $selector->query() as $entry ) {
|
34 |
$action = ( new ConvertBetweenTypes() )
|
35 |
->setDbHandler( $dbh )
|
36 |
->fromDbEntryToAction( $entry );
|
37 |
|
38 |
-
|
39 |
-
$resultsSet = $scanCon->getNewResultsSet();
|
40 |
-
}
|
41 |
-
|
42 |
-
foreach ( $action->results as $aResItemData ) {
|
43 |
$resultsSet->addItem(
|
44 |
-
$action->getNewResultItem()->applyFromArray( $
|
45 |
);
|
46 |
}
|
47 |
}
|
16 |
use ScanControllerConsumer;
|
17 |
|
18 |
/**
|
19 |
+
* @param string $scanSlug
|
20 |
+
* @return Scans\Base\ResultsSet|mixed
|
21 |
*/
|
22 |
+
public function collate( $scanSlug ) {
|
23 |
/** @var Databases\ScanQueue\Handler $dbh */
|
24 |
$dbh = $this->getDbHandler();
|
25 |
/** @var Databases\ScanQueue\Select $selector */
|
26 |
$selector = $dbh->getQuerySelector();
|
27 |
+
$selector->filterByScan( $scanSlug )
|
28 |
->setResultsAsVo( true );
|
|
|
29 |
|
30 |
+
$resultsSet = $this->getScanController()->getNewResultsSet();
|
31 |
+
|
32 |
/** @var Databases\ScanQueue\EntryVO $entry */
|
33 |
foreach ( $selector->query() as $entry ) {
|
34 |
$action = ( new ConvertBetweenTypes() )
|
35 |
->setDbHandler( $dbh )
|
36 |
->fromDbEntryToAction( $entry );
|
37 |
|
38 |
+
foreach ( $action->results as $resultItemRawData ) {
|
|
|
|
|
|
|
|
|
39 |
$resultsSet->addItem(
|
40 |
+
$action->getNewResultItem()->applyFromArray( $resultItemRawData )
|
41 |
);
|
42 |
}
|
43 |
}
|
src/lib/src/Modules/HackGuard/Scan/Queue/CompleteQueue.php
CHANGED
@@ -40,7 +40,8 @@ class CompleteQueue {
|
|
40 |
|
41 |
$con->fireEvent( $scanSlug.'_scan_run' );
|
42 |
|
43 |
-
if ( $resultsSet
|
|
|
44 |
( new HackGuard\Scan\Results\ResultsUpdate() )
|
45 |
->setScanController( $scanCon )
|
46 |
->update( $resultsSet );
|
@@ -52,10 +53,10 @@ class CompleteQueue {
|
|
52 |
: __( 'The following items were discovered.', 'wp-simple-firewall' );
|
53 |
|
54 |
$items .= ' "'.
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
|
60 |
$con->fireEvent(
|
61 |
$scanSlug.'_scan_found',
|
40 |
|
41 |
$con->fireEvent( $scanSlug.'_scan_run' );
|
42 |
|
43 |
+
if ( $resultsSet->hasItems() ) {
|
44 |
+
|
45 |
( new HackGuard\Scan\Results\ResultsUpdate() )
|
46 |
->setScanController( $scanCon )
|
47 |
->update( $resultsSet );
|
53 |
: __( 'The following items were discovered.', 'wp-simple-firewall' );
|
54 |
|
55 |
$items .= ' "'.
|
56 |
+
implode( '", "', array_map( function ( $item ) {
|
57 |
+
return $item->getDescriptionForAudit();
|
58 |
+
}, array_slice( $resultsSet->getItems(), 0, 30 ) ) )
|
59 |
+
.'"';
|
60 |
|
61 |
$con->fireEvent(
|
62 |
$scanSlug.'_scan_found',
|
src/lib/src/Modules/HackGuard/Scan/Queue/QueueProcessor.php
CHANGED
@@ -113,7 +113,7 @@ class QueueProcessor extends Utilities\BackgroundProcessing\BackgroundProcess {
|
|
113 |
if ( is_array( $this->data ) ) {
|
114 |
/** @var ScanQueue\Insert $inserter */
|
115 |
$inserter = $this->getDbHandler()->getQueryInserter();
|
116 |
-
foreach ( $this->data as $
|
117 |
/** @var ScanQueue\EntryVO $entry */
|
118 |
if ( $entry instanceof ScanQueue\EntryVO ) {
|
119 |
$inserter->insert( $entry );
|
113 |
if ( is_array( $this->data ) ) {
|
114 |
/** @var ScanQueue\Insert $inserter */
|
115 |
$inserter = $this->getDbHandler()->getQueryInserter();
|
116 |
+
foreach ( $this->data as $entry ) {
|
117 |
/** @var ScanQueue\EntryVO $entry */
|
118 |
if ( $entry instanceof ScanQueue\EntryVO ) {
|
119 |
$inserter->insert( $entry );
|
src/lib/src/Scans/Base/BaseScan.php
CHANGED
@@ -50,9 +50,6 @@ abstract class BaseScan {
|
|
50 |
return $action;
|
51 |
}
|
52 |
|
53 |
-
/**
|
54 |
-
* @return void
|
55 |
-
*/
|
56 |
abstract protected function scanSlice();
|
57 |
|
58 |
protected function postScan() {
|
50 |
return $action;
|
51 |
}
|
52 |
|
|
|
|
|
|
|
53 |
abstract protected function scanSlice();
|
54 |
|
55 |
protected function postScan() {
|
src/lib/src/Scans/Base/Files/BaseFileMapScan.php
CHANGED
@@ -4,30 +4,24 @@ namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Base\Files;
|
|
4 |
|
5 |
use FernleafSystems\Wordpress\Plugin\Shield\Scans\Base;
|
6 |
|
7 |
-
/**
|
8 |
-
* Class BaseFileAsyncScanner
|
9 |
-
* @package FernleafSystems\Wordpress\Plugin\Shield\Scans\Base\Files
|
10 |
-
*/
|
11 |
abstract class BaseFileMapScan extends Base\BaseScan {
|
12 |
|
13 |
/**
|
14 |
* @return $this
|
15 |
*/
|
16 |
protected function scanSlice() {
|
17 |
-
/** @var Base\BaseScanActionVO $action */
|
18 |
$action = $this->getScanActionVO();
|
19 |
|
20 |
-
$
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
$action->results = $newItems;
|
31 |
|
32 |
return $this;
|
33 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Plugin\Shield\Scans\Base;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
abstract class BaseFileMapScan extends Base\BaseScan {
|
8 |
|
9 |
/**
|
10 |
* @return $this
|
11 |
*/
|
12 |
protected function scanSlice() {
|
|
|
13 |
$action = $this->getScanActionVO();
|
14 |
|
15 |
+
$action->results = array_map(
|
16 |
+
function ( $item ) {
|
17 |
+
return $item->getRawData();
|
18 |
+
},
|
19 |
+
// run the scan and get results:
|
20 |
+
$this->getScanFromFileMap()
|
21 |
+
->setScanActionVO( $action )
|
22 |
+
->run()
|
23 |
+
->getAllItems()
|
24 |
+
);
|
|
|
25 |
|
26 |
return $this;
|
27 |
}
|
src/lib/src/Scans/Base/Files/BaseScanFromFileMap.php
CHANGED
@@ -38,7 +38,7 @@ abstract class BaseScanFromFileMap {
|
|
38 |
if ( !$hashVerifier->verify( $fullPath ) ) {
|
39 |
$item = $this->getFileScanner()->scan( $fullPath );
|
40 |
// We can exclude files that are empty of relevant code
|
41 |
-
if ( $item
|
42 |
$results->addItem( $item );
|
43 |
}
|
44 |
}
|
38 |
if ( !$hashVerifier->verify( $fullPath ) ) {
|
39 |
$item = $this->getFileScanner()->scan( $fullPath );
|
40 |
// We can exclude files that are empty of relevant code
|
41 |
+
if ( !empty( $item ) ) {
|
42 |
$results->addItem( $item );
|
43 |
}
|
44 |
}
|
src/lib/src/Scans/Mal/FileScanner.php
CHANGED
@@ -38,19 +38,19 @@ class FileScanner extends Shield\Scans\Base\Files\BaseFileScanner {
|
|
38 |
$this->locator->setIsRegEx( false );
|
39 |
foreach ( $action->patterns_simple as $signature ) {
|
40 |
$item = $this->scanForSig( $signature );
|
41 |
-
if ( $item
|
42 |
break;
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
|
47 |
-
if (
|
48 |
// RegEx Patterns
|
49 |
$this->locator->setIsRegEx( true );
|
50 |
if ( empty( $action->patterns_fullregex ) ) {
|
51 |
foreach ( $action->patterns_regex as $signature ) {
|
52 |
$item = $this->scanForSig( $signature );
|
53 |
-
if ( $item
|
54 |
break;
|
55 |
}
|
56 |
}
|
@@ -58,7 +58,7 @@ class FileScanner extends Shield\Scans\Base\Files\BaseFileScanner {
|
|
58 |
else { // Full regex patterns
|
59 |
foreach ( $action->patterns_fullregex as $signature ) {
|
60 |
$item = $this->scanForSig( $signature );
|
61 |
-
if ( $item
|
62 |
break;
|
63 |
}
|
64 |
}
|
@@ -86,7 +86,7 @@ class FileScanner extends Shield\Scans\Base\Files\BaseFileScanner {
|
|
86 |
if ( $this->canExcludeFile( $fullPath ) ) { // we report false positives: file and lines
|
87 |
$reporter = ( new Shield\Scans\Mal\Utilities\FalsePositiveReporter() )
|
88 |
->setMod( $this->getMod() );
|
89 |
-
foreach ( $lines as $
|
90 |
$reporter->reportLine( $fullPath, $line, true );
|
91 |
}
|
92 |
$reporter->reportPath( $fullPath, true );
|
@@ -103,11 +103,11 @@ class FileScanner extends Shield\Scans\Base\Files\BaseFileScanner {
|
|
103 |
->queryPath( $fullPath );
|
104 |
if ( $nFalsePositiveConfidence < $action->confidence_threshold ) {
|
105 |
// 2. Check each line and filter out fp confident lines
|
106 |
-
$
|
107 |
->setMod( $this->getMod() )
|
108 |
->queryFileLines( $fullPath, array_keys( $lines ) );
|
109 |
$lines = array_filter(
|
110 |
-
$
|
111 |
function ( $score ) use ( $action ) {
|
112 |
return $score < $action->confidence_threshold;
|
113 |
}
|
38 |
$this->locator->setIsRegEx( false );
|
39 |
foreach ( $action->patterns_simple as $signature ) {
|
40 |
$item = $this->scanForSig( $signature );
|
41 |
+
if ( !empty( $item ) ) {
|
42 |
break;
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
|
47 |
+
if ( empty( $item ) ) {
|
48 |
// RegEx Patterns
|
49 |
$this->locator->setIsRegEx( true );
|
50 |
if ( empty( $action->patterns_fullregex ) ) {
|
51 |
foreach ( $action->patterns_regex as $signature ) {
|
52 |
$item = $this->scanForSig( $signature );
|
53 |
+
if ( !empty( $item ) ) {
|
54 |
break;
|
55 |
}
|
56 |
}
|
58 |
else { // Full regex patterns
|
59 |
foreach ( $action->patterns_fullregex as $signature ) {
|
60 |
$item = $this->scanForSig( $signature );
|
61 |
+
if ( !empty( $item ) ) {
|
62 |
break;
|
63 |
}
|
64 |
}
|
86 |
if ( $this->canExcludeFile( $fullPath ) ) { // we report false positives: file and lines
|
87 |
$reporter = ( new Shield\Scans\Mal\Utilities\FalsePositiveReporter() )
|
88 |
->setMod( $this->getMod() );
|
89 |
+
foreach ( $lines as $line ) {
|
90 |
$reporter->reportLine( $fullPath, $line, true );
|
91 |
}
|
92 |
$reporter->reportPath( $fullPath, true );
|
103 |
->queryPath( $fullPath );
|
104 |
if ( $nFalsePositiveConfidence < $action->confidence_threshold ) {
|
105 |
// 2. Check each line and filter out fp confident lines
|
106 |
+
$lineScores = ( new Shield\Scans\Mal\Utilities\FalsePositiveQuery() )
|
107 |
->setMod( $this->getMod() )
|
108 |
->queryFileLines( $fullPath, array_keys( $lines ) );
|
109 |
$lines = array_filter(
|
110 |
+
$lineScores,
|
111 |
function ( $score ) use ( $action ) {
|
112 |
return $score < $action->confidence_threshold;
|
113 |
}
|
src/lib/src/Scans/Mal/Utilities/FalsePositiveQuery.php
CHANGED
@@ -16,18 +16,17 @@ class FalsePositiveQuery {
|
|
16 |
|
17 |
/**
|
18 |
* @param string $fullPath
|
19 |
-
* @param int[] $
|
20 |
* @return int[] - key is the file line number, value is the false positive confidence score
|
21 |
*/
|
22 |
-
public function queryFileLines( $fullPath, $
|
23 |
$scores = [];
|
24 |
/** @var Modules\HackGuard\Options $opts */
|
25 |
$opts = $this->getOptions();
|
26 |
if ( $opts->isMalUseNetworkIntelligence() ) {
|
27 |
try {
|
28 |
-
|
29 |
-
|
30 |
-
$scores[ $nLineNum ] = $this->queryLine( $fullPath, $sLine );
|
31 |
}
|
32 |
}
|
33 |
catch ( \Exception $e ) {
|
@@ -59,25 +58,25 @@ class FalsePositiveQuery {
|
|
59 |
* @param string $line
|
60 |
* @return int
|
61 |
*/
|
62 |
-
public function queryLine( $file, $line ) {
|
63 |
-
$
|
64 |
|
65 |
-
/** @var Modules\HackGuard\Options $
|
66 |
-
$
|
67 |
-
if ( $
|
68 |
$token = $this->getCon()
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
try {
|
73 |
-
$
|
74 |
-
if ( isset( $
|
75 |
-
$
|
76 |
}
|
77 |
}
|
78 |
catch ( \Exception $e ) {
|
79 |
}
|
80 |
}
|
81 |
-
return $
|
82 |
}
|
83 |
}
|
16 |
|
17 |
/**
|
18 |
* @param string $fullPath
|
19 |
+
* @param int[] $lines
|
20 |
* @return int[] - key is the file line number, value is the false positive confidence score
|
21 |
*/
|
22 |
+
public function queryFileLines( $fullPath, $lines ) {
|
23 |
$scores = [];
|
24 |
/** @var Modules\HackGuard\Options $opts */
|
25 |
$opts = $this->getOptions();
|
26 |
if ( $opts->isMalUseNetworkIntelligence() ) {
|
27 |
try {
|
28 |
+
foreach ( ( new ExtractLinesFromFile() )->run( $fullPath, $lines ) as $lineNumber => $line ) {
|
29 |
+
$scores[ $lineNumber ] = $this->queryLine( $fullPath, $line );
|
|
|
30 |
}
|
31 |
}
|
32 |
catch ( \Exception $e ) {
|
58 |
* @param string $line
|
59 |
* @return int
|
60 |
*/
|
61 |
+
public function queryLine( $file, $line ) :int {
|
62 |
+
$falsePositiveConfidence = 0;
|
63 |
|
64 |
+
/** @var Modules\HackGuard\Options $opts */
|
65 |
+
$opts = $this->getOptions();
|
66 |
+
if ( $opts->isMalUseNetworkIntelligence() ) {
|
67 |
$token = $this->getCon()
|
68 |
+
->getModule_License()
|
69 |
+
->getWpHashesTokenManager()
|
70 |
+
->getToken();
|
71 |
try {
|
72 |
+
$response = ( new Malware\Confidence\Retrieve( $token ) )->retrieveForFileLine( $file, $line );
|
73 |
+
if ( isset( $response[ 'score' ] ) ) {
|
74 |
+
$falsePositiveConfidence = (int)$response[ 'score' ];
|
75 |
}
|
76 |
}
|
77 |
catch ( \Exception $e ) {
|
78 |
}
|
79 |
}
|
80 |
+
return $falsePositiveConfidence;
|
81 |
}
|
82 |
}
|