Skip to content

Commit

Permalink
Fix #18
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoalmeidaoliveira committed May 12, 2023
1 parent 8a75f39 commit 00d4af1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ pbuild:
python3 -m pip install --upgrade build
python3 -m build

pypipub:
publish:
python3 -m pip install --user --upgrade twine
python3 -m twine upload dist/*
1 change: 0 additions & 1 deletion nb_risk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class Vulnerability(NetBoxModel):
)
cvssbaseScore = models.FloatField("Base Score", max_length=100, blank=True)

@property
def affected_assets(self):
return self.vulnerability_assignments.count()

Expand Down
22 changes: 19 additions & 3 deletions nb_risk/tables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import django_tables2 as tables
from django_tables2.utils import Accessor

from netbox.tables import NetBoxTable, ChoiceFieldColumn, columns
from netbox.tables import NetBoxTable, columns
from django.db.models import Count

from . import models
from . import columns as riskColumns
Expand Down Expand Up @@ -35,11 +37,25 @@ class Meta(NetBoxTable.Meta):
class VulnerabilityTable(NetBoxTable):

name = tables.Column(linkify=True)
affected_assets = tables.Column(verbose_name="Affected Assets")
affected = columns.LinkedCountColumn(
verbose_name="Affected Assets",
accessor=Accessor("affected_assets"),
viewname='plugins:nb_risk:vulnerabilityassignment_list',
url_params={
'vulnerability': 'name',
},
)

def order_affected(self, queryset, is_descending):
if is_descending:
queryset = queryset.annotate(affected_assets=Count('vulnerability_assignments')).order_by('-affected_assets')
else:
queryset = queryset.annotate(affected_assets=Count('vulnerability_assignments')).order_by('affected_assets')
return (queryset, True)

class Meta(NetBoxTable.Meta):
model = models.Vulnerability
fields = ["name", "cve", "description", "affected_assets", "cvssbaseScore"]
fields = ["name", "cve", "description", "affected", "cvssbaseScore"]


# VulnerabilityAssignment Tables
Expand Down
2 changes: 1 addition & 1 deletion nb_risk/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "35.0.1"
__version__ = "35.0.2"

0 comments on commit 00d4af1

Please sign in to comment.