|
@@ 404-432 (lines=29) @@
|
| 401 |
|
"Loaded %d/%d advisories from %s", 0, 1, purepath |
| 402 |
|
) |
| 403 |
|
|
| 404 |
|
def test_upload_lsc_from_csv_reader_sucess(self): |
| 405 |
|
general_metadata_dict = { |
| 406 |
|
'VULDETECT': 'Checks if a vulnerable package version is present on the target host.', |
| 407 |
|
'SOLUTION': 'Please install the updated package(s).', |
| 408 |
|
'SOLUTION_TYPE': 'VendorFix', |
| 409 |
|
'QOD_TYPE': 'package', |
| 410 |
|
} |
| 411 |
|
|
| 412 |
|
notus = NotusMetadataHandler( |
| 413 |
|
nvti=self.nvti, metadata_path="./tests/notus" |
| 414 |
|
) |
| 415 |
|
notus.nvti.add_vt_to_cache.return_value = None |
| 416 |
|
logging.Logger.debug = MagicMock() |
| 417 |
|
path = Path("./tests/notus/example.csv").resolve() |
| 418 |
|
purepath = PurePath(path).name |
| 419 |
|
family = "Some family" |
| 420 |
|
with path.open("r") as openfile: |
| 421 |
|
for line_string in openfile: |
| 422 |
|
if line_string.startswith("{"): |
| 423 |
|
break |
| 424 |
|
reader = DictReader(openfile) |
| 425 |
|
|
| 426 |
|
ret = notus.upload_lsc_from_csv_reader( |
| 427 |
|
purepath, family, general_metadata_dict, reader |
| 428 |
|
) |
| 429 |
|
|
| 430 |
|
self.assertTrue(ret) |
| 431 |
|
logging.Logger.debug.assert_called_with( |
| 432 |
|
"Loaded %d/%d advisories from %s", 1, 1, purepath |
| 433 |
|
) |
| 434 |
|
|
| 435 |
|
@patch('ospd_openvas.notus.metadata.Openvas') |
|
@@ 373-401 (lines=29) @@
|
| 370 |
|
|
| 371 |
|
logging.Logger.warning.assert_not_called() |
| 372 |
|
|
| 373 |
|
def test_upload_lsc_from_csv_reader_failed(self): |
| 374 |
|
general_metadata_dict = { |
| 375 |
|
'VULDETECT': 'Checks if a vulnerable package version is present on the target host.', |
| 376 |
|
'SOLUTION': 'Please install the updated package(s).', |
| 377 |
|
'SOLUTION_TYPE': 'VendorFix', |
| 378 |
|
'QOD_TYPE': 'package', |
| 379 |
|
} |
| 380 |
|
|
| 381 |
|
notus = NotusMetadataHandler( |
| 382 |
|
nvti=self.nvti, metadata_path="./tests/notus" |
| 383 |
|
) |
| 384 |
|
notus.nvti.add_vt_to_cache.side_effect = OspdOpenvasError |
| 385 |
|
logging.Logger.debug = MagicMock() |
| 386 |
|
path = Path("./tests/notus/example.csv").resolve() |
| 387 |
|
purepath = PurePath(path).name |
| 388 |
|
family = "Some family" |
| 389 |
|
with path.open("r") as openfile: |
| 390 |
|
for line_string in openfile: |
| 391 |
|
if line_string.startswith("{"): |
| 392 |
|
break |
| 393 |
|
reader = DictReader(openfile) |
| 394 |
|
|
| 395 |
|
ret = notus.upload_lsc_from_csv_reader( |
| 396 |
|
purepath, family, general_metadata_dict, reader |
| 397 |
|
) |
| 398 |
|
|
| 399 |
|
self.assertFalse(ret) |
| 400 |
|
logging.Logger.debug.assert_called_with( |
| 401 |
|
"Loaded %d/%d advisories from %s", 0, 1, purepath |
| 402 |
|
) |
| 403 |
|
|
| 404 |
|
def test_upload_lsc_from_csv_reader_sucess(self): |