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(secrets): Add Terraform multiline secrets handling #3907

Merged
merged 6 commits into from
Nov 22, 2022

Conversation

gruebel
Copy link
Contributor

@gruebel gruebel commented Nov 21, 2022

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

Description

  • added a new multiline parser for Terraform hcl files
  • since Terraform can leverage heredoc and can have embedded JSON or YAML in it, I iterate over the possible multiline parser
  • added a method to ignore secrets, which are related to a data block

Fixes #1660

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

Copy link
Contributor

@Eliran-Turgeman Eliran-Turgeman left a comment

Choose a reason for hiding this comment

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

🔥

Copy link
Contributor

@marynaKK marynaKK left a comment

Choose a reason for hiding this comment

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

Looks great! :) 🚀 🍒

and we need to move the other 2 parsers to join your terraform parser in the same folder :)

checkov/secrets/parsers/terraform/multiline_parser.py Outdated Show resolved Hide resolved
checkov/secrets/parsers/terraform/multiline_parser.py Outdated Show resolved Hide resolved
return False


def ignore_secret(
Copy link
Contributor

@marynaKK marynaKK Nov 21, 2022

Choose a reason for hiding this comment

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

If we add a mechanism for ignoring some data- maybe it can be added to a new file of single line parser (like there is a multiline parser)?
that's the same as skipping comments, but in this case, that's skipping specific blocks with data as a prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, that was my problem, it is related to a specific file type, but I was not sure, if it is a good idea to add it to the multi parser, but I will revisit it 🤔

checkov/secrets/plugins/ignore_secret.py Outdated Show resolved Hide resolved
@gruebel gruebel merged commit 2ee3c09 into bridgecrewio:master Nov 22, 2022
@gruebel gruebel deleted the add-tf-multiline-secrets branch November 22, 2022 17:46
gruebel added a commit to gruebel/checkov that referenced this pull request Nov 22, 2022
…#3907)

* add multiline secret support in Terraform

* support jsonencode and heredoc and ignore data blocks

* fix PR comments

* create a dedicated single line parser class

* add buildx step to build the image on self-hosted runners
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.

False positive for CKV_SECRET_6 for google_secret_manager_secret_version resources
3 participants