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

Add linter to check for correct navigation permissions #97

Open
gsnider2195 opened this issue Sep 27, 2024 · 2 comments
Open

Add linter to check for correct navigation permissions #97

gsnider2195 opened this issue Sep 27, 2024 · 2 comments

Comments

@gsnider2195
Copy link
Contributor

Environment

  • Nautobot version:
  • pylint-nautobot version:

Proposed Functionality

Ensure that if permissions are used in NavMenu items that they match the model being used in the linked view. For example, if you are adding a navigation menu item to the plugins:example_app:examplemodel_list view, the permission should be for example_app.view_examplemodel. See the Navigation Menu docs for more information.

Use Case

@glennmatthews
Copy link
Contributor

Good thought, though also I'd really like to enhance the nav menu API in core at some point so that the common case can implicitly derive the correct permissions without needing so much duplication of information.

@bryanculver
Copy link
Member

Let's not go down the depth of trying to introspect the router. Instead, let's just duck-type the link and permissions to ensure they follow the conventions (modelname_action and permission_modelname) and the model names are the same in both. Providing a helpful pylint documentation for this rule would suggest that Model-less views can be safely ignored with the pylint ignore comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants