bridgecrewio / yor

Extensible auto-tagger for your IaC files. The ultimate way to link entities in the cloud back to the codified resource which created it.
https://www.yor.io
Apache License 2.0
825 stars 123 forks source link

Invalid tags being added when there are comments in tag section of terraform file #376

Closed sahilt-ti closed 1 year ago

sahilt-ti commented 1 year ago

Describe the bug If there is a comment anywhere within the tags block in a resource (except after the last tag), then invalid tags are being generated.

To Reproduce Steps to reproduce the behavior:

  1. Go to a working terraform project directory.
  2. Use this template to reproduce:
    
    provider "aws" {
    region = "us-east-1"
    }

resource "aws_instance" "example" { ami = "ami-09d56f8956ab235b3" instance_type = "t2.micro" tags = { "name" = "sahil" # this is name "env" = "dev" } }


3. Run cli command  `yor tag -d . —tag-groups code2cloud -parsers Terraform`
4. See error

**Expected behavior**
Only the relevant trace should have been added.

**Screenshots**
https://drive.google.com/file/d/1j5FHvmiAOLJHCfgbEGXkAonw3whO_IsM/view?usp=sharing

**Desktop:**
 - OS: [macOS, Ubuntu]
 - Yor Version [0.1.178]
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ChanochShayner commented 1 year ago

@sahilt-ti the fix PR merged, feel free to reach out in case of an issue.