Skip to content

Commit

Permalink
Merge pull request #45 from jeroenvermeulen/bugfix/invalid_escape_seq…
Browse files Browse the repository at this point in the history
…uence

Fixed escaping in regexes using raw strings.
  • Loading branch information
scoopex authored May 27, 2024
2 parents d914e0c + e3ac71c commit b189be5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion extension-files/tools/zabbix_check_smartmontools
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_attribute(device, attribute):
# 1 Raw_Read_Error_Rate 0x000a 100 100 000 Old_age Always - 0
for line in out.decode('utf8').splitlines():
if attribute == "Temperature_Celsius":
line = re.sub("\(Min\/Max \d+\/\d+\)", "", line)
line = re.sub(r"\(Min\/Max \d+\/\d+\)", "", line)

m = re.match(r"^\s*\d+\s+([^\s]+?)\s+0x.*\s+(([^\s]+))\s*$", line)
if not m:
Expand Down
4 changes: 2 additions & 2 deletions extension-files/tools/zabbix_discovery_devices
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def read_config(config_file):
content = fh.read()

# Remove multiline comments
content = re.sub('^\s*/\*.*?\*/\s*', '', content, 0, re.DOTALL | re.MULTILINE)
content = re.sub(r'^\s*/\*.*?\*/\s*', '', content, 0, re.DOTALL | re.MULTILINE)
# Remove single line comments
content = re.sub('^\s*//.*$\n', '', content, 0, re.MULTILINE)
content = re.sub(r'^\s*//.*$'+'\n', '', content, 0, re.MULTILINE)

config = json.loads(content)

Expand Down
8 changes: 4 additions & 4 deletions extension-files/tools/zabbix_discovery_filesystems
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ config_default = {
"regex_includes_type": [".*"],
"regex_excludes_name": [],
"regex_excludes_type": ["nfs", "nfs4", "nfsd", "cifs", "autofs", "binfmt_misc", "cgroup", "cgroup2", "configfs",
"debugfs", "overlay", "overlay2","systemd-1", "nsfs", "lxcfs",
"debugfs", "overlay", "overlay2","systemd-1", "nsfs", "lxcfs",
"devpts", "devtmpfs", "efivarfs", "fusectl", "fuse.gvfsd-fuse", "hugetlbfs", "mqueue",
"fuse.lxcfs", "xenfs", "rpc_pipefs", "efivarfs", "tracefs", "squashfs",
"proc", "pstore", "securityfs", "sysfs", "tmpfs", "vfat", "iso9660" ],
Expand All @@ -45,7 +45,7 @@ def check_match(matchfor, filesystem_name, config, key):

if key in config:
regexes = config[key]
else:
else:
regexes = []

for regex in regexes:
Expand All @@ -67,9 +67,9 @@ def read_config(config_file):
content = fh.read()

# Remove multiline comments
content = re.sub('^\s*/\*.*?\*/\s*', '', content, 0, re.DOTALL | re.MULTILINE)
content = re.sub(r'^\s*/\*.*?\*/\s*', '', content, 0, re.DOTALL | re.MULTILINE)
# Remove single line comments
content = re.sub('^\s*//.*$\n', '', content, 0, re.MULTILINE)
content = re.sub(r'^\s*//.*$'+'\n', '', content, 0, re.MULTILINE)

config = json.loads(content)

Expand Down

0 comments on commit b189be5

Please sign in to comment.