Tighten regex rule to discard IP address as hostname

This commit is contained in:
Indrajit Raychaudhuri
2017-06-19 20:23:00 -05:00
parent 297c699103
commit 7e1b06ecf9

View File

@@ -501,7 +501,8 @@ def normalize_rule(rule):
The rule string with spelling and spacing reformatted.
"""
result = re.search(r'^[ \t]*(\d+\.\d+\.\d+\.\d+)\s+([\w\.-]+)(.*)', rule)
result = re.search(r'^\s*(\d{1,3}\.){3}\d{1,3}\s+([\w\.-]+[a-zA-Z])(.*)',
rule)
if result:
hostname, suffix = result.group(2, 3)