diff --git a/dist/bash_completion.d/oscap b/dist/bash_completion.d/oscap index 1b237ffdce..7e86bc5f68 100644 --- a/dist/bash_completion.d/oscap +++ b/dist/bash_completion.d/oscap @@ -39,7 +39,7 @@ function _oscap { opts[oscap:xccdf:generate:guide]="-o --output --hide-profile-info --profile --benchmark-id --xccdf-id --tailoring-file --tailoring-id --skip-signature-validation --enforce-signature" opts[oscap:xccdf:generate:fix]="-o --output --profile --result-id --profile --fix-type --xccdf-id --benchmark-id --tailoring-file --tailoring-id --skip-signature-validation --enforce-signature" opts[oscap:xccdf:generate:custom]="-o --output --stylesheet" - opts[oscap:info]="--fetch-remote-resources --local-files --profile --profiles --references" + opts[oscap:info]="--fetch-remote-resources --local-files --profile --profiles --references --list-rules --list-vars" # local variables local std cmd i prev diff --git a/docs/manual/manual.adoc b/docs/manual/manual.adoc index 8ae1685900..ef03bb7fb8 100644 --- a/docs/manual/manual.adoc +++ b/docs/manual/manual.adoc @@ -217,6 +217,39 @@ description, use the `--profile` option followed by the profile ID. $ oscap info --profile xccdf_org.ssgproject.content_profile_ospp /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml ---- +=== Listing rules selected by a profile + +To list the IDs of all XCCDF rules that are selected by a given profile, use +the `--list-rules` option together with `--profile`. The output contains one +rule ID per line and is machine-readable, which makes it suitable for scripting, +CI/CD pipelines, and tailoring validation workflows. + +---- +$ oscap info --profile ospp --list-rules /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml +xccdf_org.ssgproject.content_rule_partition_for_tmp +xccdf_org.ssgproject.content_rule_partition_for_var +... +---- + +The `--list-rules` option requires `--profile`. Running `--list-rules` without +`--profile` will produce an error. + +=== Listing variables set by a profile + +To list the XCCDF Values (variables) and their resolved values for a given +profile, use the `--list-vars` option together with `--profile`. Each line +contains a Value ID and its resolved value, separated by a tab character. + +---- +$ oscap info --profile ospp --list-vars /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml +xccdf_org.ssgproject.content_value_var_password_minlen 15 +xccdf_org.ssgproject.content_value_var_accounts_max_concurrent_login_sessions 10 +... +---- + +The `--list-vars` option requires `--profile`. Running `--list-vars` without +`--profile` will produce an error. + === Displaying information about SCAP result data streams The `oscap info` command is also helpful with other SCAP file types such as diff --git a/tests/API/XCCDF/unittests/test_reference_ds.xml b/tests/API/XCCDF/unittests/test_reference_ds.xml index c2bacf0704..863494bbb9 100644 --- a/tests/API/XCCDF/unittests/test_reference_ds.xml +++ b/tests/API/XCCDF/unittests/test_reference_ds.xml @@ -67,7 +67,19 @@ + + + + + + + +