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

App nist CVE sync3.0 #391

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a54d358
Adding the new NIST CVE Tracking feature for 3.x release.
bminnix Jun 4, 2024
22bb5f6
Apply suggestions from code review
bminnix Aug 12, 2024
c635d50
Updating a couple of things for linting before moving on to other rec…
bminnix Aug 12, 2024
78c411d
Pinning django-debug-toolbar to <4.4, seems to be what's causing an i…
bminnix Aug 12, 2024
b7dc4df
Adding the new NIST CVE Tracking feature for 3.x release.
bminnix Jun 4, 2024
19ba2b7
Apply suggestions from code review
bminnix Aug 12, 2024
7b6e23f
Updating a couple of things for linting before moving on to other rec…
bminnix Aug 12, 2024
68a9727
Pinning django-debug-toolbar to <4.4, seems to be what's causing an i…
bminnix Aug 12, 2024
d71a63f
After the rebase from next3.0, delete and regenerate of migration file.
bminnix Nov 14, 2024
071270e
Updating signals and tracking for ExternalIntegration updates
bminnix Nov 27, 2024
9bedd6e
Required to update the lock file
bminnix Nov 27, 2024
746073b
Fixing things the tests yelled about.
bminnix Nov 27, 2024
e43c62d
Moving init logic into run. Not able to access db items in job init.
bminnix Nov 28, 2024
5578755
Regenerated the migration file because it was causing an issue on che…
bminnix Nov 28, 2024
21a8b1b
Checked out the migrations directory from next3.0 then ran makemigrat…
bminnix Nov 28, 2024
fb6ccde
Added several things including ExternalIntegration, SecretsGroup, Sec…
bminnix Nov 29, 2024
a3613fd
Issue with one of the migrated files after I let it get ruffed up.
bminnix Nov 29, 2024
f6e4480
Update nautobot_device_lifecycle_mgmt/jobs/cve_tracking.py
bminnix Nov 29, 2024
52f4827
Update nautobot_device_lifecycle_mgmt/jobs/cve_tracking.py
bminnix Nov 29, 2024
5694c0f
Removed the create_cpe_software_search_urls as recommended and moved …
bminnix Nov 29, 2024
f397bcc
Updated all calls to use the software object instead of passing softw…
bminnix Nov 29, 2024
147a03c
Updating documentation for use with External Integration selection, a…
bminnix Nov 29, 2024
808442c
Realized there were a couple more requested changes that were hidden …
bminnix Nov 29, 2024
a898c68
Still had a continue that needed to be removed.
bminnix Nov 29, 2024
92e9de1
Saw a bit of missing instruction in the user doc regarding the secret.
bminnix Dec 2, 2024
033adaa
Updating to only leave a couple of the retry options configurable.
bminnix Dec 3, 2024
aece22c
Fixed files with ruff
bminnix Dec 3, 2024
104cac0
Updated the query_api method to Open, retrieve, and Close the session…
bminnix Dec 5, 2024
aba4645
Updating some code for readability and catching a known possible exce…
bminnix Dec 5, 2024
1a2a595
Had an unnecessary else
bminnix Dec 5, 2024
4133976
Updated logger statement
bminnix Dec 5, 2024
3431135
Post-rebase from next3.0 for latest changes and migrations
bminnix Feb 24, 2025
678613b
Ruff altered a couple of lines
bminnix Mar 4, 2025
5fb7b4b
Updating poetry.lock for changes in the toml file.
bminnix Mar 5, 2025
94d72b0
Pulled latest lock file from next3.0, then locked to add additional p…
bminnix Mar 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/images/lcm_cve_nist_job.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/lcm_cve_nist_job_log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/lcm_cve_nist_job_run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 42 additions & 2 deletions docs/user/cve_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ When creating a CVE object, the following fields are available. Fields in **bold
| Fix | The software fix (if available) for the CVE |
| Comments | Any additional comments or details about the CVE |
| Tags | Arbitrary [tag objects](https://docs.nautobot.com/projects/core/en/stable/models/extras/tag/) that can be applied to this CVE |
| Last Modified Date | The date that the CVE record was last modified |

!!! note
In addition to these standard fields, you can also add one or more [Custom Fields](https://docs.nautobot.com/projects/core/en/stable/models/extras/customfield/) to the model.

### Software Association

As stated previously, you can associate a CVE to one or many [Software objects](./software_lifecycle.md#software-objects). These relationships will present themselves as breadcrumb links on each item's detail view.
As stated previously, you can associate a CVE to one or many [Software objects](./software_lifecycle.md#software-objects). These relationships will present themselves as breadcrumb links on the CVE item's detail view, and as the "Related CVEs" tab on the Software item's detail view.

Example of a breadcrumb link on a CVE item's view:

![](../images/lcm_cve_breadcrumb.png)

Example of a breadcrumb link on a Software item's view:
Example of the "Related CVEs" tab on a Software item's view:

![](../images/lcm_software_breadcrumb.png)

Expand All @@ -60,3 +61,42 @@ After a Vulnerability object has been generated, the CVE, Software, Device and I
In addition to these standard fields, you can also add one or more [Custom Fields](https://docs.nautobot.com/projects/core/en/stable/models/extras/customfield/) to the model.

As was stated previously, running the ``Generate Vulnerabilities`` Job will not modify (or delete) any existing Vulnerability objects - **even if the associations that existed previously no longer exist**. You do have the ability to delete one or more Vulnerability objects via the GUI or API. In addition to manually removing a Vulnerability, if any CVE, Software, Device or Inventory Item objects are removed, any Vulnerability objects that reference the deleted items will also be removed automatically.

## Automated CVE Discovery via NIST API 2.0
The NTC Nautobot Device Lifecycle Management app now supports automated CVE discovery via the NIST NVD API 2.0. This feature is optional and can be enabled by obtaining an API key, updating the necessary Secret, and running the ``NIST - Software CVE Search`` Job. Continue reading for more information.

### External Integration
An External Integration must be created and configured in order to use the NIST NVD API for automatic software CVE discovery. On this note, the following is installed for you:

- A new External Integration object named ``NAUTOBOT DLM NIST EXTERNAL INTEGRATION`` that allows you to control the following behaviors of the integration:
- ``api_call_delay``: A delay between API calls in seconds (default: 6). NIST Recommends a minimum value of 6 to prevent overloading resources.
- ``retries``: Even with using a delay, the NIST API may return a 500 error. The settings in this dictionary allows you to control the number of retries and backoff.
- ``max_attempts``: The maximum number of retry attempts (default: 3).
- ``backoff``: The backoff factor for the retry attempts (default: 2). This is the multiplier for the delay between retries.
- A new Secrets Group object named ``NAUTOBOT DLM NIST SECRETS GROUP`` used for access to the NIST API Key from the External Integration.
- A new Secret object named ``NAUTOBOT DLM NIST API KEY``. This object is created for you during setup with minimum defaults. The Secret name must be exactly as above, but you will need to configure the Secret to properly access the NIST API Key.
- To obtain your NIST API Key go [here]('https://nvd.nist.gov/developers/request-an-api-key').

NOTE: You may change the name of the External Integration or create your own using other configuration settings, but the SecretsGroup and Secret objects must be named as above. The External Integration is selected when starting the Job run.


### Run Job
Automated discovery is used by running the ``NIST - Software CVE Search`` Job.

To run this job, use the "Jobs" menu dropdown and navigate to the **CVE Tracking** section. The jobs will appear here and all you will need to do is click the play button in order to use the default External Integration[^1]. If you have configured additional Integrations, you may select the External Integration that you want to use. **As stated previously, the name of the External Integration does not matter, but the External Integration must contain a SecretsGroup and Secret named as above**.

![](../images/lcm_cve_nist_job.png)

![](../images/lcm_cve_nist_job_run.png)

The job output should indicate the softwares checked and the amount of CVEs received for that software, as well as the amount of CVEs created. These will not always be the same. New CVE will be created for software with existing CVE, also software will share CVEs.

![](../images/lcm_cve_nist_job_log.png)

[^1] Warning: If play button is grayed out. You will need to enable the job by clicking on edit button in the row and navigate to "Job" portion and click on "Enable"


### Additional Notes:
Due to the way vendor platform entries vary in NIST, some platforms may work without issue, others may not work so well (false positives/negatives). Juniper JunOS is a great example and has a custom parser in netutils to handle this.

If the platform you are attempting to gather information from does not work, a custom parser will likely be needed to build a proper NIST search URL.
4 changes: 4 additions & 0 deletions nautobot_device_lifecycle_mgmt/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,10 @@ class CVELCMFilterSet(NautobotFilterSet, StatusModelFilterSetMixin): # , Custom
published_date__gte = django_filters.DateFilter(field_name="published_date", lookup_expr="gte")
published_date__lte = django_filters.DateFilter(field_name="published_date", lookup_expr="lte")

last_modified_date = django_filters.DateTimeFromToRangeFilter()
last_modified_date__gte = django_filters.DateFilter(field_name="last_modified_date", lookup_expr="gte")
last_modified_date__lte = django_filters.DateFilter(field_name="last_modified_date", lookup_expr="lte")

cvss__gte = django_filters.NumberFilter(field_name="cvss", lookup_expr="gte")
cvss__lte = django_filters.NumberFilter(field_name="cvss", lookup_expr="lte")

Expand Down
7 changes: 7 additions & 0 deletions nautobot_device_lifecycle_mgmt/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ class CVELCMForm(NautobotModelForm):
"""CVE Lifecycle Management creation/edit form."""

published_date = forms.DateField(widget=DatePicker())
last_modified_date = forms.DateField(widget=DatePicker(), required=False)
severity = forms.ChoiceField(choices=CVESeverityChoices.CHOICES, label="Severity", required=False)
tags = DynamicModelMultipleChoiceField(queryset=Tag.objects.all(), required=False)
affected_softwares = DynamicModelMultipleChoiceField(queryset=SoftwareVersion.objects.all(), required=False)
Expand All @@ -679,6 +680,7 @@ class Meta:

widgets = {
"published_date": DatePicker(),
"last_modified_date": DatePicker(),
}


Expand Down Expand Up @@ -722,6 +724,9 @@ class CVELCMFilterForm(NautobotFilterForm):
published_date_before = forms.DateField(label="Published Date Before", required=False, widget=DatePicker())
published_date_after = forms.DateField(label="Published Date After", required=False, widget=DatePicker())

last_modified_date_before = forms.DateField(label="Last Modified Date Before", required=False, widget=DatePicker())
last_modified_date_after = forms.DateField(label="Last Modified Date After", required=False, widget=DatePicker())

cvss__gte = forms.FloatField(label="CVSS Score Above", required=False)
cvss__lte = forms.FloatField(label="CVSS Score Below", required=False)

Expand Down Expand Up @@ -755,6 +760,8 @@ class Meta:
"q",
"published_date_before",
"published_date_after",
"last_modified_date_before",
"last_modified_date_after",
"severity",
"status",
"affected_softwares",
Expand Down
3 changes: 2 additions & 1 deletion nautobot_device_lifecycle_mgmt/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from nautobot.core.celery import register_jobs

from .cve_tracking import GenerateVulnerabilities
from .cve_tracking import GenerateVulnerabilities, NistCveSyncSoftware
from .lifecycle_reporting import (
DeviceHardwareNoticeFullReport,
DeviceSoftwareValidationFullReport,
Expand All @@ -16,5 +16,6 @@
InventoryItemSoftwareValidationFullReport,
GenerateVulnerabilities,
DLMToNautobotCoreModelMigration,
NistCveSyncSoftware,
]
register_jobs(*jobs)
Loading