diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2012-12-04 21:39:49 +0000 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2012-12-04 21:39:49 +0000 |
commit | 362c491d976509fdf89180818b2f0039ee54793e (patch) | |
tree | b739860c4a9ea523d6c82cdbf073f6dd75c41eaf | |
parent | 38f2b83b51d5da7ef7d5cde593c76cfdc2631fdf (diff) | |
download | sos-362c491d976509fdf89180818b2f0039ee54793e.tar.gz |
Improve sanitization of user and case number in LinuxPolicy
-rw-r--r-- | sos/policies/__init__.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py index 57803264..9fdcc9fc 100644 --- a/sos/policies/__init__.py +++ b/sos/policies/__init__.py @@ -395,6 +395,12 @@ class LinuxPolicy(Policy): """Returns the name usd in the preWork step""" return self.hostName() + def sanitizeReportName(self, report_name): + return re.sub(r"[^-a-zA-Z.0-9]", "", report_name) + + def sanitizeTicketNumber(self, ticket_number): + return re.sub(r"[^0-9]", "", ticket_number) + def preWork(self): # this method will be called before the gathering begins @@ -403,10 +409,8 @@ class LinuxPolicy(Policy): if not self.commons['cmdlineopts'].batch and not self.commons['cmdlineopts'].silent: try: self.reportName = raw_input(_("Please enter your first initial and last name [%s]: ") % localname) - self.reportName = re.sub(r"[^a-zA-Z.0-9]", "", self.reportName) self.ticketNumber = raw_input(_("Please enter the case number that you are generating this report for: ")) - self.ticketNumber = re.sub(r"[^0-9]", "", self.ticketNumber) self._print() except: self._print() @@ -417,11 +421,12 @@ class LinuxPolicy(Policy): if self.commons['cmdlineopts'].customerName: self.reportName = self.commons['cmdlineopts'].customerName - self.reportName = re.sub(r"[^a-zA-Z.0-9]", "", self.reportName) if self.commons['cmdlineopts'].ticketNumber: self.ticketNumber = self.commons['cmdlineopts'].ticketNumber - self.ticketNumber = re.sub(r"[^0-9]", "", self.ticketNumber) + + self.reportName = self.sanitizeReportName(self.reportName) + self.ticketNumber = self.sanitizeTicketNumber(self.ticketNumber) return |