-
-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests, modified cve format validation and fixed analyzer config
- Loading branch information
spoiicy
authored and
spoiicy
committed
Nov 10, 2024
1 parent
7c83986
commit 992e801
Showing
4 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
28 changes: 28 additions & 0 deletions
28
tests/api_app/analyzers_manager/observable_analyzers/test_nvd_cve.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.test import TestCase | ||
|
||
from api_app.analyzers_manager.classes import AnalyzerRunException | ||
from api_app.analyzers_manager.models import AnalyzerConfig | ||
from api_app.analyzers_manager.observable_analyzers.nvd_cve import NVDDetails | ||
|
||
|
||
class NVDCVETestCase(TestCase): | ||
config = AnalyzerConfig.objects.get(python_module=NVDDetails.python_module) | ||
|
||
def test_valid_cve_format(self): | ||
"""Test that a valid CVE format passes without raising an exception""" | ||
|
||
analyzer = NVDDetails(self.config) | ||
analyzer.observable_name = "cve-2024-51181" # Valid format | ||
|
||
try: | ||
analyzer.run() | ||
except AnalyzerRunException: | ||
self.fail("AnalyzerRunException raised with valid CVE format") | ||
|
||
def test_invalid_cve_format(self): | ||
"""Test that an invalid CVE format raises an AnalyzerRunException""" | ||
analyzer = NVDDetails(self.config) | ||
analyzer.observable_name = "2024-51181" # Invalid format | ||
|
||
with self.assertRaises(AnalyzerRunException): | ||
analyzer.run() |