Skip to content
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

feat(terraform): Censor secrets from tfplan graph #3894

Merged
merged 2 commits into from
Nov 16, 2022
Merged

Conversation

arielkru
Copy link
Contributor

@arielkru arielkru commented Nov 16, 2022

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Description

Follows the changes in #3868, and adds the masking of the values to the graph in addition to the reports and checks metadata

We want secret values to be masked from graphs as well as from reports. This change checks for every tfplan definitions if they include secrets, by the resource attributes to omit mapping, and creates a censored version of the definitions as input for the graph creation if needed.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my feature, policy, or fix is effective and works
  • New and existing tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

checkov/common/util/secrets.py Outdated Show resolved Hide resolved
checkov/common/util/secrets.py Outdated Show resolved Hide resolved
Comment on lines +179 to +184
if not found_secrets:
found_secrets = True
# The values in self.definitions shouldn't be changed so that checks' results
# of checks that rely on the definitions values are not affected.
# Hence, if secrets are found, we should censor them in a deep copy of self.definitions
censored_definitions = copy.deepcopy(definitions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 🥇

@arielkru arielkru merged commit e334f2f into master Nov 16, 2022
@arielkru arielkru deleted the censor_tfplan_graph branch November 16, 2022 14:50
gruebel pushed a commit to gruebel/checkov that referenced this pull request Nov 16, 2022
* censor secrets from tfplan graph

* antons's improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants