Skip to content

Added dry-run parameter on policy methods #51

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

markri
Copy link

@markri markri commented Feb 28, 2025

Desired Outcome

There is no way on checking a policy file with the dryRun option using the Python API.

Feature described here:
https://docs.cyberark.com/conjur-enterprise/latest/en/content/operations/policy/policy-verify.html#APIvalidateparameter

This PR adds the functionality with backwards compatibility. So that we can call any policy method with an extra dry_run parameter in order to have the policy only checked

Implemented Changes

  • An extra dry_run parameter is added in the Client class. And since this is a facade to the Api Class, it is implemented there as well.
  • The default is set to False (to maintain backwards compatibility, and only in the Client class
  • The Api class method _load_policy_file is changed to support the dry_run parameter and based on this it will create a query dictionary which is added to the invoke_endpoint request

Test coverage

No additional tests are added, as this seems trivial. Plus I don't want to put in that much effort as this repository seems to be in limbo? I'll be happy to create one if there a real demand for it, and when it is actually going to be merged, but right now I just want to contribute some inspiration for others.

Also we're not really blocked by it, as we use this exact logic in extended classes of Client and API

@szh
Copy link
Contributor

szh commented Mar 28, 2025

Hi,
Thank you for your PR! This repo is absolutely still maintained and we're renewing our effort in responding to our community in a more timely manner. We will be reviewing this PR but if you could add tests that would certainly speed up the process.

One thing to note however is that since dry run is a new feature, and the query parameter will be ignored in older versions of Conjur (as well as Conjur Cloud for now), there's the risk of performing destructive actions accidentally when calling this method on those versions of Conjur. You can see how we dealt with this in conjur-api-go.

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

Successfully merging this pull request may close these issues.

2 participants