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

fix: Enforce policy checks for overridden apply reqs #3960

Conversation

danielfm
Copy link
Contributor

@danielfm danielfm commented Nov 8, 2023

what

Keeps the policies_passed apply requirement for projects that override the apply requirements via the repo level atlantis.yaml file.

why

Without this change, projects that override the apply requirements via the repo level atlantis.yaml file do not include the policies_passed requirement even when policy checks is enabled, which ultimately allows bypassing policy checking approval when a policy fails and at least 1 approval is required.

I believe this is a security issue, as many Atlantis installations use conftest policies to enforce security best practices or to protect against misuse, i.e. block the removal of critical resources, and it's expected that these policies are enforced when policy checks is enabled.

tests

Added two new unit tests, to ensure that:

  1. The project's overridden apply_requirements always include policies_passed if policy checks are enabled
  2. The project's overridden apply_requirements are kept as-is if policy checks are disabled

references

@danielfm danielfm requested a review from a team as a code owner November 8, 2023 01:56
@github-actions github-actions bot added the go Pull requests that update Go code label Nov 8, 2023
@danielfm danielfm changed the title Enforce policy checks for overriden apply reqs fix: Enforce policy checks for overriden apply reqs Nov 8, 2023
@danielfm danielfm marked this pull request as draft November 8, 2023 02:27
This new version only includes the 'policies_passed' req back if
policy checks are enabled for the project.
@danielfm danielfm marked this pull request as ready for review November 8, 2023 11:34
@danielfm
Copy link
Contributor Author

danielfm commented Nov 9, 2023

FYI I just tested this change in our environment, and it's now working as I would expect, that is, even when setting apply_requirements: [] for a project via the repo level atlantis.yml file, the policies are enforced if policy checks is enabled:

image

@danielfm danielfm changed the title fix: Enforce policy checks for overriden apply reqs fix: Enforce policy checks for overridden apply reqs Nov 9, 2023
@danielfm
Copy link
Contributor Author

danielfm commented Nov 9, 2023

@jamengual The spelling errors were corrected! 😄

@jamengual jamengual added waiting-on-review Waiting for a review from a maintainer conftest-policy labels Nov 15, 2023
@GenPage GenPage added this to the v0.27.0 milestone Dec 12, 2023
@GenPage GenPage added bug Something isn't working and removed waiting-on-review Waiting for a review from a maintainer labels Dec 12, 2023
@GenPage GenPage merged commit 95c5fe0 into runatlantis:main Dec 12, 2023
24 checks passed
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Enforce policy checks for overriden apply reqs

* Another take on the fix

This new version only includes the 'policies_passed' req back if
policy checks are enabled for the project.

* Fix test

* Fix comment

* Fix spelling

---------

Co-authored-by: PePe Amengual <[email protected]>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Enforce policy checks for overriden apply reqs

* Another take on the fix

This new version only includes the 'policies_passed' req back if
policy checks are enabled for the project.

* Fix test

* Fix comment

* Fix spelling

---------

Co-authored-by: PePe Amengual <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working conftest-policy go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

policies_passed requirement removed when overriden in repo level configuration
3 participants