Exemple #1
0
 def test_parser_wapiti_xml_parse_report_invalid_no_vulns(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_invalid_no_vulns
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=[report_invalid_no_vulns]):
         WapitiXMLParser.__format__ = ''
         my_wapiti = WapitiXMLParser()
         report = my_wapiti.parse_report()
         self.assertTrue(report == [])
Exemple #2
0
 def test_parser_wapiti_xml_parse_metadata_version_not_supported(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     stripped_report = report_high.replace('Wapiti 2.3.0', 'Wapiti VERSIONTHATWONTEVEREXIST')
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=[stripped_report]):
         WapitiXMLParser.__format__ = ''
         my_wapiti = WapitiXMLParser('foo', 'bar', first=True)
         with self.assertRaises(NotSupportedVersionError):
             my_wapiti.parse_metadata()
Exemple #3
0
 def test_parser_wapiti_xml_parse_metadata(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find',
                     return_value=[report_high]):
         WapitiXMLParser.__format__ = ''
         my_wapiti = WapitiXMLParser('foo', 'bar', first=True)
         assert_that(my_wapiti.parse_metadata(),
                     has_entry('generatorVersion', '2.3.0'))
Exemple #4
0
 def test_parser_wapiti_xml_parse_report_invalid_no_vulns(
         self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_invalid_no_vulns
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find',
                     return_value=[report_invalid_no_vulns]):
         WapitiXMLParser.__format__ = ''
         my_wapiti = WapitiXMLParser()
         report = my_wapiti.parse_report()
         self.assertTrue(report == [])
Exemple #5
0
 def test_parser_wapiti_xml_parse_report(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=[report_high]):
         WapitiXMLParser.__format__ = ''
         my_wapiti = WapitiXMLParser()
         report = my_wapiti.parse_report()
         assert_that(report, has_items(*[{'ranking': HIGH, 'name': 'Cross Site Scripting', 'description': '\nCross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications which allow code injection by malicious web users into the web pages viewed by other users. Examples of such code include HTML code and client-side scripts.            '}] * 1))
         assert_that(report, is_not(has_item([{'ranking': LOW}])))
         assert_that(report, is_not(has_item([{'ranking': UNKNOWN}])))
         assert_that(report, is_not(has_item([{'ranking': INFO}])))
         assert_that(report, is_not(has_item([{'ranking': MEDIUM}])))
Exemple #6
0
 def test_parser_wapiti_xml_parse_metadata_version_not_supported(
         self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     stripped_report = report_high.replace(
         'Wapiti 2.3.0', 'Wapiti VERSIONTHATWONTEVEREXIST')
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find',
                     return_value=[stripped_report]):
         WapitiXMLParser.__format__ = ''
         my_wapiti = WapitiXMLParser('foo', 'bar', first=True)
         with self.assertRaises(NotSupportedVersionError):
             my_wapiti.parse_metadata()
Exemple #7
0
 def test_parser_wapiti_xml_is_mine_no_version(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     stripped_report = report_high.replace('"generatorVersion"',
                                           '"generatorINVALIDHEADER"')
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find',
                     return_value=[stripped_report]):
         WapitiXMLParser.__format__ = ''
         self.assertFalse(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #8
0
 def test_parser_wapiti_xml_is_mine_no_report_infos(self,
                                                    mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     stripped_report = report_high.replace('report_infos',
                                           'INFOSTHATWONTBEFOUND')
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find',
                     return_value=[stripped_report]):
         WapitiXMLParser.__format__ = ''
         self.assertFalse(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #9
0
 def test_parser_wapiti_xml_is_mine_version_not_supported(
         self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     stripped_report = report_high.replace(
         'Wapiti 2.3.0', 'Wapiti VERSIONTHATWONTEVEREXIST')
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find',
                     return_value=[stripped_report]):
         WapitiXMLParser.__format__ = ''
         self.assertFalse(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #10
0
 def test_parser_wapiti_xml_is_mine_invalid_tool_name(
         self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     stripped_report = report_high.replace(
         '<info name="generatorName">wapiti</info>',
         '<info name="generatorName">INVALIDTOOLNAME</info>')
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find',
                     return_value=[stripped_report]):
         WapitiXMLParser.__format__ = ''
         self.assertFalse(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #11
0
 def test_parser_wapiti_xml_parse_report(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find',
                     return_value=[report_high]):
         WapitiXMLParser.__format__ = ''
         my_wapiti = WapitiXMLParser()
         report = my_wapiti.parse_report()
         assert_that(
             report,
             has_items(*[{
                 'ranking':
                 HIGH,
                 'name':
                 'Cross Site Scripting',
                 'description':
                 '\nCross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications which allow code injection by malicious web users into the web pages viewed by other users. Examples of such code include HTML code and client-side scripts.            '
             }] * 1))
         assert_that(report, is_not(has_item([{'ranking': LOW}])))
         assert_that(report, is_not(has_item([{'ranking': UNKNOWN}])))
         assert_that(report, is_not(has_item([{'ranking': INFO}])))
         assert_that(report, is_not(has_item([{'ranking': MEDIUM}])))
Exemple #12
0
 def test_parser_wapiti_xml_is_mine(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find',
                     return_value=[report_high]):
         WapitiXMLParser.__format__ = ''
         self.assertTrue(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #13
0
 def test_parser_wapiti_xml_parse_metadata(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=[report_high]):
         WapitiXMLParser.__format__ = ''
         my_wapiti = WapitiXMLParser('foo', 'bar', first=True)
         assert_that(my_wapiti.parse_metadata(), has_entry('generatorVersion', '2.3.0'))
Exemple #14
0
 def test_parser_wapiti_xml_is_mine_no_report_infos(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     stripped_report = report_high.replace('report_infos', 'INFOSTHATWONTBEFOUND')
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=[stripped_report]):
         WapitiXMLParser.__format__ = ''
         self.assertFalse(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #15
0
 def test_parser_wapiti_xml_is_mine_invalid_tool_name(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     stripped_report = report_high.replace('<info name="generatorName">wapiti</info>', '<info name="generatorName">INVALIDTOOLNAME</info>')
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=[stripped_report]):
         WapitiXMLParser.__format__ = ''
         self.assertFalse(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #16
0
 def test_parser_wapiti_xml_is_mine_version_not_supported(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     stripped_report = report_high.replace('Wapiti 2.3.0', 'Wapiti VERSIONTHATWONTEVEREXIST')
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=[stripped_report]):
         WapitiXMLParser.__format__ = ''
         self.assertFalse(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #17
0
 def test_parser_wapiti_xml_is_mine_no_version(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     stripped_report = report_high.replace('"generatorVersion"', '"generatorINVALIDHEADER"')
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=[stripped_report]):
         WapitiXMLParser.__format__ = ''
         self.assertFalse(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #18
0
 def test_parser_wapiti_xml_is_not_mine(self, mock_lxml_etree_parse):
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=['foo.bar']):
         WapitiXMLParser.__format__ = ''
         self.assertFalse(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #19
0
 def test_parser_wapiti_xml_is_mine(self, mock_lxml_etree_parse):
     from .wapiti_reports_2_3_0 import report_high
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find', return_value=[report_high]):
         WapitiXMLParser.__format__ = ''
         self.assertTrue(WapitiXMLParser.is_mine('foo', 'bar', first=True))
Exemple #20
0
 def test_parser_wapiti_xml_is_not_mine(self, mock_lxml_etree_parse):
     with mock.patch('ptp.libptp.parser.AbstractParser._recursive_find',
                     return_value=['foo.bar']):
         WapitiXMLParser.__format__ = ''
         self.assertFalse(WapitiXMLParser.is_mine('foo', 'bar', first=True))