mirror of https://github.com/MISP/MISP
Merge pull request #8612 from JakubOnderka/ssdeep-validation
chg: [validation] Check if ssdeep contain newline characterpull/8625/head
commit
3f9898b806
|
@ -635,11 +635,14 @@ class AttributeValidationTool
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
private static function isSsdeep($value)
|
||||
{
|
||||
if (strpos($value, "\n") !== false) {
|
||||
return false;
|
||||
}
|
||||
$parts = explode(':', $value);
|
||||
if (count($parts) !== 3) {
|
||||
return false;
|
||||
|
|
|
@ -135,6 +135,12 @@ class AttributeValidationToolTest extends TestCase
|
|||
$this->assertEquals('xn--hkyrky-ptac70bc.cz|127.0.0.1', AttributeValidationTool::modifyBeforeValidation('domain|ip', 'HÁČKYČÁRKY.CZ|127.0.0.1'));
|
||||
}
|
||||
|
||||
public function testSssdeep()
|
||||
{
|
||||
$this->shouldBeValid('ssdeep', ["768:+OFu8Q3w6QzfR5Jni6SQD7qSFDs6P93/q0XIc/UB5EPABWX:RFu8QAFzffJui79f13/AnB5EPAkX"]);
|
||||
$this->shouldBeInvalid('ssdeep', ["768:+OFu8Q3w6QzfR5Jni6SQD7qSFDs6P93/q0XIc/UB5EPABWX\n\n:RFu8QAFzffJui79f13/AnB5EPAkX"]);
|
||||
}
|
||||
|
||||
private function shouldBeValid($type, array $values)
|
||||
{
|
||||
foreach ($values as $value) {
|
||||
|
|
Loading…
Reference in New Issue