This message was deleted.
# atlantis-community
s
This message was deleted.
p
yes that is a Terraform problem
there is tools like tfsec that help on certain aspects of this
The state is a secret and it should be handled the same way
r
How would you even prevent this without using something like tfsec (as you already mentioned)
Maybe if the runner didn't require those env vars
p
and I will say
external
should not be allowed to run
šŸ‘ 2
ideally you will remove the installation of that provider
that is where you need to stop it
same as a dangerous package/dependency for any other language in the world, terraform is no different
utilities like Nexusx IQ, Snyk and other will alert you about the security concern for a python or java app
you can run checkov after init and fail if it finds something
and even before atlantis is triggered it fails the run
r
You can do it with a conftest policy too
I think there is a doc on the Atlantis website for exactly this use case
b
I think what Walter is aiming at, is that any person can just create a feature branch and add this to his feature branch, prep a PR and the data is exposed
checkov, tfsec, conftest could block this from getting merged - sure. But then it's already too late
Then again, good luck solving this...
This comes down to write permissions and securing your repositories the right way
p
That is not totally correct, if you commit code and for example use Github you can stop sending the webhook call to atlantis by checking with those tools
b
Hmm I was not aware of that PePe, how would that work? That's good to know actually
p
one of you github actions can check for the existance of certain providers and remove them from the code
r
Conftest can also block the code itself not just the plan
this 1
I use conftest today on the code
b
Do you have some reference material on how to prevent the auto plan (webhooks) from going off with conftest?
p
@RB can you remove provider with conftest? like if
external
is installed then remove and fail the evaluation?
b
I would happily contribute some docs to our 'Webooks' page in that case
look at that action
it call atlantis at the end, not via webhook
b
Ah... just a layer in between, I see
p
so then you run all your checks and then you send over
but @RB I think is mention that you can run this as a pre_workflow hook and check using onftest and opa rules
b
If only our conftest implementation could run before the auto plan too šŸ˜„
p
and that will happen before autoplan
b
Yeah that can work
Is it worth documenting a gotcha on the Webhooks page regarding pre_workflow hooks in order to prevent data exfiltration?
r
I run conftest part of the atlantis workflow on the code. If it errors on the code then the plan doesn't run. Just an alternative to consider
b
@Walter Vargas tldr; • You can use pre workflow hooks to prevent the plan from going off, by e.g. using conftest or tfsec • You can embed it into your own workflow, as @RB outlined above • You can also construct your own workflows that wrap around atlantis, see @PePe Amengual his answer Enough options available to prevent running arbitrary code šŸ™‚
šŸ‘ 1
s
If using pre-workflow hooks, don't forget to set fail-on-pre-workflow-hook-error.
šŸ‘ 1
r
Hmm how come that not just automatically enabled when using pre workflow hooks?
b
automatically turning it on and having a
continue-on-pre-workflow-hook-error
would be cleaner
to just overwrite it if you want to
s
That would be a breaking change on the current functionality though. I don't know why when the pre workflow hook was added, it wasn't made to fail the whole workflow on error... I added the
fail-on-pre-workflow-hook-error
in https://github.com/runatlantis/atlantis/pull/3729.
r
Oh interesting. Thanks for the background simon.
That might be a good thing to document beside the flag on the runatlantis website for future askers
s
r
I need to read the docs then haha. Thank you!