tfmask icon indicating copy to clipboard operation
tfmask copied to clipboard

Supported Colors and Terraform 12 JSON diff secrets masking

Open mnatan opened this issue 4 years ago • 5 comments

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.

mnatan avatar Aug 06 '20 12:08 mnatan

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.

osterman avatar Aug 12 '20 06:08 osterman

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

mnatan avatar Aug 12 '20 14:08 mnatan

@mnatan thanks for the PR, please rebase

aknysh avatar Aug 12 '20 19:08 aknysh

@aknysh rebased

mnatan avatar Aug 13 '20 10:08 mnatan

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

connorlwilkes avatar Aug 26 '20 14:08 connorlwilkes