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

fix: respect ref head rules in rule-name-repeats-package #1022

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

anderseknert
Copy link
Member

Also made some adjustments to make the rule follow more modern conventions, and more importantly, to report end locations.

Fixes #1015

Also made some adjustments to make the rule follow more
modern conventions, and more importantly, to report end
locations.

Fixes #1015

Signed-off-by: Anders Eknert <anders@styra.com>
possible_offending_prefixes contains prefix if {
some combination in possible_path_component_combinations
_possible_offending_prefixes contains prefix if {
some combination in _possible_path_component_combinations

prefix := concat("_", combination)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also catch things like this with this rule?

package foo.bar

import rego.v1

foo.bar := true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I'd say no, as at least applying the same logic as we currently do for any path component would mean that something like:

package region.us.policies

user.permissions := { }

Would count user as repeating us...

I think even for a simple naming scheme, this can sometimes be problematic. Like this one for example:

package my.db

dba if {
    "dba" in input.user.roles
}

A config toggle to only match full words would be nice. But it's also not a problem I've enountered in any real policy yet.

@anderseknert anderseknert merged commit a92a31f into main Aug 29, 2024
3 checks passed
@anderseknert anderseknert deleted the fix-rule-name-repeats-package branch August 29, 2024 08:43
srenatus pushed a commit to srenatus/regal that referenced this pull request Oct 1, 2024
…1022)

Also made some adjustments to make the rule follow more
modern conventions, and more importantly, to report end
locations.

Fixes StyraInc#1015

Signed-off-by: Anders Eknert <anders@styra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rule-name-repeats-package misses some classes of rules
2 participants