fix: Added impfuzzy validation

pull/3345/head
iglocska 2018-06-11 17:48:36 +02:00
parent 169da86545
commit e70992c565
1 changed files with 25 additions and 18 deletions

View File

@ -815,20 +815,20 @@ class Attribute extends AppModel {
}
private $__hexHashLengths = array(
'authentihash' => 64,
'md5' => 32,
'imphash' => 32,
'sha1' => 40,
'x509-fingerprint-md5' => 32,
'x509-fingerprint-sha1' => 40,
'x509-fingerprint-sha256' => 64,
'pehash' => 40,
'sha224' => 56,
'sha256' => 64,
'sha384' => 96,
'sha512' => 128,
'sha512/224' => 56,
'sha512/256' => 64,
'authentihash' => 64,
'md5' => 32,
'imphash' => 32,
'sha1' => 40,
'x509-fingerprint-md5' => 32,
'x509-fingerprint-sha1' => 40,
'x509-fingerprint-sha256' => 64,
'pehash' => 40,
'sha224' => 56,
'sha256' => 64,
'sha384' => 96,
'sha512' => 128,
'sha512/224' => 56,
'sha512/256' => 64
);
public function runValidation($value, $type) {
@ -845,8 +845,8 @@ class Attribute extends AppModel {
case 'sha512/224':
case 'sha512/256':
case 'authentihash':
case 'x509-fingerprint-md5':
case 'x509-fingerprint-sha256':
case 'x509-fingerprint-md5':
case 'x509-fingerprint-sha256':
case 'x509-fingerprint-sha1':
$length = $this->__hexHashLengths[$type];
if (preg_match("#^[0-9a-f]{" . $length . "}$#", $value)) {
@ -876,6 +876,13 @@ class Attribute extends AppModel {
}
if (!$returnValue) $returnValue = 'Invalid SSDeep hash. The format has to be blocksize:hash:hash';
break;
case 'impfuzzy':
if (substr_count($value, ':') == 2) {
$parts = explode(':', $value);
if (is_numeric($parts[0])) $returnValue = true;
}
if (!$returnValue) $returnValue = 'Invalid impfuzzy format. The format has to be imports:hash:hash';
break;
case 'http-method':
if (preg_match("#(OPTIONS|GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT|PROPFIND|PROPPATCH|MKCOL|COPY|MOVE|LOCK|UNLOCK|VERSION-CONTROL|REPORT|CHECKOUT|CHECKIN|UNCHECKOUT|MKWORKSPACE|UPDATE|LABEL|MERGE|BASELINE-CONTROL|MKACTIVITY|ORDERPATCH|ACL|PATCH|SEARCH)#", $value)) {
$returnValue = true;
@ -1270,8 +1277,8 @@ class Attribute extends AppModel {
$value = preg_replace('/^hxxp/i', 'http', $value);
$value = preg_replace('/\[\.\]/', '.' , $value);
break;
case 'x509-fingerprint-md5':
case 'x509-fingerprint-sha256':
case 'x509-fingerprint-md5':
case 'x509-fingerprint-sha256':
case 'x509-fingerprint-sha1':
$value = str_replace(':', '', $value);
$value = strtolower($value);