Skip to content

Commit

Permalink
Merge pull request #377 from nautobot/cve-bulk-update
Browse files Browse the repository at this point in the history
Allow bulk update status for CVE. Fix CVE status filter.
  • Loading branch information
bradh11 authored Oct 18, 2024
2 parents 3766f87 + 93e3895 commit db3ef9b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions changes/255.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add status to bulk update for CVE. Fix CVE status filter.
10 changes: 9 additions & 1 deletion nautobot_device_lifecycle_mgmt/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,9 @@ class CVELCMBulkEditForm(NautobotBulkEditForm, CustomFieldModelBulkEditFormMixin
description = forms.CharField(required=False)
comments = forms.CharField(required=False)
tags = DynamicModelMultipleChoiceField(queryset=Tag.objects.all(), required=False)
status = DynamicModelChoiceField(
queryset=Status.objects.all(), required=False, query_params={"content_types": model._meta.label_lower}
)

class Meta:
"""Meta attributes for the CVELCMBulkEditForm class."""
Expand Down Expand Up @@ -884,7 +887,12 @@ class CVELCMFilterForm(NautobotFilterForm):
cvss_v3__lte = forms.FloatField(label="CVSSv3 Score Below", required=False)
affected_softwares = forms.ModelMultipleChoiceField(queryset=SoftwareLCM.objects.all(), required=False)

status = DynamicModelMultipleChoiceField(queryset=Status.objects.all(), required=False, to_field_name="name")
status = DynamicModelMultipleChoiceField(
queryset=Status.objects.all(),
required=False,
query_params={"content_types": model._meta.label_lower},
to_field_name="name",
)
exclude_status = DynamicModelMultipleChoiceField(
label="Exclude Status",
required=False,
Expand Down
9 changes: 9 additions & 0 deletions nautobot_device_lifecycle_mgmt/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,33 @@ def create_inventory_items():

def create_cves():
"""Create CVELCM items for tests."""
cve_ct = ContentType.objects.get_for_model(CVELCM)
status_review, _ = Status.objects.get_or_create(name="Review")
status_review.content_types.add(cve_ct)
status_resolved, _ = Status.objects.get_or_create(name="Resolved")
status_resolved.content_types.add(cve_ct)

cves = (
CVELCM.objects.create(
name="CVE-2021-1391",
published_date="2021-03-24",
link="https://www.cvedetails.com/cve/CVE-2021-1391/",
description="A vulnerability in the dragonite debugger of Cisco IOS XE Software",
status=status_review,
),
CVELCM.objects.create(
name="CVE-2021-44228",
published_date="2021-12-10",
link="https://www.cvedetails.com/cve/CVE-2021-44228/",
description="Apache Log4j2 2.0-beta9 through 2.15.0",
status=status_review,
),
CVELCM.objects.create(
name="CVE-2020-27134",
published_date="2020-12-11",
link="https://www.cvedetails.com/cve/CVE-2020-27134/",
description="Multiple vulnerabilities in Cisco Jabber",
status=status_review,
),
)
return cves
Expand Down
18 changes: 11 additions & 7 deletions nautobot_device_lifecycle_mgmt/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,22 @@ class CVELCMViewTest(ViewTestCases.PrimaryObjectViewTestCase):
"""Test the CVELCM views."""

model = CVELCM
bulk_edit_data = {"description": "Bulk edit views"}

form_data = {
"name": "Test 1",
"published_date": datetime.date(2022, 1, 1),
"link": "https://www.cvedetails.com/cve/CVE-2022-0001/",
}

@classmethod
def setUpTestData(cls): # pylint: disable=invalid-name
"""Set up test objects."""
create_cves()
cls.bulk_edit_data = {
"description": "Bulk edit views",
"comments": "New",
"status": Status.objects.get_for_model(CVELCM).first().pk,
}

cls.form_data = {
"name": "Test 1",
"published_date": datetime.date(2022, 1, 1),
"link": "https://www.cvedetails.com/cve/CVE-2022-0001/",
}

@skip("Not implemented")
def test_bulk_import_objects_with_permission(self):
Expand Down

0 comments on commit db3ef9b

Please sign in to comment.