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

Add alternatives to mandatory keys #11268

Conversation

yuumasato
Copy link
Member

@yuumasato yuumasato commented Nov 10, 2023

Description:

  • Don't require profiles to have selections if they have an extends.

Rationale:

  • The OCP profiles aim to have versioned profiles and non-versioned profiles, with the non-versioned profiles being used as the profile for anyone who wants to automatically "roll over" to the latest version when new versions are added.:
    Add profile aliases for OpenShift versioned profiles #11241
  • This allows a profile to just extend another one without having to add any selection. Making it possible to have non-versioned profiles extend versioned profiles.
  • Profiles with no rules selected (that unselect all groups) are already caught by the build system.

Review Hints:

  • Add an extends to any profile and remove the whole selections key.
  • Check the linked PR for reference.

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

@jan-cerny jan-cerny self-assigned this Nov 10, 2023
@jan-cerny jan-cerny added this to the 0.1.71 milestone Nov 10, 2023
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 tried this and it works for me as expected 👍

msg = "Profile {0} unselects all groups.".format(self.id_)
msg = ("Profile {0} unselects all groups. "
"Check whether it selects any rule or extends any profile."
.format(self.id_))
Copy link
Collaborator

Choose a reason for hiding this comment

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

please fix indentation

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the review, should be fixed now.

@yuumasato yuumasato force-pushed the allow_extends_in_place_of_selections branch from cd8b25b to 58eea27 Compare November 10, 2023 12:59
@@ -55,6 +55,10 @@ class Profile(XCCDFEntity, SelectionHandler):
"selections",
Copy link
Member Author

@yuumasato yuumasato Nov 10, 2023

Choose a reason for hiding this comment

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

@jan-cerny Another approach would be to remove selections from MANDATORY_KEYS, I don't think this would open gaps that could lead to problems. But the ALTERNATIVE_KEYS seem to guard and lead better to what is expected.

Don't require profiles to have 'selections' if they have an 'extends'.

This allows a profile to just extend a profile without having to add
any selection. Making it possible to have non-versioned profiles to
extend versioned profiles.
@yuumasato yuumasato force-pushed the allow_extends_in_place_of_selections branch from 58eea27 to 521a4dc Compare November 10, 2023 13:38
Copy link

codeclimate bot commented Nov 10, 2023

Code Climate has analyzed commit 521a4dc and detected 0 issues on this pull request.

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

This pull request will bring the total coverage in the repository to 58.8%.

View more on Code Climate.

@jan-cerny jan-cerny merged commit 422606f into ComplianceAsCode:master Nov 13, 2023
33 of 34 checks passed
@yuumasato yuumasato deleted the allow_extends_in_place_of_selections branch November 13, 2023 11:04
@Mab879 Mab879 added the Infrastructure Our content build system label Nov 15, 2023
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.

3 participants