aboutsummaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* [collect,docs] Drop `--master` and update internal referencesJake Hunsaker2021-08-231-1/+1
| | | | | | | | | | | | | | | | This commit follows up on the previous changes from #2555 by fully dropping the `--master` option in favor of `--primary`, `--manager`, and `--controller`. Internal references have been updated as well, using the term `primary` across all instances. Note that within OCP cluster profile, 'primary' labeling and option setting still relies on the 'master' label/role reported by the environment, as that remains the term used to identify such nodes. Resolves: #2329 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sos] Read config section for clean when `--clean` is usedJake Hunsaker2021-08-114-0/+64
| | | | | | | | | | | | | | | | When a `report` or `collect` run would use `--clean` or `--mask` to do in-line obfuscation of collected reports, sos would not read the config section for clean - it would only be read if `sos clean` was called directly. As such, users would need to manually specify config file values for each run. Alleviate this gap by reading the config section for `clean` if either of the cleaner options are used. Do this before we apply cmdline options so that we maintain our order of precedence. Related: RHBZ#1950350 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Allow entire test classes to be distro specificJake Hunsaker2021-08-101-0/+21
| | | | | | | | | | | | | | Previously new test cases had to be written in such a way that they could be run on any supported distribution, even if their individual tests were all marked for specific distributions. Use of the distro-only decorators would fail when applied to test cases as a whole due to how test instantiation errors are handled. To address this, provide a distro check within `BaseSoSTest` so that tests can be made distro-specific and we can signal to avocado to skip all tests within that test case without failing the test suite entirely. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add test for cleaning and existing archiveJake Hunsaker2021-08-044-25/+110
| | | | | | | | | | | | | | | | Adds a test that ensures we are properly extracting and cleaning an already existing archive (one is being included under tests/test_data/ now), much the same as we test for a proper `sos report --clean` run. As part of this, some aspects of the `full_report_run.py` test are moved into the base test classes, and the new `existing_archive.py` test will explicitly run `sos clean` instead of `sos report`. The included archive for obfuscation testing is taken from a stock Fedora 34 VM with a known configuration which is reflected in the items being tested for. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sos|options] Add global 'namespaces' optionJake Hunsaker2021-08-021-1/+1
| | | | | | | | | | | | | | | Adds a global `--namespaces` option that can be used to limit the number of namespaces all plugins will iterate over. If a plugin provides a specific plugin option, such as the `networking.namespaces` option, then if set that plugin option will override the global option value. The global option defaults to not limiting namespaces, matching current behavior. Closes: #2092 Resolves: #2547 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [cleaner] Read map file only once for parsersJake Hunsaker2021-07-291-5/+5
| | | | | | | | | | Instead of re-reading the mapping file for each parser, read it once and store the contents, then hand those contents over to each parser. This allows us to side-step handling the same exception for malformed config files over and over for each parser loaded. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] use Avocado "recursive" behavior by defaultCleber Rosa2021-07-271-2/+0
| | | | | | | | | | | | | | Avocado will, by default, use the "recursive" behavior when looking for tests. It means that the class hierarchy will be crawled recursively, until, for "avocado-instrumented" tests, the top-most parent "avocado.Test" is found. When the "enable" behavior is activated, it forces the class to be considered one containing avocado-instrumented tests, but, it disables the recursive behavior and only the tests local to that specific class are found. Signed-off-by: Cleber Rosa <crosa@redhat.com>
* [tests] Add foreman_proxy and foreman_installer testsPavel Moravec2021-07-221-0/+26
| | | | | | | | | | | Add tests checking independence of foreman_* plugins on the "main" foreman plugin. Add the two plugins to the list of expectedly enabled on a tfm instance. Relevant: #2546 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
* [utilities,Plugin] Add sysroot wrappers for common os.path methodsJake Hunsaker2021-06-301-0/+1
| | | | | | | | | | | | | | | | Adds wrapper methods to `sos.utilities` that allows the common `os` methods, such as `os.path.exists()` to account for the setting of `sysroot`. This will allow sos, and particularly plugins, to more easily and reliably function as expected when sos is run within a container. Helpers have been added directly to `Plugin` that automatically pass the set `sysroot` option, so plugin authors do not need to handle that option or directly import these path functions from `sos.utilities`. Closes: #494 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Catch unexpected exceptions that can't be inspectedJake Hunsaker2021-06-301-0/+3
| | | | | | | If we get an exception we aren't expecting and can't investigate due to a missing `CmdResult` object being attached to the raised exception, simply re-raise that exception rather than failing on trying to inspect a non-existing object.
* [tests] Add new full-run clean test caseJake Hunsaker2021-06-302-0/+86
| | | | | | | | | | | Adds a new test case that captures a full, unrestricted, sos report and runs it through `sos clean` to enhance our confidence in `clean` performance. This is a StageTwo test as it will temporarily overwrite any existing default_mapping. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Make sos execution timeout configurableJake Hunsaker2021-06-301-1/+2
| | | | | | | | Allows test cases to set their own timeout for sos command executions, rather than applying a 300 second timeout to all test cases. 300 seconds remains the default, however. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Move report_with_mask tests to cleaner_tests directoryJake Hunsaker2021-06-221-0/+0
| | | | | | | | Moves the report_with_mask tests to be under the cleaner_tests/ directory. No changes are actually being made to the tests, this is an organization change. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add tests to ensure help outputJake Hunsaker2021-06-224-0/+217
| | | | | | | | | | | | | In the past, there have been otherwise trivial typos and the like that have caused `--help` output to be unreliable. In the case of "help options" such as `--list-plugins` this also includes potentially unavailable detailed information about whatever is being listed. These tests are sanity checks to ensure that changes aren't regressing this behavior and that the informational output options, and `--help` directly, continue to provide the right output. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Re-organize some features between base test classesJake Hunsaker2021-06-221-93/+108
| | | | | | | | | | | | | | Moves several aspects of test setup and design from `BaseSoSReportTest` into the lower-level `BaseSoSTest`, so that adding new test classes that are not report-centric will be easier going forward. Where needed, overrides in `BaseSoSReportTest` have been added. In general, this means that sos command construction, execution, tmpdir management, and the methods for mocking and other pre-execution tasks are now in `BaseSoSTest` and the additions in `BaseSoSReportTest` are now centered around handling a generated archive. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Allow plugin activation by container presenceJake Hunsaker2021-06-161-1/+1
| | | | | | | | | | | Adds an enablement trigger tuple, `containers`, that allows for enabling a plugin based on the presence of a _running_ container matching a given name or regex. Note that this is only functional for the default runtime discovered by a policy during initialization. Resolves: #2561 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [cleaner] Remove binary files by defaultJake Hunsaker2021-06-153-1/+62
| | | | | | | | | | | | | | | | | | Binary files generally speaking cannot be obfuscated, and as such we should remove them from archives being obfuscated by default so that sensitive data is not mistakenly included in an obfuscated archive. This commits adds a new `--keep-binary-files` option that if used will keep any encountered binary files in the final archive. The default option of `false` will ensure that encountered binary files are removed. The number of removed binary files per archive is reported when obfuscation is completed for that archive. Closes: #2478 Resolves: #2524 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Add default journal collection for Plugin servicesJake Hunsaker2021-06-142-1/+47
| | | | | | | | | | | | | | | | | Adds automatic collection of journals for any service defined in a plugin's `services` tuple, if that service exists on the system. Updates several plugins to define a `services` tuple in place of manually calling `add_journal()` (and as a bonus, removing redundant `add_service_status()` calls that are already performed based on the tuple). Additionally, add an appropriate tag to each `add_journal` call for easier collection lookup in the manifest. Resolves: #2579 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add test for using `--encrypt-pass`Jake Hunsaker2021-06-032-2/+85
| | | | | | | | | | Adds two test cases for using `--encrypt-pass`; one with just the bare option and another in conjunction with `--clean` to ensure both can be used in the same execution. Resolves: #2566 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [archive] skip copying SELinux context for /proc and /sys everytimePavel Moravec2021-06-011-0/+39
| | | | | | | | | | | A supplement of #1399 fix, now also for adding strings or special device files. Also adding a (vendor) test case for it. Resolves: #2560 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
* [tests] Improve failed command reporting in test outputJake Hunsaker2021-05-263-3/+13
| | | | | | | | | | | | | | | | | | | | Improves error reporting for failed sos commands by logging stderr (or stdout if stderr is not populated) to the console, which was previously being truncated by the builtin error handling of avocado. Printed output is limited to the last 8k to avoid dumping several MBs at a time for scenarios such as timeouts where command failure may generate significant logging prior to failing. Included with this are 2 minor changes to existing tests. First, remove verbose output from the expected plugins test to reduce otherwise irrelevant output for command failures. Second limit the number of plugins run for the LogLevelTest, both to reduce overall run time for a test where we aren't testing specific plugins and to improve readability of failures for such a test. Resolves: #2556 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add test for priority parameter in add_cmd_output()Jake Hunsaker2021-05-242-0/+68
| | | | | | | | | Adds a test that checks that the new `priority` parameter is working as expected for well known and common collections. Resolves: #2553 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add test for plugin design conformanceJake Hunsaker2021-05-191-0/+57
| | | | | | | | | | Adds a unittest that ensures conformance for plugin design, e.g. ensuring that enablement triggers are proper tuples and not inadvertent strings due to a missing trailing comma for single-tuples. Resolves: #2549 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [report] Do not fail on skipping non-existing pluginsJake Hunsaker2021-05-181-1/+12
| | | | | | | | | | | | | | | | | | | Specifying a non-existing plugin to skip is no longer considered a fatal error. This was previously in place, in part, for third party utilities calling sos to ensure adherence to known plugins. However, since `collect` has been integrated into sos natively, this is far less of a concern. Specfying non-existing plugins will now only generate a warning message for plugins wanting to be skipped (`-n`). If non-existing plugins are specified for enablement via `-e` or `-o`, that will still generate a fatal error. Closes: #537 Closes: #1723 Resolves: #2517 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add integration testing for ForemanJake Hunsaker2021-05-132-26/+116
| | | | | | | | | | | | | | | Adds an integration test for the upstream Foreman project. After stageone tests have passed, and if the PR has changes relevant to the Foreman plugins (or the cirrus config), launch a pre-built GCE image that has a Foreman deployment on it. Per request of the Foreman devel team, these tests will be run against both a CentOS and Debian based Foreman image. Currently, testing is performed against Foreman 2.4. Resolves: #2531 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [archive] Don't shell out for compressing the archiveJake Hunsaker2021-05-123-2/+46
| | | | | | | | | | As sos is now python3-only, we can avoid shelling-out to compression utilities like `xz` or `gzip`, and instead use the method provided by the built-in `tarfile` module. Resolves: #2523 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests|logs] Stream test data to journal, change inspected journalJake Hunsaker2021-05-051-9/+13
| | | | | | | | | | | | Changes the logs pre_sos_setup() to write to the journal using a stream rather than writing several MB directly all at once. This fixes an issue where using the `journal.send()` method from the systemd module would result in no data being written to the journal during the test setup. Second, switch over to inspecting the full journal rather than the most recent boot journal. Related: #2499
* [tests] assertFileGlobInArchive should only fail if file is presentJake Hunsaker2021-05-051-4/+8
| | | | | | | | | | | Like `assertFileCollected`, `assertFileGlobInArchive` should only fail if the referenced collection is not in the archive *and* it is present on the test system. If it is not present on the test system, sos cannot collect it and it is thus not an error to be missing from the archive. Related: #2499 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Correct test package installationJake Hunsaker2021-05-052-10/+9
| | | | | | | | | | | | | | | | First, correct the logs plugin stagetwo test to specify the needed package in a list, and second move the import to within the test class that needs it so that we don't fail on the stageone tests if the package is not present. Second, correct the journal injections that this plugin test does to use `pre_sos_setup()` instead of overriding `setup_mocking()`, and call the former after the mocking has been setup. Finally, add the resulting size of the collected journal if we fail the size requirements of the test. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add test class for when exceptions are expected in an executionJake Hunsaker2021-05-032-6/+89
| | | | | | | | | | | | | | Adds a new `StageOneReportExceptionTest` class that is to be used for tests that should ensure an exception IS hit, for example when testing plugin enablement or invalid options. Included with this commit is a small set of plugin enablement tests. Future tests for component and plugin specific exception handling should be built using this class and design approach. Resolves: #2518 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Make command output size limiting obviousJake Hunsaker2021-04-301-0/+4
| | | | | | | | | | | | | | | | | | | | | When command output is size limited it should be made obvious that it is not the whole output of the command, beyond the collected output (most likely) starting in the middle of a string. To do this, we add a 'truncated' key to the results dict returned by `sos_get_command_output()`, which is set based on if the `AsyncReader` was filled during command execution. From that, first log if a command was truncated. Second, instead of dropping the collected output in the normal plugin directory, instead drop it into `sos_strings` with a `.tailed` extention to mimic how we handled tailed file collections. Finally, add a symlink from the plugin dir with the original filename that points to the `sos_strings` path. Closes: #1332 Resolves: #2506 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Use re.search for assertOutput(Not)ContainsJake Hunsaker2021-04-281-2/+4
| | | | | | | | | | | Standardizes the `assertOutputContains` and `assertOutputNotContains` methods to use `re.search()`, instead of separate parsing methods. `search()` replaces `match()` for efficiency purposes against the collected output. Related: #2507 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [logging] Fix archive debug logging, adjust verbosity levelsJake Hunsaker2021-04-281-1/+20
| | | | | | | | | | | | | | | | | Fixes an issue where archive debug logging was controlled by the use of `--debug` rather than `--verbose`. Removes a superfluous log in `FileCacheArchive.add_link()`. Also, adjusts the different verbosity levels to be more meaninful. Now, the use of `-v` will enable debug logging but will not print those messages to console, `-vv` will print debug logging to console, while `-vvv` will enable archive debug logging which is expected to be significant due to most file operations being logging at some point with archive debug logging. Resolves: #2507 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [process] Collect per-process files from /procJake Hunsaker2021-04-161-0/+29
| | | | | | | | | | | | | | | | | | | | Adds collection of per-process files from /proc/$pid, limited to a number of pids controlled by the new `process.numprocs` option. This option will default to the first 2048 processes. Using a value of `0` for this option will result in all pids being collected. In testing, the initial limit of 2048 process did not significantly raise collection time or archive size. Note however, that collection of 20k or more processes does show a significant increase in plugin execution time and archive size. This is however tempered, by the whole-plugin timeout that sos imposes. Related: #436 Closes: #542 Resolves: #1783 Resolves: #2498 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add a test for default expected plugin enablementJake Hunsaker2021-04-151-1/+56
| | | | | | | | | | | | | | | | Adds a test case to ensure that the plugins we can expect to always be enabled when a "normal" `sos report` command is run are in fact enabled. First, test the distro-independent plugins that do not have specific enablement triggers (and thus should always be enabled). Second, have a distro-specific test for distro-specific plugins that are also expected to always run on those systems. Closes: #2365 Resolves: #2431 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Allow lists for plugin enablement assertionsJake Hunsaker2021-04-151-2/+8
| | | | | | | Updates `assertPlugin(Not)Included` to allow for lists as well as single strings. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add distro specific helper decoratorsJake Hunsaker2021-04-152-3/+14
| | | | | | | | | | | | | | | | | | | Adds helper decorators to define specific test methods for use on specific distributions only. Currently two decorators are available: @redhat_only Only run on fedora, centos, or rhel @ubuntu_only Only run on ubuntu or debian Note that these decorators are only intended for individual `test_*` methods, and will not function to define distro-specific test classes. These should make it easier to write plugin test cases where packaging differences between distributions otherwise makes plugin tests either impossible needlessly complex to write generically. Related: #2431 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Set local distro in StageOne to allow distro-specific testsJake Hunsaker2021-04-152-9/+12
| | | | | | | | | | | | | | Moves the detection of the local system's distribution to StageOne, and defines two constants to reference RH and Ubuntu distribution lists to allow for distro-specific tests. Further, make the expected_warnings_displayed test skipped if the local test system is not a RH-family distro, as those warnings are not expected on non RH-family systems. Related: #2431 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add a pre-setup setup method and smoke testsJake Hunsaker2021-04-152-0/+65
| | | | | | | | | | | | | | | | First, add a "pre-setup setup" method, in the form of `pre_sos_setup()`, that can be used in the way the traditional `setUp()` method would be used (but can't because that's our entry point for executing our sos runs). This method will be executed _prior_ to any mocking. Second, add a smoke test that enables all plugins that exist in the local branch being tested. This will test that doing so does not generate any exceptions and that some expected warnings from select plugins are displayed. Related: #2431 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add plugin tests for basic functionalityJake Hunsaker2021-04-155-0/+147
| | | | | | | | | | | | Adds several plugin tests for plugins that can be expected to run on all distributions, in particular these tests are including mostly Stage Two tests. As such, these tests are only recommended to be run on test machines. Related: #2431 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add a StageTwo timeout testJake Hunsaker2021-04-152-0/+65
| | | | | | Adds a test to ensure our timeout control is working properly. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Add StageTwoReportTest as a base test classJake Hunsaker2021-04-151-4/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commits adds a `StageTwoReportTest` from which tests that need to do "light" mocking should be defined. As the name implies, this is the base class for our Stage 2 tests. "Light" mocking for our purposes is currently defined as dropping files in locations on the test system's filesystem, which may include replacing binaries, and installing packages for the durtation of the test case. At the end of the test, packages are uninstalled and mocked files are removed. In the event that a file already exists at a given location on the test system, that file is temporarily renamed with a '.sostesting' extension. On test clean up, once mocked files are removed, any files renamed previously are moved back to their original location/name. Mocking is controlled automatically during test setup, and is based upon test class attributes, similar to how plugin enablement is dependent upon plugin class attributes. For Stage 2 tests cases, this includes: `files` - a list of file names. These names should represent the "real" location on the filesystem where the mocked files will be placed. The mocked content should be placed under a similar file path under tests/test_data E.G. using `files = ['/etc/foo/bar']` will place a copy of `tests/test_data/etc/foo/bar` under `/etc/foo/bar` on the test system. `packages` - a dict of packages to install. The dict keys map to the distribution the package names are used for, e.g. `rhel` or `ubuntu`. The values are lists of package names, optionally with version included. This commit includes just the framework for these tests, and no actual Stage 2 tests are included as of yet. Related: #2431 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [unittests] Update file paths in unittests for new directory layoutJake Hunsaker2021-04-153-15/+15
| | | | | | | | | Updates the filepaths in our unittests for the temp data files to reflect their new location in the updated directory layout. Related: #2431 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Start using avocado for test suiteJake Hunsaker2021-04-1526-272/+715
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit represents the start of an overhaul of the test suite used by sos. Note that several more commits to follow will be required in order for the test suite to be considered stable. The new test suite will use the avocado-framework to build out new tests. This first part adopts a new 'stageX' naming scheme for our tests as follows: stage0 -> Unittests stage1 -> Basic function tests, no mocking allowed stage2 -> Mocked tests for specific scenarios/regressions stage3 -> Complex setups for layered products/environments At the moment, these unittests are not updated for avocado, though most should still work with `nosetest` directly. A new set of base classes is defined in tests/sos_tests.py which provide the foundation for actual tests cases. This approach entails new test cases subclassing a base class, such as the new `StageOneReportTest`, and setting the `sos_cmd` class attr to the _options_ for an sos report run. By default `sos report --batch` will be run, and targeted to the test job's directory as a tmpdir. Each sos command will be executed once, and all test_* methods within a test case that subclasses `StageOneReportTest` will be checked against the output of that execution. Note that this diverges from avocado's typical approach where each test_* method is performed against a brand new instance of the class (thus meaning any setup including our sos report run would normally be run fresh). However, after speaking with the avocado devel team, this is still seen as a valid pattern for the framework. The current organizational approach is to separate the tests by component rather than stage. For example. `tests/report_tests/` should hold any report-centric tests, and the `plugin_tests` directory therein should be used for plugin-specific tests. As of this commit, there are basic functionality tests under `tests/report_tests/` and a single plugin test under `tests/report_tests/plugin_tests/` to act as a POC. Further, there is a `tests/vendor_tests/` directory for organizing vendor-specific bug/feature tests that are not covered by the generic project-wide tests. A POC test from RHBZ1928628 is available with this commit. Note that in order for these tests to be run properly _without_ installing the current branch to the local system, you will need to run the following command: `PYTHONPATH=tests/ avocado run -t stageone tests/` Related: #2431 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Fix typoEric Desrochers2021-03-231-1/+1
| | | | | | | | | | /var/tmp/sosreport_test/ instead of /var/tmp/sosreport/_test/ Resolves: #2457 Signed-off-by: Eric Desrochers <eric.desrochers@canonical.com> Signed-off-by: Bryan Quigley <code@bryanquigley.com>
* [clean] Fix hostnames not being obfuscated when host plugin wasn't runJake Hunsaker2021-02-171-1/+2
| | | | | | | | | | | | | | | | | | | | | It was discovered that if a report was generated without the host plugin being run, then the hostname parser would not obfuscate the localhost hostname or domain at all. This was due to the fact that while the default_mapping values were being read into the parser's map's dataset correctly, they weren't being loaded into the 'intermediary' dicts that the parser uses to separate short names from domain names. Fix this by reading the contents of the map's dataset dict (which is populated by the map file) into those intermediary dicts that the parser uses. Additionally, safeguard against overloading domain and host obfuscation numbers when loading this way by setting the respective counts to the next-highest number after the map loading is complete. Resolves: #2406 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [policy] switch to sha256 sumBryan Quigley2021-02-091-1/+1
| | | | | | | | | | | | Move cleaner to ignore both sha256/md5s Move collector to use sha256 as well. Move to get hash from stdout Resolves: #2351 Closes: #1204 Signed-off-by: Bryan Quigley <code@bryanquigley.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sos] Align plugin options with destination namesJake Hunsaker2021-02-032-2/+2
| | | | | | | | | | | | | This commit alters several option long-form names or destination names to align those values in a sensible way. This serves to not only remove some abiguity in option naming in code, but also to make it so that the "effective options" line logged in every sos execution can be direction copy-pasted as a working command. Closes: #2288 Resolves: #2398 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Policy] Add policy-controlled forbidden pathsJake Hunsaker2021-01-131-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds policy-controlled forbidden path checking, which should be the final part of implementing "global" forbidden paths. With this commit, policies may now add paths and glob matches for paths which should never be collected in any plugin. Combined with plugin-defined paths and user-defined paths already available, plugins should now be able to be properly restricted from sensitive collections. Note that the way this is implemented is that policies that define the `set_forbidden_paths()` classmethod *extend* this forbidden list as it is built from the subclass(es) that also define one. This way, "top-level" policies do not need to maintain independent copies of entire trees of paths just to add a few specific additional ones that are not forbidden within other policies. This initial commit adds paths that are either very well-known to be ones we should avoid, or are paths that have previously been part of reported issues where these paths/files should not be collected. Closes: #316 Closes: #796 Closes: #919 Closes: #1316 Resolves: #2360 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [PackageManager] Separate PackageManager from policiesJake Hunsaker2021-01-041-1/+2
| | | | | | | | | | | | Moves `PackageManager` out from `sos/policies/__init__.py` into a new `sos/policies/package_managers` subdir. Future commits will aim to canonicalize package manager subclasses for policies to use, and ease the creation of new reusable package managers. Related: #2349 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>