Hints kitten: add support for IPs (v4 and v6)

It selects v4 and v6 IPs with a simple regex that doesn't actually
check for the validity of the IPs.
This commit is contained in:
Sighery
2020-10-04 22:04:00 +02:00
parent d3d2930bd2
commit b4415c90f9
2 changed files with 36 additions and 1 deletions

View File

@@ -325,6 +325,14 @@ def functions_for(args: HintsCLIOptions) -> Tuple[str, List[PostprocessorFunc]]:
pattern = '(?m)^\\s*(.+)[\\s\0]*$'
elif args.type == 'hash':
pattern = '[0-9a-f]{7,128}'
elif args.type == 'ip':
pattern = (
# # IPv4 with no validation
r"((?:\d{1,3}\.){3}\d{1,3}"
r"|"
# # IPv6 with no validation
r"(?:[a-fA-F0-9]{0,4}:){2,7}[a-fA-F0-9]{1,4})"
)
elif args.type == 'word':
chars = args.word_characters
if chars is None:
@@ -482,7 +490,7 @@ programs.
--type
default=url
choices=url,regex,path,line,hash,word,linenum,hyperlink
choices=url,regex,path,line,hash,word,linenum,hyperlink,ip
The type of text to search for. A value of :code:`linenum` is special, it looks
for error messages using the pattern specified with :option:`--regex`, which
must have the named groups, :code:`path` and :code:`line`. If not specified,