Skip to content

Add policy support for DELETE operations #628

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chandrasekharmalladi
Copy link

@chandrasekharmalladi chandrasekharmalladi commented Jun 4, 2025

Summary

This change extends the core Rego library to support safely handling input.review.oldObject, and input.review.operation.

Details

  • Updates resource to use:

    • input.review.object if present
    • fallback to input.review.oldObject in case of DELETE operations.
  • Adds logic to expose core.operation using:

    • input.review.operation for Gatekeeper

Why

Gatekeeper policies for DELETE operations often need access to:

Example Use Case

A policy can now safely evaluate:

core.kind == "Namespace"
core.operation == "DELETE"

@chandrasekharmalladi chandrasekharmalladi changed the title Add support for DELETE operations Add policy support for DELETE operations Jun 4, 2025
@jalseth
Copy link
Collaborator

jalseth commented Jun 10, 2025

Thanks for the PR, but I have concerns about the impact. This has a high likelihood to break people's workflows if they are already using konstraint and don't care about DELETE operations. With this change, it would actually prevent people from deleting resources that violate policy.

@chandrasekharmalladi
Copy link
Author

Hey @jalseth, apologies for getting back late. Thank you for reviewing the MR. I see what you mean, I tested it and it indeed blocks people from deleting resources that violate the policy.

The workarounds I can think of would need all the "non-delete" examples to explicitly define the operation.

Are there any other ways you could recommend to solve this problem? I am trying to have some OPA policies to block deletion of some key resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants