cloudposse-archives / tfmask

Terraform utility to mask select output from `terraform plan` and `terraform apply`
https://cloudposse.com/accelerate
Apache License 2.0
202 stars 27 forks source link

Supported Colors and Terraform 12 JSON diff secrets masking #21

Closed mnatan closed 4 months ago

mnatan commented 4 years ago

Credit to @1n for figuring out a way of stripping ANSI colours and diffing.

We are using this project with terraform-provider-helmfile. It tends to generate big diffs with JSON and YAML files pretty printed and we sometimes see secrets leaking to the screen.

To support masking these cases we decided to just detect secrets with regex on ANSI-stripped terraform output and saving them to a new genericMatch structure.

It contains a list of confidential strings, that are then masked in ANSI-colored output before we print it out to the screen.

The whole codebase can be adapted to this approach, however due to time constraints, I was unable to do so.

osterman commented 4 years ago

This looks great!

Ugh, looks like when I wrote the github action I forgot to actually run the tests. :/

Any chance you can add that? Otherwise, I'll have @aknysh take a look.

mnatan commented 4 years ago

Hey @osterman, I'm super swamped with deployments right now. Happy to review though.

aknysh commented 4 years ago

@mnatan thanks for the PR, please rebase

mnatan commented 4 years ago

@aknysh rebased

connorlwilkes commented 4 years ago

This is really useful when using with Helmfile provider. Would be good if it can be merged soon if it looks good 👍