mirror of https://github.com/MISP/MISP
chg: [internal] Optimise converting hash to lowercase
parent
0e81e90fef
commit
5b0979200a
|
@ -117,8 +117,9 @@ class AttributeValidationTool
|
|||
case 'filename|vhash':
|
||||
case 'filename|pehash':
|
||||
case 'filename|tlsh':
|
||||
$pieces = explode('|', $value);
|
||||
return $pieces[0] . '|' . strtolower($pieces[1]);
|
||||
// Convert hash to lowercase
|
||||
$pos = strpos($value, '|');
|
||||
return substr($value, 0, $pos) . strtolower(substr($value, $pos));
|
||||
case 'http-method':
|
||||
case 'hex':
|
||||
return strtoupper($value);
|
||||
|
|
|
@ -114,6 +114,11 @@ class AttributeValidationToolTest extends TestCase
|
|||
$this->assertEquals('127.0.0.1', AttributeValidationTool::modifyBeforeValidation('ip-src', '127.0.0.1'));
|
||||
}
|
||||
|
||||
public function testFilenameHashLowercase()
|
||||
{
|
||||
$this->assertEquals('CMD.EXE|0cc175b9c0f1b6a831c399e269772661', AttributeValidationTool::modifyBeforeValidation('filename|md5', 'CMD.EXE|0CC175B9C0F1B6A831C399E269772661'));
|
||||
}
|
||||
|
||||
private function shouldBeValid($type, array $values)
|
||||
{
|
||||
foreach ($values as $value) {
|
||||
|
|
Loading…
Reference in New Issue