-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
chore(terraform): hook into evaluateStep behavior with custom hooks #8302
base: main
Are you sure you want to change the base?
Conversation
@nikpivkin I did see those options. I had considered seeing if those presets could be added in as hooks. I am also unsure if I can make my provider block implementation purely in the context of terraform. I am working with the coder/coder provider. Specifically In terraform, the user defined values are passed in as environment variables. For the presets block, I do not like the idea of using You can see the hook I made here: https://github.com/Emyrk/terraform-eval/blob/4d10683c15ecf202a4fa1377dd9ddc7d331f5dac/engine/coderism/extract.go#L46-L81
I appreciate the fast feedback on my PRs and thoughts. Your package is pretty amazing that I can evaluate the language without having to run a As you are likely aware, the terraform language is behind |
@nikpivkin, @simar7 any updated thoughts? I am happy to explore other methods to accomplish this. I am hoping this is the last change (:crossed_fingers:) to fully enable my use case using this as a library over some others. |
evaluateStep handles many terraform semantics such as default values for 'variables'. A hook into these steps allows defining additional semantics, likely to mirror those of the actual provider implementation.
b29168c
to
11c279f
Compare
hi @Emyrk sorry for the late response. While I like the idea you have, I'm not sure how beneficial it is to the Trivy project. As for my thoughts on making Certainly open to ideas. |
If it adds any value, if the project I am working on adopts trivy's tf parsing as the underlying library, we are happy to add our resources to maintaining the common overlap. The being the evaluation of the terraform.
I do understand, and do not intend to drift from the primary purpose of the package. I admit I am still in the evaluating stage of things, so if my use case is not an intended case, I understand if I have to look elsewhere. If it's possible and not too much work, a simple |
@simar7 apologies to keep bringing this up. If I back up a little bit, and define the things I am trying to solve, maybe it would be easier to determine if these features have a place in this library. The two things I am trying to do:
|
Description
Let me know if I am missing some other means to make this work
evaluateStep handles many terraform semantics such as default values for 'variables'. A hook into these steps allows defining additional semantics, likely to mirror those of the actual provider implementation.
This must be done in
evaluateStep
, as things such asexpandBlocks
occur afterwards. Without this hook, theExpandBlock
must be called manually outside of the executor.Conversation
Calling
ExpandBlock
outside is ok, however I wonder if callingEvaluateStep
again is required in order to be correct.EvaluateSteps
is called here afterExpandBlocks
https://github.com/aquasecurity/trivy/blob/main/pkg/iac/scanners/terraform/parser/evaluator.go#L145
Hence why this hook was added. To place similar semantic code to variable defaults in the same spot.
Checklist