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

Test that all rules have references #11610

Merged
merged 18 commits into from
Feb 26, 2024

Conversation

jan-cerny
Copy link
Collaborator

Description:

Extend existing CTest tests "missing-references-ssg-${PRODUCT}-ds.xml". We will use it to test references that are automatically added to rules based on data from control files. The test checks that all rules in given profiles have a reference of the given type.

The test will now test references added from the following control files:

  • controls/anssi.yml
  • controls/ccn_rhel9.yml
  • controls/cis_rhel7.yml
  • controls/cis_rhel8.yml
  • controls/cis_rhel9.yml
  • controls/pcidss_4.yml
  • controls/stig_rhel9.yml

Rationale:

Ensures that references from control files are propagated to the rules in the built SCAP source data stream. Provides an integration test for #11540.

Review Hints:

Build product, open the built data stream and remove some reference elements from your favorite rules. Then run this test, eg. ctest --verbose -R missing-references-ssg-rhel9-ds.xml.

The constants.xslt in the `eks` product is the only product-specific
constants XSLT file file that defines the variable `disa-stigs-uri`.
Other products don't define this variable. But, this product doesn't
have a STIG profile. So I think we can remove this variable. The
definition of this variable seems to be a copy paste problem, from other
products it was removed.
The XSLT variable `disa-stigs-uri` has been removed completely
which made this part of the code useless.
There is no reason to store the variable into the object
because it's just renaming the imported constant. Let's
decrease the confusion.
The variable `generic_stig_ns` isn't used anywhere.
The option `--missing-stig-ids` is actually checking the references
that are represented using `stigref` key in references in resolved
rule YAML files. The naming of the option makes a confusion with
`stigid` references. Therefore, we will rename the option to
`--missing-stigref-refs` which will align this option name with
the other options of this script, eg.` --missing-anssi-refs` is
checking for missing `anssi` references in rules so
`--missing-stigref-refs` will check for missing `stigref` references
in rules.
This commit extends the CTest test missing-references-ssg-rhel9-ds.xml
to verify that all rules in the RHEL 9 STIG profile in the data stream
have a `stigid` reference.
@jan-cerny jan-cerny added this to the 0.1.73 milestone Feb 20, 2024
Copy link

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

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:11610

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:11610

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

We don't need to rename the constant and we don't need to copy
it into the object instances.
This commit solves Code Climate problem that the RuleStats ctor
has too many parameters.
Instead of having a dictionary in the object the items of the
dictionary can be direct members of the class.
Copy link

codeclimate bot commented Feb 21, 2024

Code Climate has analyzed commit 46170d6 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Style 1

The test coverage on the diff in this pull request is 2.1% (50% is the threshold).

This pull request will bring the total coverage in the repository to 57.9% (-0.3% change).

View more on Code Climate.

@jan-cerny
Copy link
Collaborator Author

I don't want to solve the Code Climate problems

Copy link
Member

@Mab879 Mab879 left a comment

Choose a reason for hiding this comment

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

LGTM.

Thanks!

@Mab879 Mab879 merged commit 9ed3cd0 into ComplianceAsCode:master Feb 26, 2024
42 of 44 checks passed
@Mab879 Mab879 added the Infrastructure Our content build system label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Our content build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants