@cryptotaxi247 / netdata-1 / commits / 7682e98dd

disable command whitelisting, enable custom commands

paulfantom committed Jul 14, 2016 at 00:30 UTC 7682e98dd42cd6c64338eb1a1bd1979e3c4e9e39
1 file changed +9 -9
python.d/python_modules/base.py
+9 -9
@@ -621,7 +621,7 @@ class LogService(SimpleService):
621
622
623 class ExecutableService(SimpleService):
624 - command_whitelist = ['exim', 'postqueue']
624 + #command_whitelist = ['exim', 'postqueue']
625 bad_substrings = ('&', '|', ';', '>', '<')
626
627 def __init__(self, configuration=None, name=None):
@@ -653,21 +653,21 @@ class ExecutableService(SimpleService):
653 self.name = ""
654 else:
655 self.name = str(self.name)
656 - # try:
657 - # self.command = str(self.configuration['path'])
658 - # except (KeyError, TypeError):
659 - # self.error("No command specified. Using: '" + self.command + "'")
656 + try:
657 + self.command = str(self.configuration['command'])
658 + except (KeyError, TypeError):
659 + self.error("No command specified. Using: '" + self.command + "'")
660 self.command = self.command.split(' ')
661 - if self.command[0] not in self.command_whitelist:
662 - self.error("Command is not whitelisted.")
663 - return False
661 + #if self.command[0] not in self.command_whitelist:
662 + # self.error("Command is not whitelisted.")
663 + # return False
664
665 for arg in self.command[1:]:
666 if any(st in arg for st in self.bad_substrings):
667 self.error("Bad command argument:" + " ".join(self.command[1:]))
668 return False
669 # test command and search for it in /usr/sbin or /sbin when failed
670 - base = self.command[0]
670 + base = self.command[0].split('/')[-1]
671 if self._get_raw_data() is None:
672 for prefix in ['/sbin/', '/usr/sbin/']:
673 self.command[0] = prefix + base