Skip to content

Commit

Permalink
Fix: Make cpe_last_modified of CPE matches optional
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier committed Dec 13, 2024
1 parent d742cdc commit 55e5552
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pontos/nvd/models/cpe_match_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CPEMatchString(Model):
version_end_including: Optional end of the matching version range, including the given version
version_end_excluding: Optional end of the matching version range, excluding the given version
status: Status of the CPE match
cpe_last_modified: The date the CPEs list of the match was last modified
cpe_last_modified: Optional date the CPEs list of the match was last modified
created: Creation date of the CPE
last_modified: Last modification date of the CPE
matches: List of CPEs matching the criteria string and the optional range limits
Expand All @@ -47,9 +47,9 @@ class CPEMatchString(Model):
match_criteria_id: UUID
criteria: str
status: str
cpe_last_modified: datetime
created: datetime
last_modified: datetime
cpe_last_modified: Optional[datetime] = None
matches: List[CPEMatch] = field(default_factory=list)
version_start_including: Optional[str] = None
version_start_excluding: Optional[str] = None
Expand Down
15 changes: 11 additions & 4 deletions tests/nvd/models/test_cpe_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def test_required_only(self):
data = get_cpe_match_data()
data.__delitem__("matches")
data.__delitem__("version_end_including")
data.__delitem__("cpe_last_modified")

cpe_match_string = CPEMatchString.from_dict(data)

Expand All @@ -37,10 +38,6 @@ def test_required_only(self):
"Active",
cpe_match_string.status,
)
self.assertEqual(
datetime(2019, 7, 22, 16, 37, 38, 133000, tzinfo=timezone.utc),
cpe_match_string.cpe_last_modified,
)
self.assertEqual(
datetime(2019, 6, 17, 9, 16, 33, 960000, tzinfo=timezone.utc),
cpe_match_string.created,
Expand All @@ -52,11 +49,21 @@ def test_required_only(self):

self.assertEqual([], cpe_match_string.matches)

self.assertIsNone(cpe_match_string.cpe_last_modified)
self.assertIsNone(cpe_match_string.version_start_excluding)
self.assertIsNone(cpe_match_string.version_end_excluding)
self.assertIsNone(cpe_match_string.version_start_including)
self.assertIsNone(cpe_match_string.version_end_including)

def test_cpe_last_modified(self):
data = get_cpe_match_data()
cpe_match_string = CPEMatchString.from_dict(data)

self.assertEqual(
datetime(2019, 7, 22, 16, 37, 38, 133000, tzinfo=timezone.utc),
cpe_match_string.cpe_last_modified,
)

def test_matches(self):
"""
Test the matches list of a CPEMatchString
Expand Down

0 comments on commit 55e5552

Please sign in to comment.