mirror of https://github.com/MISP/MISP
fix: [attribute] IP address was considered as valid AS number
parent
f57ea8ef21
commit
c8bda8b66f
|
@ -202,7 +202,7 @@ class AttributeValidationTool
|
|||
$value = substr($value, 2); // remove 'AS'
|
||||
}
|
||||
if (strpos($value, '.') !== false) { // maybe value is in asdot notation
|
||||
$parts = explode('.', $value);
|
||||
$parts = explode('.', $value, 2);
|
||||
if (self::isPositiveInteger($parts[0]) && self::isPositiveInteger($parts[1])) {
|
||||
return $parts[0] * 65536 + $parts[1];
|
||||
}
|
||||
|
|
|
@ -110,6 +110,20 @@ class AttributeValidationToolTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function testValidateAs(): void
|
||||
{
|
||||
$this->shouldBeValid('AS', [
|
||||
'0',
|
||||
0,
|
||||
1,
|
||||
'1',
|
||||
4294967295,
|
||||
]);
|
||||
$this->shouldBeInvalid('AS', [
|
||||
'1.2.3.4',
|
||||
]);
|
||||
}
|
||||
|
||||
public function testCompressIpv6(): void
|
||||
{
|
||||
$this->assertEquals('1234:fd2:5621:1:89::4500', AttributeValidationTool::modifyBeforeValidation('ip-src', '1234:0fd2:5621:0001:0089:0000:0000:4500'));
|
||||
|
|
Loading…
Reference in New Issue