-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mod. Heuristic always returns SUSPICIOUS severity.
Mod. Heuristic always returns SUSPICIOUS severity.
- Loading branch information
Showing
11 changed files
with
624 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
use CleantalkSP\Common\Scanner\HeuristicAnalyser\Controller; | ||
use CleantalkSP\Common\Scanner\HeuristicAnalyser\Structures\FileInfo; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NoPHPCodeTest extends TestCase | ||
{ | ||
private $current_dir; | ||
private $heuristic_scanner; | ||
|
||
private $files_list; | ||
|
||
public function setUp() | ||
{ | ||
$this->current_dir = __DIR__ . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR; | ||
$this->heuristic_scanner = new Controller(); | ||
$this->files_list = array( | ||
'testNoPHPCodeFile' => new FileInfo( | ||
'has_no_php.otf', | ||
file_get_contents($this->current_dir . 'has_no_php.otf') | ||
), | ||
'testNoPHPCodeFileWithShortOpenTag' => new FileInfo( | ||
'has_no_php_but_has_short_open_tag.otf', | ||
file_get_contents($this->current_dir . 'has_no_php_but_has_short_open_tag.otf') | ||
), | ||
'testHasPHPCodeBadFile' => new FileInfo( | ||
'has_bad_php.otf', | ||
file_get_contents($this->current_dir . 'has_bad_php.otf') | ||
), | ||
'testHasPHPCodeBadFileShortOpenTag' => new FileInfo( | ||
'has_bad_php_short_tag.otf', | ||
file_get_contents($this->current_dir . 'has_bad_php_short_tag.otf') | ||
), | ||
'testHasPHPCodeBadFileNoClosingTag' => new FileInfo( | ||
'has_bad_php_no_closing_tag.otf', | ||
file_get_contents($this->current_dir . 'has_bad_php_no_closing_tag.otf') | ||
), | ||
'testHasPHPCodeBadFileOpenSomewhere' => new FileInfo( | ||
'has_bad_php_open_somewhere.otf', | ||
file_get_contents($this->current_dir . 'has_bad_php_open_somewhere.otf') | ||
), | ||
'testHasPHPCodeGoodFile' => new FileInfo( | ||
'has_good_php.otf', | ||
file_get_contents($this->current_dir . 'has_good_php.otf') | ||
), | ||
); | ||
parent::setUp(); // TODO: Change the autogenerated stub | ||
} | ||
|
||
public function testNoPHPCodeFile() | ||
{ | ||
$verdict = $this->heuristic_scanner->scanFile($this->files_list[__FUNCTION__], $this->current_dir); | ||
$this->assertEquals('OK', $verdict->status); | ||
$this->assertEquals(null, $verdict->severity); | ||
} | ||
|
||
public function testNoPHPCodeFileWithShortOpenTag() | ||
{ | ||
$verdict = $this->heuristic_scanner->scanFile($this->files_list[__FUNCTION__], $this->current_dir); | ||
$this->assertEquals('OK', $verdict->status); | ||
$this->assertEquals(null, $verdict->severity); | ||
} | ||
public function testHasPHPCodeBadFile() | ||
{ | ||
$verdict = $this->heuristic_scanner->scanFile($this->files_list[__FUNCTION__], $this->current_dir); | ||
$this->assertEquals('INFECTED', $verdict->status); | ||
$this->assertEquals('SUSPICIOUS', $verdict->severity); | ||
} | ||
|
||
public function testHasPHPCodeBadFileNoClosingTag() | ||
{ | ||
$verdict = $this->heuristic_scanner->scanFile($this->files_list[__FUNCTION__], $this->current_dir); | ||
$this->assertEquals('INFECTED', $verdict->status); | ||
$this->assertEquals('SUSPICIOUS', $verdict->severity); | ||
} | ||
|
||
public function testHasPHPCodeBadFileOpenSomewhere() | ||
{ | ||
$verdict = $this->heuristic_scanner->scanFile($this->files_list[__FUNCTION__], $this->current_dir); | ||
$this->assertEquals('INFECTED', $verdict->status); | ||
$this->assertEquals('SUSPICIOUS', $verdict->severity); | ||
} | ||
|
||
public function testHasPHPCodeBadFileShortOpenTag() | ||
{ | ||
if ( ini_get('short_open_tag') ) { | ||
$verdict = $this->heuristic_scanner->scanFile($this->files_list[__FUNCTION__], $this->current_dir); | ||
$this->assertEquals('INFECTED', $verdict->status); | ||
$this->assertEquals('SUSPICIOUS', $verdict->severity); | ||
} | ||
} | ||
|
||
public function testHasPHPCodeGoodFile() | ||
{ | ||
$verdict = $this->heuristic_scanner->scanFile($this->files_list[__FUNCTION__], $this->current_dir); | ||
$this->assertEquals('OK', $verdict->status); | ||
$this->assertEquals(null, $verdict->severity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
$code = eval('$a=$b;'); | ||
?> | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malwaresome text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
|
||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
some text not contains malware | ||
|
||
|
Oops, something went wrong.