-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
parse: include location of rule ref in AST #5790
Comments
Hmm, interesting. I think that we might be able to dig into where |
I have taken a look into the code of While investigating the motivation that causes the output to have missing location, I tried to use the following code as an example: package test
default allow = false
allow = true {
input.method == "GET"
input.path = ["getSalary", user]
input.user == user
} In this case the output relative to the line "head": {
"name": "allow",
"value": {
"location": {
"file": "t2.rego",
"row": 4,
"col": 9
},
"type": "boolean",
"value": true
},
"ref": [
{
"type": "var",
"value": "allow"
}
],
"location": {
"file": "t2.rego",
"row": 4,
"col": 1
}
},
"location": {
"file": "t2.rego",
"row": 4,
"col": 1
} There is a similar part of the output for the What I noticed after this, is that in parseModule, the statement used in the example of @anderseknert is handled by the I have tried to add similar code in the switch statement mentioned above and this is the output for the example of @anderseknert: "rules": [
{
"body": [
{
"index": 0,
"location": {
"file": "test.rego",
"row": 3,
"col": 8
},
"terms": {
"location": {
"file": "test.rego",
"row": 3,
"col": 8
},
"type": "boolean",
"value": true
}
}
],
"head": {
"name": "foo",
"value": {
"location": {
"file": "test.rego",
"row": 3,
"col": 8
},
"type": "string",
"value": "bar"
},
"assign": true,
"ref": [
{
"type": "var",
"value": "foo"
}
],
"location": {
"file": "test.rego",
"row": 3,
"col": 1
}
},
"location": {
"file": "test.rego",
"row": 3,
"col": 1
}
}
] I can work on this to further investigate if only this addition fixes the problem and add some tests. |
That'd be amazing! Thanks @Trolloldem 😃 |
Prior to this commit, when the AST information were serialized to JSON, rules expressed as discussed in open-policy-agent#5790 included only the location of their value and not the one of the rule ref var itself. Now the AST serialized to JSON includes this information. Fixes: open-policy-agent#5790 Signed-off-by: Gianluca Oldani <[email protected]>
Prior to this commit, when the AST information were serialized to JSON, rules expressed as discussed in open-policy-agent#5790 included only the location of their value and not the one of the rule ref var itself. Now the AST serialized to JSON includes this information. Fixes: open-policy-agent#5790 Signed-off-by: Gianluca Oldani <[email protected]>
Prior to this commit, when the AST information were serialized to JSON, rules expressed as discussed in open-policy-agent#5790 included only the location of their value and not the one of the rule ref var itself. Now the AST serialized to JSON includes this information. Fixes: open-policy-agent#5790 Signed-off-by: Gianluca Oldani <[email protected]>
Prior to this commit, when the AST information were serialized to JSON, rules expressed as discussed in open-policy-agent#5790 included only the location of their value and not the one of the rule ref var itself. Now the AST serialized to JSON includes this information. Fixes: open-policy-agent#5790 Signed-off-by: Gianluca Oldani <[email protected]>
Prior to this commit, when the AST information were serialized to JSON, rules expressed as discussed in open-policy-agent#5790 included only the location of their value and not the one of the rule ref var itself. Now the AST serialized to JSON includes this information. Fixes: open-policy-agent#5790 Signed-off-by: Gianluca Oldani <[email protected]>
Prior to this commit, when the AST information were serialized to JSON, rules expressed as discussed in open-policy-agent#5790 included only the location of their value and not the one of the rule ref var itself. Now the AST serialized to JSON includes this information. Fixes: open-policy-agent#5790 Signed-off-by: Gianluca Oldani <[email protected]>
Prior to this commit, when the AST information were serialized to JSON, rules expressed as discussed in open-policy-agent#5790 included only the location of their value and not the one of the rule ref var itself. Now the AST serialized to JSON includes this information. Fixes: open-policy-agent#5790 Signed-off-by: Gianluca Oldani <[email protected]>
Seems to be missing still in some cases: #6860 |
AST information from a rule head currently only includes the location of the value, not the rule ref var itself.
For tooling that works with the AST, this location information would be useful.
The text was updated successfully, but these errors were encountered: