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

Automated Reference Assignment: Allow Skippping of Controls #11630

Conversation

yuumasato
Copy link
Member

@yuumasato yuumasato commented Feb 27, 2024

Description:

  • Add a new key that allows Controls to be skipped from automated "referencing" during build.

Rationale:

Review Hints:

  • Build content before and after PR and check that STIG needed_rules references are gone.

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

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

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

@yuumasato
Copy link
Member Author

@Mab879 @jan-cerny If the needed_rules reference is actually there by design I can drop the second commit.
I would still like to leverage the skip_reference in OCP4 STIG profile.

Add a new key to tag controls that should not be added as a reference
during build.
These rules are not directly tied to a STIG ID.
Plus, the string 'needed_rules' was being added as a STIG reference.
@yuumasato yuumasato force-pushed the feature_control_skip_auto_referencing branch from 16f6944 to 99eb3fc Compare February 27, 2024 17:03
@yuumasato yuumasato added RHEL9 Red Hat Enterprise Linux 9 product related. STIG STIG Benchmark related. labels Feb 27, 2024
@Mab879 Mab879 added this to the 0.1.73 milestone Feb 27, 2024
@Mab879 Mab879 added the Infrastructure Our content build system label Feb 27, 2024
@Mab879 Mab879 self-assigned this Feb 27, 2024
@Mab879
Copy link
Member

Mab879 commented Feb 27, 2024

We will need to figure out what we want to do about the missing refs test. Do want to somehow add a exclude list?

@jan-cerny
Copy link
Collaborator

I don't have a strong opinion.

I can imagine the situation in which the reference to a dummy control would be useful. Remember that the users don't have access to the control files, they only use the data stream. If they review the profile eg. in HTML guide they will see that all rules have a reference to the STIG policy except this one so they might wonder if the rule is there by mistake. So in that case a reference to the dummy control could be a helpful information.

If you decide to remove it please add a whitelist as Matthew suggested.

@xiaojiey
Copy link
Collaborator

/hold for test

@openshift-ci openshift-ci bot added the do-not-merge/hold Used by openshift-ci-robot bot. label Feb 29, 2024
@yuumasato
Copy link
Member Author

I don't have a strong opinion.

I can imagine the situation in which the reference to a dummy control would be useful. Remember that the users don't have access to the control files, they only use the data stream. If they review the profile eg. in HTML guide they will see that all rules have a reference to the STIG policy except this one so they might wonder if the rule is there by mistake. So in that case a reference to the dummy control could be a helpful information.

Still, as you mentioned, the user doesn't have access to the control file, only the data stream. So listing a dummy control in the rule can be confusing too.

@yuumasato
Copy link
Member Author

yuumasato commented Feb 29, 2024

@jan-cerny By the way, these "needed rules" could also be directly selected in rhel9/profiles/stig.profile. What are your thoughts on that?
Some of the OCP4 profiles do that for "needed rules":

### This is a helper rule to fetch the required api resource for detecting OCP version
- version_detect_in_ocp
- version_detect_in_hypershift

This approach will still trigger "missing references" failures though.
Maybe expecting that all rules in a "referenced" profile have the reference is too much?
And we need to allow for exceptions...

@jan-cerny
Copy link
Collaborator

I think adding there the exception list would be great.

Maybe expecting that all rules in a "referenced" profile have the reference is too much?

So for some profile we expect this and we had the test for years. This expectation is easy and consistent.

@yuumasato
Copy link
Member Author

yuumasato commented Mar 5, 2024

@jan-cerny We have moved the rules that don't support a STIG ID out of the control file into the profile file.
So we don't have the need for the skip_reference key anymore.

If you are not interested in this feature we can close the PR.

I think adding there the exception list would be great.

I gave it some thought and am curious how you would implement this.
The test only looks at the built data stream, it doesn't look at the source, and this okay, it makes sense to me.
I see a few ways this test could have an exception list:

  1. By breaking this concept and making the test aware of a product's profile and the source control used by them to check which controls skipped auto-referencing during build.
    I'm not sure it is worth it to add all this product/profile/control parsing logic to this test.
  2. By maintaining a matrix of rules per product per profile that can miss a certain reference.
    This approach also seems error prone and will require constant maintenance with profile updates.
  3. A plain hard coded list of rules that are okay missing any type of references in any profile/product.
    From what I could check, for RHEL only dconf_db_up_to_date and enable_authselect are extraneous in the control file.
    This may lead to errors where listed rules may be missing valid references.

@jan-cerny
Copy link
Collaborator

It would have to be a hardcoded list of tuples (rule, product, profile).

I assume that these rules are an exception and not something that should be there on a large scale.

@Mab879 Mab879 removed their assignment Mar 7, 2024
@yuumasato
Copy link
Member Author

@jan-cerny I'm sorry but I won't have the time to pursue this. I'm closing the PR, feel free to reuse the commit.

@yuumasato yuumasato closed this Mar 15, 2024
@Mab879 Mab879 removed this from the 0.1.73 milestone May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Used by openshift-ci-robot bot. Infrastructure Our content build system RHEL9 Red Hat Enterprise Linux 9 product related. STIG STIG Benchmark related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants