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

Sarif output has wrong file path value for file scans #861

Closed
devang-gaur opened this issue Jun 14, 2021 · 0 comments · Fixed by #863
Closed

Sarif output has wrong file path value for file scans #861

devang-gaur opened this issue Jun 14, 2021 · 0 comments · Fixed by #863
Assignees
Labels

Comments

@devang-gaur
Copy link
Contributor

Directory Scan

./bin/terrascan scan -d pkg/iac-providers/terraform/v14/testdata/relative-moduleconfigs/elasticcache/ -o sarif                                                                                                                                        
{
  "version": "2.1.0",
  "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "terrascan",
          "version": "1.7.0",
          "informationUri": "https://github.com/accurics/terrascan",
          "rules": [
            {
              "id": "AWS.ElastiCache.DataSecurity.High.0424",
              "name": "noMemcachedInElastiCache",
              "shortDescription": {
                "text": "ElastiCache for Memcached is not in use in AWS PCI DSS environments"
              },
              "properties": {
                "category": "Compliance Validation",
                "severity": "HIGH"
              }
            }
          ]
        }
      },
      "results": [
        {
          "ruleId": "AWS.ElastiCache.DataSecurity.High.0424",
          "level": "error",
          "message": {
            "text": "ElastiCache for Memcached is not in use in AWS PCI DSS environments"
          },
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "file:///Users/dev-gaur/go/src/github.com/accurics/terrascan/pkg/iac-providers/terraform/v14/testdata/relative-moduleconfigs/elasticcache/main.tf"
                },
                "region": {
                  "startLine": 1
                }
              },
              "logicalLocations": [
                {
                  "name": "noMemcachedInElastiCache",
                  "kind": "aws_elasticache_cluster"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Check the artifactLocation.url value. It works fine for Directory scans, but works a bit wrong for File scans. Check the example below.

File Scan

./bin/terrascan scan -f pkg/iac-providers/terraform/v14/testdata/relative-moduleconfigs/elasticcache/main.tf -o sarif                                                                                                                                 
{
  "version": "2.1.0",
  "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "terrascan",
          "version": "1.7.0",
          "informationUri": "https://github.com/accurics/terrascan",
          "rules": [
            {
              "id": "AWS.ElastiCache.DataSecurity.High.0424",
              "name": "noMemcachedInElastiCache",
              "shortDescription": {
                "text": "ElastiCache for Memcached is not in use in AWS PCI DSS environments"
              },
              "properties": {
                "category": "Compliance Validation",
                "severity": "HIGH"
              }
            }
          ]
        }
      },
      "results": [
        {
          "ruleId": "AWS.ElastiCache.DataSecurity.High.0424",
          "level": "error",
          "message": {
            "text": "ElastiCache for Memcached is not in use in AWS PCI DSS environments"
          },
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "file:///Users/dev-gaur/go/src/github.com/accurics/terrascan/pkg/iac-providers/terraform/v14/testdata/relative-moduleconfigs/elasticcache/main.tf/main.tf"
                },
                "region": {
                  "startLine": 1
                }
              },
              "logicalLocations": [
                {
                  "name": "noMemcachedInElastiCache",
                  "kind": "aws_elasticache_cluster"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
@devang-gaur devang-gaur self-assigned this Jun 14, 2021
@devang-gaur devang-gaur changed the title Sarif output has wrong file name for file scans Sarif output has wrong file path value for file scans Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant