diff --git a/.devcontainer/configuration/plugins.py b/.devcontainer/configuration/plugins.py index 9d1b8e9..da91b11 100644 --- a/.devcontainer/configuration/plugins.py +++ b/.devcontainer/configuration/plugins.py @@ -9,7 +9,7 @@ PLUGINS = [ "netbox_acls", ] -PLUGINS_CONFIG = { # type: ignore +PLUGINS_CONFIG = { # type: ignore "netbox_initializers": {}, "netbox_acls": {}, } diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index f681350..bef13f5 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -3,7 +3,7 @@ # separate terms of service, privacy policy, and support # documentation. -# This workflow helps you trigger a SonarCloud analysis of your code and populates +# This workflow helps you trigger a SonarCloud analysis of your code and populates # GitHub Code Scanning alerts with the vulnerabilities found. # Free for open source project. @@ -11,16 +11,16 @@ # 2. Import your project on SonarCloud # * Add your GitHub organization first, then add your repository as a new project. -# * Please note that many languages are eligible for automatic analysis, +# * Please note that many languages are eligible for automatic analysis, # which means that the analysis will start automatically without the need to set up GitHub Actions. # * This behavior can be changed in Administration > Analysis Method. -# +# # 3. Follow the SonarCloud in-product tutorial # * a. Copy/paste the Project Key and the Organization Key into the args parameter below # (You'll find this information in SonarCloud. Click on "Information" at the bottom left) # # * b. Generate a new token and add it to your Github repository's secrets using the name SONAR_TOKEN -# (On SonarCloud, click on your avatar on top-right > My account > Security +# (On SonarCloud, click on your avatar on top-right > My account > Security # or go directly to https://sonarcloud.io/account/security/) # Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/) @@ -41,9 +41,9 @@ permissions: jobs: Analysis: runs-on: ubuntu-latest - + steps: - - name: Analyze with SonarCloud + - name: Analyze with SonarCloud # You can pin the exact commit or the version. # uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049 @@ -53,7 +53,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) with: # Additional arguments for the sonarcloud scanner - args: + args: # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu) # mandatory -Dsonar.projectKey= @@ -65,4 +65,4 @@ jobs: # Comma-separated paths to directories containing test source files. #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/ # Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing. - #-Dsonar.verbose= # optional, default is false + #-Dsonar.verbose= # optional, default is false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 596b3da..c8cde6e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -62,4 +62,4 @@ repos: # entry: wily diff # verbose: true # language: python - # additional_dependencies: [wily] \ No newline at end of file + # additional_dependencies: [wily] diff --git a/netbox_acls/forms/models.py b/netbox_acls/forms/models.py index 2bff4ce..a8800e5 100644 --- a/netbox_acls/forms/models.py +++ b/netbox_acls/forms/models.py @@ -410,7 +410,7 @@ class ACLInterfaceAssignmentForm(NetBoxModelForm): def save(self, *args, **kwargs): # Set assigned object self.instance.assigned_object = self.cleaned_data.get( - "interface" + "interface", ) or self.cleaned_data.get("vminterface") return super().save(*args, **kwargs) diff --git a/netbox_acls/models/access_list_rules.py b/netbox_acls/models/access_list_rules.py index e08063b..2dff662 100644 --- a/netbox_acls/models/access_list_rules.py +++ b/netbox_acls/models/access_list_rules.py @@ -2,6 +2,7 @@ Define the django models for this plugin. """ +from django.apps import apps from django.contrib.postgres.fields import ArrayField from django.db import models from django.urls import reverse @@ -57,6 +58,10 @@ class ACLRule(NetBoxModel): def get_action_color(self): return ACLRuleActionChoices.colors.get(self.action) + @classmethod + def get_prerequisite_models(cls): + return [apps.get_model("ipam.Prefix"), AccessList] + class Meta: """ Define the common model properties: @@ -90,6 +95,10 @@ class ACLStandardRule(ACLRule): """ return reverse("plugins:netbox_acls:aclstandardrule", args=[self.pk]) + @classmethod + def get_prerequisite_models(cls): + return [AccessList] + class Meta(ACLRule.Meta): """ Define the model properties adding to or overriding the inherited class: @@ -151,6 +160,10 @@ class ACLExtendedRule(ACLRule): def get_protocol_color(self): return ACLProtocolChoices.colors.get(self.protocol) + @classmethod + def get_prerequisite_models(cls): + return [apps.get_model("ipam.Prefix"), AccessList] + class Meta(ACLRule.Meta): """ Define the model properties adding to or overriding the inherited class: diff --git a/netbox_acls/models/access_lists.py b/netbox_acls/models/access_lists.py index e4946e0..729e024 100644 --- a/netbox_acls/models/access_lists.py +++ b/netbox_acls/models/access_lists.py @@ -139,6 +139,10 @@ class ACLInterfaceAssignment(NetBoxModel): args=[self.pk], ) + @classmethod + def get_prerequisite_models(cls): + return [AccessList] + def get_direction_color(self): return ACLAssignmentDirectionChoices.colors.get(self.direction) diff --git a/setup.py b/setup.py index 1ed86ec..3b2bab6 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os.path from setuptools import find_packages, setup -with open("README.md", "r") as fh: +with open("README.md") as fh: long_description = fh.read()