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

Malformed output after a parsing error #1326

Closed
VeraBE opened this issue Jul 13, 2022 · 1 comment · Fixed by #1385
Closed

Malformed output after a parsing error #1326

VeraBE opened this issue Jul 13, 2022 · 1 comment · Fixed by #1385
Assignees
Labels
dependencies Pull requests that update a dependency file enhancement

Comments

@VeraBE
Copy link
Contributor

VeraBE commented Jul 13, 2022

  • terrascan version: I tried 1.14.0 and 1.15.2, both have the issue
  • Operating System: Windows 11

Description

When analyzing a template with a syntax issue the tool outputs an error on top of the SARIF file instead of using the toolNotifications object, resulting in a malformed JSON file

The templated had this object:

"DBSecurityGroup": {
      "Type": "AWS::RDS::DBSecurityGroup",
      "Condition" : "Is-EC2-Classic",
      "Properties": {
        "DBSecurityGroupIngress": {
          "EC2SecurityGroupName": { "Ref": "InstanceSecurityGroup" }
        },
        "GroupDescription": "database access"
      }
    }

instead of:

"DBSecurityGroup": {
      "Type": "AWS::RDS::DBSecurityGroup",
      "Condition" : "Is-EC2-Classic",
      "Properties": {
        "DBSecurityGroupIngress": [{
          "EC2SecurityGroupName": { "Ref": "InstanceSecurityGroup" }
        }],
        "GroupDescription": "database access"
      }
    }

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-security-group.html

What I Did

The command I used to run the tool was:

.\terrascan.exe scan -f "<file path>" -i cft -o sarif

The error outputted on top of the SARIF file was:

ERROR: json: cannot unmarshal object into Go struct field Properties.Properties.DBSecurityGroupIngress of type []rds.DBSecurityGroup_Ingress
@VeraBE
Copy link
Contributor Author

VeraBE commented Aug 16, 2022

This was fixed and released in the latest version of awslabs/goformation

Is there a reason why Terrascan is still using v5 instead of v6?

I started to work on an update but it's taking me longer than expected, I'm not familiar with Go or Terrascan master...VeraBE:terrascan:updateGoFormation

@gaurav-gogia gaurav-gogia self-assigned this Sep 5, 2022
@gaurav-gogia gaurav-gogia added enhancement dependencies Pull requests that update a dependency file labels Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants