Check fails if you have different objects with the same name
See original GitHub issueDescribe the bug The checkov CLI has an exception if two objects share the same object and name. For some unknown reason we have a data and resource with the same names - one checking if an object exists, the other to make it.
data "aws_sns_topic" "this" {
count = "${(1 - var.create_sns_topic) * var.create}"
name = var.sns_topic_name
}
resource "aws_sns_topic" "this" {
count = var.create_sns_topic * var.create
name = var.sns_topic_name
}
checkov -d . Traceback (most recent call last): File “C:\Python37\Lib\site-packages\checkov\main.py”, line 55, in <module> run() File “C:\Python37\Lib\site-packages\checkov\main.py”, line 43, in run report = Runner().run(root_folder, external_checks_dir=args.external_checks_dir, files=file) File “C:\Python37\lib\site-packages\checkov\terraform\runner.py”, line 32, in run self.check_tf_definition(report, root_folder, tf_definitions) File “C:\Python37\lib\site-packages\checkov\terraform\runner.py”, line 60, in check_tf_definition block_type) File “C:\Python37\lib\site-packages\checkov\terraform\runner.py”, line 68, in run_block entity_context = dpath.get(definition_context[full_file_path], f’*/{entity_type}/{entity_name}') File “C:\Python37\lib\site-packages\dpath\util.py”, line 124, in get raise ValueError(“dpath.util.get() globs must match only one leaf : %s” % glob) ValueError: dpath.util.get() globs must match only one leaf : */aws_sns_topic/this To Reproduce Steps to reproduce the behavior: 0. add code like above.
- Go to ‘CLI’
- Run cli command ‘.checkov -d .’
- See error
Expected behavior Checkov should be able to tell if they are data or resource and not throw an exception.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Win10
- Checkov Version 1.0.173
Additional context I’m just going to rename the data source but it is a bug, if minor.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Fixed. Thank you @tronxd
@JamesWoolfenden variable evaluation issues were solved in #106, thanks for your input! Please try to upgrade
checkov
and re-run it on your code