diff options
author | astokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2010-01-14 15:12:28 +0000 |
---|---|---|
committer | astokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8> | 2010-01-14 15:12:28 +0000 |
commit | d94514462f60693cf115553ca5ca47f1e18fad8f (patch) | |
tree | 8295ad196393956ab906fddff4b1471a85cc6473 | |
parent | 09e8e83472f8ef32e419e3542a6bd725f4d49e3d (diff) | |
download | sos-d94514462f60693cf115553ca5ca47f1e18fad8f.tar.gz |
working on a sanitize plugin
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@676 ef72aa8b-4018-0410-8976-d6e080ef94d8
-rw-r--r-- | src/lib/sos/plugins/general.py | 17 | ||||
-rw-r--r-- | src/lib/sos/plugins/sanitize.py | 34 |
2 files changed, 35 insertions, 16 deletions
diff --git a/src/lib/sos/plugins/general.py b/src/lib/sos/plugins/general.py index 44e81c1a..2f6a8e7b 100644 --- a/src/lib/sos/plugins/general.py +++ b/src/lib/sos/plugins/general.py @@ -22,10 +22,7 @@ class general(sos.plugintools.PluginBase): """ optionList = [("syslogsize", "max size (MiB) to collect per syslog file", "", 15), - ("all_logs", "collect all log files defined in syslog.conf", "", False), - ("sanitize", "scrub hostname/ip's from log files", "", False)] - - hostname = commands.getoutput("/bin/hostname") + ("all_logs", "collect all log files defined in syslog.conf", "", False)] def setup(self): self.addCopySpec("/etc/redhat-release") @@ -55,20 +52,8 @@ class general(sos.plugintools.PluginBase): for i in logs: if not os.path.isfile(i): continue self.addCopySpec(i) - return def postproc(self): self.doRegexSub("/etc/sysconfig/rhn/up2date", r"(\s*proxyPassword\s*=\s*)\S+", r"\1***") - - # sanitize ip's, hostnames in logs - if self.getOption('sanitize'): - rhelver = self.policy().rhelVersion() - if rhelver == 5 or rhelver == 4: - logs=self.doRegexFindAll(r"^\S+\s+(\/.*log.*)\s+$", "/etc/syslog.conf") - else: - logs=self.doRegexFindAll(r"^\S+\s+(\/.*log.*)\s+$", "/etc/rsyslog.conf") - for log in logs: - self.doRegexSub(log, r"\s+(%s.*)" % (self.hostname,), r"\1sanitized-hostname") - self.doRegexSub(log, r"([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", r"\1sanitized-ip") return diff --git a/src/lib/sos/plugins/sanitize.py b/src/lib/sos/plugins/sanitize.py new file mode 100644 index 00000000..421b2314 --- /dev/null +++ b/src/lib/sos/plugins/sanitize.py @@ -0,0 +1,34 @@ +### This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. + +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. + +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import os +import sos.plugintools +import glob + +class sanitize(sos.plugintools.PluginBase): + """ sanitize plugin + """ + def defaultenabled(self): + return False + + def setup(self): + # sanitize ip's, hostnames in logs + rhelver = self.policy().rhelVersion() + if rhelver == 5 or rhelver == 4: + logs=self.doRegexFindAll(r"^\S+\s+(\/.*log.*)\s+$", "/etc/syslog.conf") + else: + logs=self.doRegexFindAll(r"^\S+\s+(\/.*log.*)\s+$", "/etc/rsyslog.conf") + for log in logs: + self.doRegexSub(log, r"\s+(%s.*)" % (self.hostname,), r"\1sanitized-hostname") + self.doRegexSub(log, r"([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", r"\1sanitized-ip")
\ No newline at end of file |