Skip to content
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

extend misleading Automatus error message #11658

Merged

Conversation

vojtapolasek
Copy link
Collaborator

Description:

  • The error message is extended and the oscap output is appended

Rationale:

  • The condition checks that the output does not contain the rule id. This can mean that the rule has not been selected. But it can mean also other errors, e.g. there has been problem starting evaluation.

I think this manifests also here: #10895

Review Hints:

I managed to reproduce it by editing /etc/nsswitch.conf, removing all lines starting with "passwd" and replacing them with:

passwd nis

This is invalid on RHEL 9 and mostly on RHEL 8. It seems this prevents oscap-ssh from logging in and the error message is encountered.

@vojtapolasek vojtapolasek added bugfix Fixes to reported bugs. Test Suite Update in Test Suite. labels Mar 6, 2024
@vojtapolasek vojtapolasek added this to the 0.1.73 milestone Mar 6, 2024
@vojtapolasek
Copy link
Collaborator Author

Please @matusmarhefka or @mildas have look at this, maybe you will have a better solution.

Copy link

github-actions bot commented Mar 6, 2024

Start a new ephemeral environment with changes proposed in this pull request:

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

Copy link

github-actions bot commented Mar 6, 2024

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:11658
This image was built from commit: eacecbf

Click here to see how to deploy it

If you alread have Compliance Operator deployed:
utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:11658

Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and:
CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:11658 make deploy-local

The condition checks that the output does not contain the rule id.
This can mean that the rule has not been selected.
But it can mean also other errors, e.g. there has been problem starting evaluation.
@vojtapolasek vojtapolasek force-pushed the fix_automatus_misleading_mesage branch from 4ca33ec to 422cbd7 Compare March 11, 2024 09:40
Copy link

codeclimate bot commented Mar 12, 2024

Code Climate has analyzed commit eacecbf 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 59.8% (0.0% change).

View more on Code Climate.

@jan-cerny jan-cerny self-assigned this Mar 12, 2024
Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reproduced the problem by breaking the tested data stream by changing the value of @test_ref in the OVAL definition in my favorite rule. This triggered your improved message. It no longer points people to a wrong direction concerning the profile which is in practice unlikely to happen. Also, I really love that it points me to the right log.

jcerny@fedora:~/work/git/scap-security-guide (pr/11658)$ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 --scenario selinux_enforcing.pass.sh selinux_state
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2024-03-12-1145/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_selinux_state
ERROR - Script selinux_enforcing.pass.sh using profile xccdf_org.ssgproject.content_profile_ospp found issue:
ERROR - Rule xccdf_org.ssgproject.content_rule_selinux_state has not been evaluated! Wrong profile selected in test scenario or there has been problem starting the evaluation. Please inspect the log file /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2024-03-12-1145/selinux_state-selinux_enforcing.pass.sh-initial.verbose.log for details.
ERROR - The initial scan failed for rule 'xccdf_org.ssgproject.content_rule_selinux_state'.
jcerny@fedora:~/work/git/scap-security-guide (pr/11658)$ cat /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2024-03-12-1145/selinux_state-selinux_enforcing.pass.sh-initial.verbose.log
Warning: Permanently added '192.168.124.235' (ED25519) to the list of known hosts.
I: oscap: Identified document type: data-stream-collection [oscap(2070):oscap(7f0358df7940):doc_type.c:96:oscap_determine_document_type_reader]
I: oscap: Created a new XCCDF session from a SCAP Source Datastream '/tmp/tmp.LXPFPqJLYF/input.xml'. [oscap(2070):oscap(7f0358df7940):xccdf_session.c:179:xccdf_session_new_from_source]
D: oscap: Validating SCAP Source Datastream (1.3) document from /tmp/tmp.LXPFPqJLYF/input.xml. [oscap(2070):oscap(7f0358df7940):oscap_source.c:360:oscap_source_validate]
OpenSCAP Error: File '/tmp/tmp.LXPFPqJLYF/input.xml' line 65535: Element '{http://oval.mitre.org/XMLSchema/oval-definitions-5}criterion': No match found for key-sequence ['oval:ssg-test_etc_selinux_config:tst:2'] of keyref '{http://oval.mitre.org/XMLSchema/oval-definitions-5}testKeyRef'.
 [/builddir/build/BUILD/openscap-1.3.8/src/XCCDF/xccdf_session.c:726]
Invalid SCAP Source Datastream (1.3) content in /tmp/tmp.LXPFPqJLYF/input.xml. [/builddir/build/BUILD/openscap-1.3.8/src/source/oscap_source.c:363]
Invalid SCAP Source Datastream (1.3) content in /tmp/tmp.LXPFPqJLYF/input.xml [/builddir/build/BUILD/openscap-1.3.8/src/XCCDF/xccdf_session.c:839]
scp: /tmp/tmp.LXPFPqJLYF/results-arf.xml: No such file or directory
Failed to copy the ARF file back to local machine!
jcerny@fedora:~/work/git/scap-security-guide (pr/11658)$ 


@jan-cerny jan-cerny merged commit c0ed7ee into ComplianceAsCode:master Mar 12, 2024
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes to reported bugs. Test Suite Update in Test Suite.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants