Initial NVD mirror
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import unittest
|
||||
from datetime import datetime, timezone
|
||||
from scripts.sync import windows, timestamp, CVE_RE
|
||||
|
||||
class TestNvd(unittest.TestCase):
|
||||
def test_windows(self):
|
||||
a = datetime(2026, 1, 1, tzinfo=timezone.utc)
|
||||
b = datetime(2026, 3, 3, tzinfo=timezone.utc)
|
||||
result = list(windows(a,b,30))
|
||||
self.assertEqual(len(result), 3)
|
||||
self.assertEqual(result[0][0], a)
|
||||
self.assertEqual(result[-1][1], b)
|
||||
self.assertTrue(all((e-s).days <= 30 for s,e in result))
|
||||
def test_id(self):
|
||||
self.assertTrue(CVE_RE.fullmatch('CVE-2026-12345'))
|
||||
self.assertFalse(CVE_RE.fullmatch('CVE-2026-../1234'))
|
||||
def test_timestamp(self):
|
||||
self.assertEqual(timestamp(datetime(2026,1,1,tzinfo=timezone.utc)), '2026-01-01T00:00:00.000+00:00')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user