There may be leading output before the expected version string,
so make sure to be a bit stricter on in the regex to extract the
version correctly.
"SuricataVersion", ["major", "minor", "patch"])
def parse_suricata_version(buf):
- m = re.search("(\d+)\.?(\d+)?\.?(\d+)?.*", str(buf).strip())
+ m = re.search("(?:Suricata version |^)(\d+)\.?(\d+)?\.?(\d+)?.*", str(buf).strip())
if m:
major = int(m.group(1)) if m.group(1) else 0
minor = int(m.group(2)) if m.group(2) else 0