question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Check fails if you have different objects with the same name

See original GitHub issue

Describe 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.

  1. Go to ‘CLI’
  2. Run cli command ‘.checkov -d .’
  3. 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:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
schosterbarakcommented, Feb 26, 2020

Fixed. Thank you @tronxd

1reaction
tronxdcommented, Feb 26, 2020

@JamesWoolfenden variable evaluation issues were solved in #106, thanks for your input! Please try to upgrade checkov and re-run it on your code

Read more comments on GitHub >

github_iconTop Results From Across the Web

What happens if we create multiple objects with the same ...
It will throw and error. Its same as you cant declare two variables with same names cannot be declared. Because objects are user...
Read more >
Objects with the same name, what does that mean?
No, those two pointers point to two different objects in the memory. It doesn't matter if they have the same name. They were...
Read more >
"Multiple objects with the same name were found." - MSDN
The error I get is: "Multiple objects with the same name were found." Some items it seemingly just chooses not to bind.
Read more >
Objects with same name need to be mapped different...
In WinForms, I need to test with multiple tabs open as seen below. However, both "Work Queue" and "Watch List" have the same...
Read more >
Comparing Java objects with equals() and hashcode()
Simply put, these methods work together to verify if two objects have the same values. Without equals() and hashcode() we would have to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found