Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2020580

Summary: [RFE] Allow specifying --exclude-rules to evaluate all rules in a profile except some
Product: Red Hat Enterprise Linux 9 Reporter: Jan Pazdziora (Red Hat) <jpazdziora>
Component: openscapAssignee: Jan Černý <jcerny>
Status: CLOSED ERRATA QA Contact: Matus Marhefka <mmarhefk>
Severity: low Docs Contact:
Priority: medium    
Version: 9.0CC: jpazdziora, mhaicman, mmarhefk
Target Milestone: rcKeywords: AutoVerified, FutureFeature, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openscap-1.3.6-2.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 13:04:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Pazdziora (Red Hat) 2021-11-05 10:23:27 UTC
Description of problem:

When working with SCAP profiles, especially when debugging or testing them in automated fashion, it is often desirable to evaluate or remediate all rules in the profile, except for a small list of rules that are bound to yield the system inoperable for that specific purpose.

For example, one might want to remediate with the full OSPP profile but exclude the xccdf_org.ssgproject.content_rule_sshd_disable_root_login rule because otherwise they might no longer be able to log into that testing machine.

It'd be useful to have an option like --exclude-rules to use all rules in the profile but those listed.

Version-Release number of selected component (if applicable):

openscap-scanner-1.3.5-8.el9.s390x

How reproducible:

Deterministic.

Steps to Reproduce:
1. Try to run
   oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_ospp  /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
   but avoid some rules.

Actual results:

Customized / tailored profile needs to be created per 

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/security_hardening/scanning-the-system-for-configuration-compliance-and-vulnerabilities_security-hardening#scanning-the-system-with-a-customized-profile-using-scap-workbench_scanning-the-system-for-configuration-compliance-and-vulnerabilities

using GUI tool.

Expected results:

A quick, command-line way of excluding some rules from the evaluation is provided.

Additional info:

Comment 2 Jan Černý 2021-11-05 11:25:21 UTC
As a workaround there is the "autotailor" utility which can be used to create the tailoring file on the command line.

Comment 3 Jan Pazdziora (Red Hat) 2021-11-14 13:18:26 UTC
Thanks for the pointer. Quickly checking the man page and the --help output, I came up with

# autotailor -u xccdf_org.ssgproject.content_rule_grub2_uefi_password /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml xccdf_org.ssgproject.content_profile_ospp > tailor.xml
# oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_ospp tailor.xml

but that gave me

OpenSCAP Error: Unable to open file: './file:///usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml' [/builddir/build/BUILD/openscap-1.3.5/src/source/oscap_source.c:288]
Unable to open file: './file:///usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml' [/builddir/build/BUILD/openscap-1.3.5/src/source/oscap_source.c:288]
Unable to open file: './file:///usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml' [/builddir/build/BUILD/openscap-1.3.5/src/source/oscap_source.c:288]
Unable to open file: './file:///usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml' [/builddir/build/BUILD/openscap-1.3.5/src/source/oscap_source.c:288]
Unable to open file: './file:///usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml' [/builddir/build/BUILD/openscap-1.3.5/src/source/oscap_source.c:288]
Unrecognized document type for: ./file:///usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml [/builddir/build/BUILD/openscap-1.3.5/src/source/oscap_source.c:341]
Unable to open file: './file:///usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml' [/builddir/build/BUILD/openscap-1.3.5/src/source/oscap_source.c:288]
Unable to open file: './file:///usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml' [/builddir/build/BUILD/openscap-1.3.5/src/source/oscap_source.c:288]
Invalid (null) ((null)) content in ./file:///usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml [/builddir/build/BUILD/openscap-1.3.5/src/XCCDF/xccdf_session.c:713]

Is that expected or a bug?

Comment 4 Marek Haicman 2022-01-07 17:53:40 UTC
Hello Jan,
the omission is in the second command. The tailoring file is not the right source, and the command that works is:
oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_ospp --tailoring-file tailor.xml /usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml

So the behavior is not a bug, but I understand the output you've got is not very user friendly, nor guiding you the right way.

Comment 5 Jan Černý 2022-01-11 10:12:53 UTC
There is a PR opened in upstream in https://github.com/OpenSCAP/openscap/pull/1832

Comment 6 Jan Černý 2022-01-20 09:59:07 UTC
https://github.com/OpenSCAP/openscap/pull/1832

Comment 15 errata-xmlrpc 2022-05-17 13:04:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: openscap), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2449