chg: [internal] Optimise converting hash to lowercase

pull/7895/head
Jakub Onderka 2021-10-28 15:56:48 +02:00
parent 0e81e90fef
commit 5b0979200a
2 changed files with 8 additions and 2 deletions

View File

@ -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);

View File

@ -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) {