# Automatic source locations with Rego

DevFeed: [Automatic source locations with Rego](<https://devfeed.tech/articles/automatic-source-locations-with-rego-7835.md>)

Original publisher: [Read original article](<https://snyk.io/blog/automatic-source-locations-rego/>)

Author: Jasper Van der Jeugt

Published: 2024-02-12T05:00:00Z

Content type: article

Language: en

Sources: [Blog RSS Feed | Snyk](<https://devfeed.tech/sources/blog-rss-feed-snyk.md>)

Topics: [opa](<https://devfeed.tech/topics/opa.md>), [snyk-iac](<https://devfeed.tech/topics/snyk-iac.md>), [Infrastructure as code](<https://devfeed.tech/topics/infrastructure-as-code.md>), [Open Policy Agent](<https://devfeed.tech/topics/open-policy-agent.md>), [AWS CloudFormation](<https://devfeed.tech/topics/aws-cloudformation.md>), [Terraform](<https://devfeed.tech/topics/terraform.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [blog-post](<https://devfeed.tech/tags/blog-post.md>), [cloud-security](<https://devfeed.tech/tags/cloud-security.md>), [cloudformation](<https://devfeed.tech/tags/cloudformation.md>), [developer](<https://devfeed.tech/tags/developer.md>), [devops](<https://devfeed.tech/tags/devops.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [iac](<https://devfeed.tech/tags/iac.md>), [opa](<https://devfeed.tech/tags/opa.md>), [rego](<https://devfeed.tech/tags/rego.md>), [snyk](<https://devfeed.tech/tags/snyk.md>), [snyk-iac](<https://devfeed.tech/tags/snyk-iac.md>), [technical](<https://devfeed.tech/tags/technical.md>)

## AI overview

This technical Snyk article explains automatic source code locations for Rego policy violations in Snyk IaC. The feature reports accurate file, line, and column information, including for custom rules. A simplified proof of concept uses CloudFormation YAML, Rego policies, and YAML tree traversal to infer attribute paths and retrieve source locations.

## Source excerpt

We recently released a series of improvements to Snyk IaC, and in this blog post, we're taking a technical dive into a particularly interesting feature -- automatic source code locations for rule violations.