[PATCH rtems-tools 5 5/5] rtems-bsp-builder: Fix mail support

Alex White alex.white at oarcorp.com
Wed Dec 15 21:32:56 UTC 2021


This fixes a problem with mailer options support that occurred because
check.py uses argparse.ArgumentParser instead of tester.rt.options.

Closes #4553
---
 rtemstoolkit/mailer.py |  5 +++--
 tester/rt/check.py     | 17 ++++++++++++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/rtemstoolkit/mailer.py b/rtemstoolkit/mailer.py
index ae51d78..09e4a26 100644
--- a/rtemstoolkit/mailer.py
+++ b/rtemstoolkit/mailer.py
@@ -61,14 +61,15 @@ def append_options(opts):
 def add_arguments(argsp):
     argsp.add_argument('--mail', help = _options['--mail'], action = 'store_true')
     argsp.add_argument('--use-gitconfig', help = _options['--use-gitconfig'], action = 'store_true')
-    for o in list(_options)[1:]:
+    no_add = ['--mail', '--use-gitconfig']
+    for o in [opt for opt in list(_options) if opt not in no_add]:
         argsp.add_argument(o, help = _options[o], type = str)
 
 class mail:
     def __init__(self, opts):
         self.opts = opts
         self.gitconfig_lines = None
-        if opts.find_arg('--use-gitconfig') is not None:
+        if self._get_arg('--use-gitconfig'):
             # Read the output of `git config --list` instead of reading the
             # .gitconfig file directly because Python 2 ConfigParser does not
             # accept tabs at the beginning of lines.
diff --git a/tester/rt/check.py b/tester/rt/check.py
index 2a38d99..deac19d 100755
--- a/tester/rt/check.py
+++ b/tester/rt/check.py
@@ -105,7 +105,22 @@ def title():
     return 'RTEMS Tools Project - RTEMS Kernel BSP Builder, %s' % (version.string())
 
 def command_line():
-    return wrap(('command: ', ' '.join(sys.argv)), lineend = '\\')
+    # Filter potentially sensitive mail options out.
+    filtered_args = [
+        arg for arg in sys.argv
+        if all(
+            smtp_opt not in arg
+            for smtp_opt in [
+                '--smtp-host',
+                '--mail-to',
+                '--mail-from',
+                '--smtp-user',
+                '--smtp-password',
+                '--smtp-port'
+            ]
+        )
+    ]
+    return wrap(('command: ', ' '.join(filtered_args)), lineend = '\\')
 
 def jobs_option_parse(jobs_option):
     try:
-- 
2.27.0



More information about the devel mailing list