-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(terraform): Mask secret values in Terraform plan file reports by…
… resource (#3868) * add test * update set with list[str] * typing * linting * add secret based test * aws provider multi secret test * Update checkov/common/util/secrets.py Co-authored-by: Anton Grübel <[email protected]> * code improvements * code improvements * code improvements * add resources to censor * dict to Dict * typing Co-authored-by: Anton Grübel <[email protected]>
- Loading branch information
Showing
5 changed files
with
165 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from checkov.common.util.secrets import omit_secret_value_from_checks | ||
from checkov.common.models.enums import CheckResult | ||
from checkov.terraform.checks.resource.azure.SecretExpirationDate import SecretExpirationDate | ||
from checkov.terraform.checks.provider.aws.credentials import AWSCredentials | ||
|
||
|
||
def test_omit_secret_value_from_checks_by_attribute(tfplan_resource_lines_with_secrets, tfplan_resource_config_with_secrets, | ||
tfplan_resource_lines_without_secrets): | ||
check = SecretExpirationDate() | ||
check.entity_type = 'azurerm_key_vault_secret' | ||
check_result = {'result': CheckResult.FAILED} | ||
resource_attributes_to_omit = {'azurerm_key_vault_secret': 'value'} | ||
|
||
assert omit_secret_value_from_checks(check, check_result, tfplan_resource_lines_with_secrets, | ||
tfplan_resource_config_with_secrets, resource_attributes_to_omit | ||
) == tfplan_resource_lines_without_secrets | ||
|
||
|
||
def test_omit_secret_value_from_checks_by_secret(aws_provider_lines_with_secrets, aws_provider_config_with_secrets, | ||
aws_provider_lines_without_secrets): | ||
check = AWSCredentials() | ||
check_result = {'result': CheckResult.FAILED} | ||
|
||
assert omit_secret_value_from_checks(check, check_result, aws_provider_lines_with_secrets, | ||
aws_provider_config_with_secrets | ||
) == aws_provider_lines_without_secrets |