| @@ 698-750 (lines=53) @@ | ||
| 695 | time.sleep(0.01) |
|
| 696 | self.assertEqual(daemon.get_scan_vts(scan_id), {}) |
|
| 697 | ||
| 698 | def test_scan_with_vts_and_param(self): |
|
| 699 | daemon = DummyWrapper([]) |
|
| 700 | ||
| 701 | # Raise because no vt_param id attribute |
|
| 702 | cmd = secET.fromstring( |
|
| 703 | '<start_scan ' |
|
| 704 | 'target="localhost" ports="80, 443">' |
|
| 705 | '<scanner_params /><vt_selection><vt_si' |
|
| 706 | 'ngle id="1234"><vt_value>200</vt_value>' |
|
| 707 | '</vt_single></vt_selection></start_scan>' |
|
| 708 | ) |
|
| 709 | self.assertRaises(OSPDError, daemon.handle_start_scan_command, cmd) |
|
| 710 | ||
| 711 | # No error |
|
| 712 | response = secET.fromstring( |
|
| 713 | daemon.handle_command( |
|
| 714 | '<start_scan ' |
|
| 715 | 'target="localhost" ports="80, 443">' |
|
| 716 | '<scanner_params /><vt_selection><vt' |
|
| 717 | '_single id="1234"><vt_value id="ABC">200' |
|
| 718 | '</vt_value></vt_single></vt_selection>' |
|
| 719 | '</start_scan>' |
|
| 720 | ) |
|
| 721 | ) |
|
| 722 | scan_id = response.findtext('id') |
|
| 723 | time.sleep(0.01) |
|
| 724 | self.assertEqual( |
|
| 725 | daemon.get_scan_vts(scan_id), |
|
| 726 | {'1234': {'ABC': '200'}, 'vt_groups': []}, |
|
| 727 | ) |
|
| 728 | ||
| 729 | # Raise because no vtgroup filter attribute |
|
| 730 | cmd = secET.fromstring( |
|
| 731 | '<start_scan ' |
|
| 732 | 'target="localhost" ports="80, 443">' |
|
| 733 | '<scanner_params /><vt_selection><vt_group/>' |
|
| 734 | '</vt_selection></start_scan>' |
|
| 735 | ) |
|
| 736 | self.assertRaises(OSPDError, daemon.handle_start_scan_command, cmd) |
|
| 737 | ||
| 738 | # No error |
|
| 739 | response = secET.fromstring( |
|
| 740 | daemon.handle_command( |
|
| 741 | '<start_scan ' |
|
| 742 | 'target="localhost" ports="80, 443">' |
|
| 743 | '<scanner_params /><vt_selection>' |
|
| 744 | '<vt_group filter="a"/>' |
|
| 745 | '</vt_selection></start_scan>' |
|
| 746 | ) |
|
| 747 | ) |
|
| 748 | scan_id = response.findtext('id') |
|
| 749 | time.sleep(0.01) |
|
| 750 | self.assertEqual(daemon.get_scan_vts(scan_id), {'vt_groups': ['a']}) |
|
| 751 | ||
| 752 | def test_billon_laughs(self): |
|
| 753 | # pylint: disable=line-too-long |
|
| @@ 659-696 (lines=38) @@ | ||
| 656 | cmd = secET.fromstring('<stop_scan />') |
|
| 657 | self.assertRaises(OSPDError, daemon.handle_stop_scan_command, cmd) |
|
| 658 | ||
| 659 | def test_scan_with_vts(self): |
|
| 660 | daemon = DummyWrapper([]) |
|
| 661 | cmd = secET.fromstring( |
|
| 662 | '<start_scan ' |
|
| 663 | 'target="localhost" ports="80, 443">' |
|
| 664 | '<scanner_params /><vt_selection />' |
|
| 665 | '</start_scan>' |
|
| 666 | ) |
|
| 667 | self.assertRaises(OSPDError, daemon.handle_start_scan_command, cmd) |
|
| 668 | ||
| 669 | # With one vt, without params |
|
| 670 | response = secET.fromstring( |
|
| 671 | daemon.handle_command( |
|
| 672 | '<start_scan ' |
|
| 673 | 'target="localhost" ports="80, 443">' |
|
| 674 | '<scanner_params /><vt_selection>' |
|
| 675 | '<vt_single id="1.2.3.4" />' |
|
| 676 | '</vt_selection></start_scan>' |
|
| 677 | ) |
|
| 678 | ) |
|
| 679 | scan_id = response.findtext('id') |
|
| 680 | time.sleep(0.01) |
|
| 681 | self.assertEqual( |
|
| 682 | daemon.get_scan_vts(scan_id), {'1.2.3.4': {}, 'vt_groups': []} |
|
| 683 | ) |
|
| 684 | self.assertNotEqual(daemon.get_scan_vts(scan_id), {'1.2.3.6': {}}) |
|
| 685 | ||
| 686 | # With out vtS |
|
| 687 | response = secET.fromstring( |
|
| 688 | daemon.handle_command( |
|
| 689 | '<start_scan ' |
|
| 690 | 'target="localhost" ports="80, 443">' |
|
| 691 | '<scanner_params /></start_scan>' |
|
| 692 | ) |
|
| 693 | ) |
|
| 694 | scan_id = response.findtext('id') |
|
| 695 | time.sleep(0.01) |
|
| 696 | self.assertEqual(daemon.get_scan_vts(scan_id), {}) |
|
| 697 | ||
| 698 | def test_scan_with_vts_and_param(self): |
|
| 699 | daemon = DummyWrapper([]) |
|