cloudformation-guard icon indicating copy to clipboard operation
cloudformation-guard copied to clipboard

[Enhancement] Unit test shoud support invoking a rule that has an argument

Open fabiodouek opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe.

I'm creating cfn-guard rules for evaluating Resource Policies. I will use these rules from different entry points: CloudFormation and AWS Config. This means that the extraction path from these two use cases will be different. However the Resource policy evaluation on the statements will be the exact same. For this reason I've created rules with arguments to evaluate the policy.

However, I'm not able to do unit tests on rules that expect an argument.

Describe the solution you'd like

In the unit test file, I would like to be able to specify the argument, where this will be the value in the input. A nice feature would be if we could specify the extraction path such as $this/PolicyDocument

expectations: rules: check_principal_deny($this)

Describe alternatives you've considered

The alternative at the moment is to have tests duplicated from different extraction points, which makes hard to unit test and maintain it

fabiodouek avatar Feb 19 '23 12:02 fabiodouek

Hi @fabiodouek thanks for creating this issue. This is a solid idea. We will continue to track this and update it when appropriate.

Thanks

joshfried-aws avatar Jul 18 '23 14:07 joshfried-aws