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 log_info for each CVE in the vulnerability job #140

Merged
merged 2 commits into from Mar 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion nautobot_device_lifecycle_mgmt/jobs/cve_tracking.py
@@ -1,7 +1,7 @@
"""Jobs for the CVE Tracking portion of the Device Lifecycle plugin."""
from datetime import datetime

from nautobot.extras.jobs import Job, StringVar
from nautobot.extras.jobs import Job, StringVar, BooleanVar
from nautobot.extras.models import Relationship, RelationshipAssociation

from nautobot_device_lifecycle_mgmt.models import (
Expand Down Expand Up @@ -31,6 +31,9 @@ class Meta: # pylint: disable=too-few-public-methods
"""Meta class for the job."""

commit_default = True
field_order = ["published_after", "_task_queue", "debug", "_commit"]

debug = BooleanVar(description="Enable for more verbose logging.")

def run(self, data, commit): # pylint: disable=too-many-locals
"""Check if software assigned to each device is valid. If no software is assigned return warning message."""
Expand All @@ -40,6 +43,8 @@ def run(self, data, commit): # pylint: disable=too-many-locals
count_before = VulnerabilityLCM.objects.count()

for cve in cves:
if data["debug"]:
self.log_info(obj=cve, message="Generating vulnerabilities for CVE {cve}")
software_rels = RelationshipAssociation.objects.filter(relationship__slug="soft_cve", destination_id=cve.id)
for soft_rel in software_rels:

Expand Down