aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2020-05-28 11:23:19 -0400
committerJake Hunsaker <jhunsake@redhat.com>2020-06-17 12:11:29 -0400
commitc92ee4bfeb2c4f612a392be7be8e4b619a31ccac (patch)
tree2aa07566e98a8b41b987092b9d33d66de2ac130a
parent33bfe244f66af4dedee887799db0b6eaf85c9f08 (diff)
downloadsos-c92ee4bfeb2c4f612a392be7be8e4b619a31ccac.tar.gz
[sos] Extend clean/mask option to report and collect
Extends the clean/mask options to the parsers built for `report` and `collect` so that those components hooking into `SoSCleaner` still allow full functionality to the user. Related: #1987 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/cleaner/__init__.py4
-rw-r--r--sos/collector/__init__.py55
-rw-r--r--sos/report/__init__.py223
3 files changed, 163 insertions, 119 deletions
diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py
index 3c4cb053..8c07a3ea 100644
--- a/sos/cleaner/__init__.py
+++ b/sos/cleaner/__init__.py
@@ -40,7 +40,7 @@ class SoSCleaner(SoSComponent):
arg_defaults = {
'domains': [],
'jobs': 4,
- 'map_file': '/etc/sos/cleaner/mapping',
+ 'map_file': '/etc/sos/cleaner/default_mapping',
'no_update': False,
'target': ''
}
@@ -60,8 +60,6 @@ class SoSCleaner(SoSComponent):
self.sys_tmp = hook_commons['sys_tmp']
self.policy = hook_commons['policy']
self.from_cmdline = False
- self.opts.map_file = '/etc/sos/cleaner/default_mapping'
- self.opts.no_update = False
if not hasattr(self.opts, 'jobs'):
self.opts.jobs = 4
self.soslog = logging.getLogger('sos')
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
index 08665b94..a1f5c547 100644
--- a/sos/collector/__init__.py
+++ b/sos/collector/__init__.py
@@ -47,42 +47,45 @@ class SoSCollector(SoSComponent):
desc = 'Collect an sos report from multiple nodes simultaneously'
arg_defaults = {
- 'alloptions': False,
'all_logs': False,
+ 'alloptions': False,
'allow_system_changes': False,
'become_root': False,
'case_id': False,
+ 'chroot': 'auto',
'clean': False,
- 'cluster_type': None,
'cluster_options': [],
- 'chroot': 'auto',
+ 'cluster_type': None,
+ 'domains': [],
'enable_plugins': [],
- 'encrypt_pass': '',
'encrypt_key': '',
+ 'encrypt_pass': '',
'group': None,
- 'save_group': '',
'image': '',
'jobs': 4,
- 'ssh_key': '',
- 'nopasswd_sudo': False,
- 'plugin_options': [],
- 'plugin_timeout': None,
- 'list_options': False,
'label': '',
+ 'list_options': False,
'log_size': 0,
- 'skip_plugins': [],
+ 'map_file': '/etc/sos/cleaner/default_mapping',
+ 'master': '',
'nodes': [],
'no_env_vars': False,
- 'no_pkg_check': False,
'no_local': False,
- 'master': '',
+ 'nopasswd_sudo': False,
+ 'no_pkg_check': False,
+ 'no_update': False,
'only_plugins': [],
- 'since': '',
- 'ssh_port': 22,
'password': False,
'password_per_node': False,
+ 'plugin_options': [],
+ 'plugin_timeout': None,
'preset': '',
+ 'save_group': '',
+ 'since': '',
+ 'skip_plugins': [],
'sos_opt_line': '',
+ 'ssh_key': '',
+ 'ssh_port': 22,
'ssh_user': 'root',
'timeout': 600,
'verify': False
@@ -279,9 +282,6 @@ class SoSCollector(SoSComponent):
dest='become_root',
help='Become root on the remote nodes')
collect_grp.add_argument('--case-id', help='Specify case number')
- collect_grp.add_argument('--clean', '--mask', action='store_true',
- default=False, dest='clean',
- help='Locally obfuscate reports gathered')
collect_grp.add_argument('--cluster-type',
help='Specify a type of cluster profile')
collect_grp.add_argument('-c', '--cluster-option',
@@ -333,6 +333,25 @@ class SoSCollector(SoSComponent):
collect_grp.add_argument('--timeout', type=int, required=False,
help='Timeout for sosreport on each node.')
+ # Group the cleaner options together
+ cleaner_grp = parser.add_argument_group(
+ 'Cleaner/Masking Options',
+ 'These options control how data obfuscation is performed'
+ )
+ cleaner_grp.add_argument('--clean', '--mask', dest='clean',
+ default=False, action='store_true',
+ help='Obfuscate sensistive information')
+ cleaner_grp.add_argument('--domains', dest='domains', default=[],
+ action='extend',
+ help='Additional domain names to obfuscate')
+ cleaner_grp.add_argument('--no-update', action='store_true',
+ default=False, dest='no_update',
+ help='Do not update the default cleaner map')
+ cleaner_grp.add_argument('--map', dest='map_file',
+ default='/etc/sos/cleaner/default_mapping',
+ help=('Provide a previously generated mapping'
+ ' file for obfuscation'))
+
def _check_for_control_persist(self):
"""Checks to see if the local system supported SSH ControlPersist.
diff --git a/sos/report/__init__.py b/sos/report/__init__.py
index 2eb26ab8..6d182a10 100644
--- a/sos/report/__init__.py
+++ b/sos/report/__init__.py
@@ -81,6 +81,7 @@ class SoSReport(SoSComponent):
'chroot': 'auto',
'clean': False,
'desc': '',
+ 'domains': [],
'dry_run': False,
'experimental': False,
'enableplugins': [],
@@ -90,10 +91,12 @@ class SoSReport(SoSComponent):
'list_presets': False,
'list_profiles': False,
'log_size': 25,
+ 'map_file': '/etc/sos/cleaner/default_mapping',
'noplugins': [],
'noreport': False,
'no_env_vars': False,
'no_postproc': False,
+ 'no_update': False,
'note': '',
'onlyplugins': [],
'preset': 'auto',
@@ -169,111 +172,135 @@ class SoSReport(SoSComponent):
@classmethod
def add_parser_options(cls, parser):
- parser.add_argument("-a", "--alloptions", action="store_true",
- dest="alloptions", default=False,
- help="enable all options for loaded plugins")
- parser.add_argument("--all-logs", action="store_true",
- dest="all_logs", default=False,
- help="collect all available logs regardless "
- "of size")
- parser.add_argument('--clean', '--mask', dest='clean', default=False,
- action='store_true',
- help='Obfuscate sensistive network information')
- parser.add_argument("--since", action="store",
- dest="since", default=None,
- type=_format_since,
- help="Escapes archived files older than date. "
- "This will also affect --all-logs. "
- "Format: YYYYMMDD[HHMMSS]")
- parser.add_argument("--build", action="store_true",
- dest="build", default=False,
- help="preserve the temporary directory and do not "
- "package results")
- parser.add_argument("--case-id", action="store",
- dest="case_id",
- help="specify case identifier")
- parser.add_argument("-c", "--chroot", action="store", dest="chroot",
- help="chroot executed commands to SYSROOT "
- "[auto, always, never] (default=auto)",
- default='auto')
- parser.add_argument("--desc", "--description", type=str,
- action="store", default="",
- help="Description for a new preset",)
- parser.add_argument("--dry-run", action="store_true",
- help="Run plugins but do not collect data")
- parser.add_argument("--experimental", action="store_true",
- dest="experimental", default=False,
- help="enable experimental plugins")
- parser.add_argument("-e", "--enable-plugins", action="extend",
- dest="enableplugins", type=str,
- help="enable these plugins", default=[])
- parser.add_argument("-k", "--plugin-option", action="extend",
- dest="plugopts", type=str,
- help="plugin options in plugname.option=value "
- "format (see -l)", default=[])
- parser.add_argument("--label", "--name", action="store", dest="label",
- help="specify an additional report label")
- parser.add_argument("-l", "--list-plugins", action="store_true",
- dest="list_plugins", default=False,
- help="list plugins and available plugin options")
- parser.add_argument("--list-presets", action="store_true",
- help="display a list of available presets")
- parser.add_argument("--list-profiles", action="store_true",
- dest="list_profiles", default=False,
- help="display a list of available profiles and "
- "plugins that they include")
- parser.add_argument("--log-size", action="store", dest="log_size",
- type=int, default=25,
- help="limit the size of collected logs (in MiB)")
- parser.add_argument("-n", "--skip-plugins", action="extend",
- dest="noplugins", type=str,
- help="disable these plugins", default=[])
- parser.add_argument("--no-report", action="store_true",
- dest="noreport", default=False,
- help="disable plaintext/HTML reporting")
- parser.add_argument("--no-env-vars", action="store_true",
- dest="no_env_vars", default=False,
- help="Do not collect environment variables")
- parser.add_argument("--no-postproc", default=False, dest="no_postproc",
- action="store_true",
- help="Disable all post-processing")
- parser.add_argument("--note", type=str, action="store", default="",
- help="Behaviour notes for new preset")
- parser.add_argument("-o", "--only-plugins", action="extend",
- dest="onlyplugins", type=str,
- help="enable these plugins only", default=[])
- parser.add_argument("--preset", action="store", type=str,
- help="A preset identifier", default="auto")
- parser.add_argument("--plugin-timeout", default=None,
- help="set a timeout for all plugins")
- parser.add_argument("-p", "--profile", action="extend",
- dest="profiles", type=str, default=[],
- help="enable plugins used by the given profiles")
- parser.add_argument("--verify", action="store_true",
- dest="verify", default=False,
- help="perform data verification during collection")
- parser.add_argument("--allow-system-changes", action="store_true",
- dest="allow_system_changes", default=False,
- help="Run commands even if they can change the "
- "system (e.g. load kernel modules)")
- parser.add_argument("--upload", action="store_true", default=False,
- help="Upload archive to a policy-default location")
- parser.add_argument("--upload-url", default=None,
- help="Upload the archive to the specified server")
- parser.add_argument("--upload-directory", default=None,
- help="Specify directory to upload the archive to")
- parser.add_argument("--upload-user", default=None,
- help="Username to authenticate to server with")
- parser.add_argument("--upload-pass", default=None,
- help="Password to authenticate to server with")
+ report_grp = parser.add_argument_group(
+ 'Report Options',
+ 'These options control how report collects data'
+ )
+ report_grp.add_argument("-a", "--alloptions", action="store_true",
+ dest="alloptions", default=False,
+ help="enable all options for loaded plugins")
+ report_grp.add_argument("--all-logs", action="store_true",
+ dest="all_logs", default=False,
+ help="collect all available logs regardless "
+ "of size")
+ report_grp.add_argument("--since", action="store",
+ dest="since", default=None, type=_format_since,
+ help="Escapes archived files older than date. "
+ "This will also affect --all-logs. "
+ "Format: YYYYMMDD[HHMMSS]")
+ report_grp.add_argument("--build", action="store_true",
+ dest="build", default=False,
+ help="preserve the temporary directory and do "
+ "not package results")
+ report_grp.add_argument("--case-id", action="store", dest="case_id",
+ help="specify case identifier")
+ report_grp.add_argument("-c", "--chroot", action="store",
+ dest="chroot", default='auto',
+ help="chroot executed commands to SYSROOT "
+ "[auto, always, never] (default=auto)")
+ report_grp.add_argument("--desc", "--description", type=str,
+ action="store", default="",
+ help="Description for a new preset",)
+ report_grp.add_argument("--dry-run", action="store_true",
+ help="Run plugins but do not collect data")
+ report_grp.add_argument("--experimental", action="store_true",
+ dest="experimental", default=False,
+ help="enable experimental plugins")
+ report_grp.add_argument("-e", "--enable-plugins", action="extend",
+ dest="enableplugins", type=str,
+ help="enable these plugins", default=[])
+ report_grp.add_argument("-k", "--plugin-option", action="extend",
+ dest="plugopts", type=str,
+ help="plugin options in plugname.option=value "
+ "format (see -l)", default=[])
+ report_grp.add_argument("--label", "--name", action="store",
+ dest="label",
+ help="specify an additional report label")
+ report_grp.add_argument("-l", "--list-plugins", action="store_true",
+ dest="list_plugins", default=False,
+ help="list plugins and available plugin "
+ "options")
+ report_grp.add_argument("--list-presets", action="store_true",
+ help="display a list of available presets")
+ report_grp.add_argument("--list-profiles", action="store_true",
+ dest="list_profiles", default=False,
+ help="display a list of available profiles and"
+ " plugins that they include")
+ report_grp.add_argument("--log-size", action="store", dest="log_size",
+ type=int, default=25,
+ help="limit the size of collected logs "
+ "(in MiB)")
+ report_grp.add_argument("-n", "--skip-plugins", action="extend",
+ dest="noplugins", type=str,
+ help="disable these plugins", default=[])
+ report_grp.add_argument("--no-report", action="store_true",
+ dest="noreport", default=False,
+ help="disable plaintext/HTML reporting")
+ report_grp.add_argument("--no-env-vars", action="store_true",
+ dest="no_env_vars", default=False,
+ help="Do not collect environment variables")
+ report_grp.add_argument("--no-postproc", default=False,
+ dest="no_postproc", action="store_true",
+ help="Disable all post-processing")
+ report_grp.add_argument("--note", type=str, action="store", default="",
+ help="Behaviour notes for new preset")
+ report_grp.add_argument("-o", "--only-plugins", action="extend",
+ dest="onlyplugins", type=str,
+ help="enable these plugins only", default=[])
+ report_grp.add_argument("--preset", action="store", type=str,
+ help="A preset identifier", default="auto")
+ report_grp.add_argument("--plugin-timeout", default=None,
+ help="set a timeout for all plugins")
+ report_grp.add_argument("-p", "--profile", action="extend",
+ dest="profiles", type=str, default=[],
+ help="enable plugins used by the given "
+ "profiles")
+ report_grp.add_argument("--verify", action="store_true",
+ dest="verify", default=False,
+ help="perform data verification during "
+ "collection")
+ report_grp.add_argument("--allow-system-changes", action="store_true",
+ dest="allow_system_changes", default=False,
+ help="Run commands even if they can change the"
+ " system (e.g. load kernel modules)")
+ report_grp.add_argument("--upload", action="store_true", default=False,
+ help="Upload archive to a policy-default "
+ "location")
+ report_grp.add_argument("--upload-url", default=None,
+ help="Upload the archive to specified server")
+ report_grp.add_argument("--upload-directory", default=None,
+ help="Specify upload directory for archive")
+ report_grp.add_argument("--upload-user", default=None,
+ help="Username to authenticate to server with")
+ report_grp.add_argument("--upload-pass", default=None,
+ help="Password to authenticate to server with")
# Group to make add/del preset exclusive
- preset_grp = parser.add_mutually_exclusive_group()
+ preset_grp = report_grp.add_mutually_exclusive_group()
preset_grp.add_argument("--add-preset", type=str, action="store",
help="Add a new named command line preset")
preset_grp.add_argument("--del-preset", type=str, action="store",
help="Delete the named command line preset")
+ # Group the cleaner options together
+ cleaner_grp = parser.add_argument_group(
+ 'Cleaner/Masking Options',
+ 'These options control how data obfuscation is performed'
+ )
+ cleaner_grp.add_argument('--clean', '--mask', dest='clean',
+ default=False, action='store_true',
+ help='Obfuscate sensistive information')
+ cleaner_grp.add_argument('--domains', dest='domains', default=[],
+ action='extend',
+ help='Additional domain names to obfuscate')
+ cleaner_grp.add_argument('--no-update', action='store_true',
+ default=False, dest='no_update',
+ help='Do not update the default cleaner map')
+ cleaner_grp.add_argument('--map', dest='map_file',
+ default='/etc/sos/cleaner/default_mapping',
+ help=('Provide a previously generated mapping'
+ ' file for obfuscation'))
+
def print_header(self):
print("\n%s\n" % _("sosreport (version %s)" % (__version__,)))