-
Notifications
You must be signed in to change notification settings - Fork 698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Automatus traceback #11111
Fix Automatus traceback #11111
Conversation
This commit tries to fix a traceback that happens when evaluating a SLE15 data stream on a container back end when the test scenarios require to install a package into the back end. Resolves: ``` [jcerny@fedora scap-security-guide{master}]$ tests/test_rule_in_container.sh --no-remove-machine-only --dontclean --logdir logs_bash --remediate-using bash --name ssg_test_suite --datastream build/ssg-sle15-ds.xml audit_rules_login_events Setting console output to log level INFO INFO - The base image option has been specified, choosing Podman-based test environment. INFO - Logging into logs_bash-4/test_suite.log WARNING - Nothing has been tested! Traceback (most recent call last): File "/home/jcerny/work/git/scap-security-guide/tests/automatus.py", line 511, in <module> main() File "/home/jcerny/work/git/scap-security-guide/tests/automatus.py", line 507, in main options.func(options) File "/home/jcerny/work/git/scap-security-guide/tests/ssg_test_suite/rule.py", line 689, in perform_rule_check checker.test_target() File "/home/jcerny/work/git/scap-security-guide/tests/ssg_test_suite/oscap.py", line 683, in test_target self._test_target() File "/home/jcerny/work/git/scap-security-guide/tests/ssg_test_suite/rule.py", line 458, in _test_target self._prepare_environment(test_content_by_rule_id) File "/home/jcerny/work/git/scap-security-guide/tests/ssg_test_suite/rule.py", line 275, in _prepare_environment self._ensure_package_present_for_all_scenarios(test_content_by_rule_id) File "/home/jcerny/work/git/scap-security-guide/tests/ssg_test_suite/rule.py", line 265, in _ensure_package_present_for_all_scenarios common.install_packages(self.test_env, packages_to_install) File "/home/jcerny/work/git/scap-security-guide/tests/ssg_test_suite/common.py", line 592, in install_packages platform = cpes_to_platform([platform_cpe]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jcerny/work/git/scap-security-guide/tests/ssg_test_suite/common.py", line 623, in cpes_to_platform raise ValueError(msg) ValueError: Unable to deduce a platform from these CPEs: ['cpe:/o:suse:sles:15:sp5'] ```
Refactor the code to have less return statements in a function and reduce cognitive complexity.
Reduce code complexity
I was fixing this as part of an old open pull request: ad31112 But your solution is cleaner and improves the code. I will discard that commit and rebase on top of this when it gets merged. |
Code Climate has analyzed commit 6d0a593 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 53.8% (0.0% change). View more on Code Climate. |
This commit tries to fix a traceback that happens when evaluating a SLE15 data stream on a container back end when the test scenarios require to install a package into the back end.
Resolves: