Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

False positives in top-level-iteration #1277

Closed
anderseknert opened this issue Nov 26, 2024 · 1 comment · Fixed by #1287
Closed

False positives in top-level-iteration #1277

anderseknert opened this issue Nov 26, 2024 · 1 comment · Fixed by #1287
Labels
bug Something isn't working rule

Comments

@anderseknert
Copy link
Member

package play

import rego.v1

split_rule_name := split(input.rulePackageNameToRun, ".")

result := data.play.other[a][b][c][d] if [a, b, c, d] := split_rule_name

result := data.play.other[a][b][c] if [a, b, c] := split_rule_name

result := data.play.other[a][b] if [a, b] := split_rule_name

result := data.play.other[a] if [a] := split_rule_name

other.foo.bar := "baz"

As @srenatus pointed out on Slack, this policy, while a tad unconventional, has Regal falsely report both top-level-iteration and pointless-reassignment. I guess we should file two issues for this, but the cause is likely the same for both, so I'll split these up only if it's found not to be the case.

Boiling it down, this should work as a test case:

package play

import rego.v1

parts := split(input.parts, ".")

result := ref[a][b] if [a, b] := parts
@anderseknert anderseknert added the bug Something isn't working label Nov 26, 2024
@anderseknert anderseknert changed the title False positives in top-level-iteration and pointles-reassignment False positives in top-level-iteration Dec 3, 2024
@anderseknert
Copy link
Member Author

The pointless reassignment issue moved to #1285

anderseknert added a commit that referenced this issue Dec 4, 2024
Fixes #1277

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue Dec 4, 2024
Fixes #1277

Signed-off-by: Anders Eknert <anders@styra.com>
charlieegan3 pushed a commit to charlieegan3/regal that referenced this issue Jan 6, 2025
Fixes StyraInc#1277

Signed-off-by: Anders Eknert <anders@styra.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant