From 36dbbc39d7f3d2a7c8d0146c59c3def9ad2e3eb6 Mon Sep 17 00:00:00 2001 From: srilumpa Date: Thu, 22 Feb 2018 15:58:44 +0100 Subject: [PATCH 1/2] Detect more strictly IPv4 address --- contrib/cortexutils/extractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/cortexutils/extractor.py b/contrib/cortexutils/extractor.py index f77c1df13..88ed40ce9 100644 --- a/contrib/cortexutils/extractor.py +++ b/contrib/cortexutils/extractor.py @@ -28,7 +28,7 @@ def __init_regex(): # IPv4 regex = [{ 'type': 'ip', - 'regex': re.compile(r'[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}') + 'regex': re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$') }] # IPv6 From 220821d25f69ac13d13ff68f2694a556cee12a39 Mon Sep 17 00:00:00 2001 From: srilumpa Date: Thu, 22 Feb 2018 15:59:17 +0100 Subject: [PATCH 2/2] Include netmask detection in CIDR notation --- contrib/cortexutils/extractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/cortexutils/extractor.py b/contrib/cortexutils/extractor.py index 88ed40ce9..264e5ad12 100644 --- a/contrib/cortexutils/extractor.py +++ b/contrib/cortexutils/extractor.py @@ -28,7 +28,7 @@ def __init_regex(): # IPv4 regex = [{ 'type': 'ip', - 'regex': re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$') + 'regex': re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:\/\d\d?)?$') }] # IPv6