Skip to content

Commit a215412

Browse files
timopollmeiergreenbonebot
authored andcommitted
Fix: Make cpe_last_modified of CPE matches optional
1 parent b2fa245 commit a215412

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

pontos/nvd/models/cpe_match_string.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CPEMatchString(Model):
3838
version_end_including: Optional end of the matching version range, including the given version
3939
version_end_excluding: Optional end of the matching version range, excluding the given version
4040
status: Status of the CPE match
41-
cpe_last_modified: The date the CPEs list of the match was last modified
41+
cpe_last_modified: Optional date the CPEs list of the match was last modified
4242
created: Creation date of the CPE
4343
last_modified: Last modification date of the CPE
4444
matches: List of CPEs matching the criteria string and the optional range limits
@@ -47,9 +47,9 @@ class CPEMatchString(Model):
4747
match_criteria_id: UUID
4848
criteria: str
4949
status: str
50-
cpe_last_modified: datetime
5150
created: datetime
5251
last_modified: datetime
52+
cpe_last_modified: Optional[datetime] = None
5353
matches: List[CPEMatch] = field(default_factory=list)
5454
version_start_including: Optional[str] = None
5555
version_start_excluding: Optional[str] = None

tests/nvd/models/test_cpe_match.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_required_only(self):
2222
data = get_cpe_match_data()
2323
data.__delitem__("matches")
2424
data.__delitem__("version_end_including")
25+
data.__delitem__("cpe_last_modified")
2526

2627
cpe_match_string = CPEMatchString.from_dict(data)
2728

@@ -37,10 +38,6 @@ def test_required_only(self):
3738
"Active",
3839
cpe_match_string.status,
3940
)
40-
self.assertEqual(
41-
datetime(2019, 7, 22, 16, 37, 38, 133000, tzinfo=timezone.utc),
42-
cpe_match_string.cpe_last_modified,
43-
)
4441
self.assertEqual(
4542
datetime(2019, 6, 17, 9, 16, 33, 960000, tzinfo=timezone.utc),
4643
cpe_match_string.created,
@@ -52,11 +49,21 @@ def test_required_only(self):
5249

5350
self.assertEqual([], cpe_match_string.matches)
5451

52+
self.assertIsNone(cpe_match_string.cpe_last_modified)
5553
self.assertIsNone(cpe_match_string.version_start_excluding)
5654
self.assertIsNone(cpe_match_string.version_end_excluding)
5755
self.assertIsNone(cpe_match_string.version_start_including)
5856
self.assertIsNone(cpe_match_string.version_end_including)
5957

58+
def test_cpe_last_modified(self):
59+
data = get_cpe_match_data()
60+
cpe_match_string = CPEMatchString.from_dict(data)
61+
62+
self.assertEqual(
63+
datetime(2019, 7, 22, 16, 37, 38, 133000, tzinfo=timezone.utc),
64+
cpe_match_string.cpe_last_modified,
65+
)
66+
6067
def test_matches(self):
6168
"""
6269
Test the matches list of a CPEMatchString

0 commit comments

Comments
 (0)