Пример #1
0
 def test_backend_factory(self):
     """ test_factory BackendPluginFactory.create(**url)
         Invoke factory and test that the object is of the right classes
     """
     for url in self.urls:
         backend = BackendPluginFactory.create(**url)
         self.assertEqual(isinstance(backend, NessusBackendPlugin), True)
         className = "Nessus%sPlugin" % url['plugin_name'].title()
         print("DEBUUUUUUUUG", className, backend.__class__.__name__)
         self.assertEqual(backend.__class__.__name__, className, True)
 def test_backend_factory(self):
     """ test_factory BackendPluginFactory.create(**url)
         Invoke factory and test that the object is of the right classes
     """
     for url in self.urls:
         backend = BackendPluginFactory.create(**url)
         self.assertEqual(isinstance(backend, NessusBackendPlugin), True)
         className = "Nessus%sPlugin" % url["plugin_name"].title()
         print("DEBUUUUUUUUG", className, backend.__class__.__name__)
         self.assertEqual(backend.__class__.__name__, className, True)
 def test_backend_insert(self):
     """ test_insert
         best way to insert is to call save() of nmapreport :P
         should add some code to test the output as save will catch exception raise by insert
         I dunno how to do that...
     """
     for nrp in self.reportList:
         for url in self.urls:
             # create the backend factory object
             backend = BackendPluginFactory.create(**url)
             # save the report
             returncode = nrp.save(backend)
             # test return code
             self.assertNotEqual(returncode, None)
Пример #4
0
 def test_backend_insert(self):
     """ test_insert
         best way to insert is to call save() of nmapreport :P
         should add some code to test the output as save will catch exception raise by insert
         I dunno how to do that...
     """
     for nrp in self.reportList:
         for url in self.urls:
             #create the backend factory object
             backend = BackendPluginFactory.create(**url)
             #save the report
             returncode = nrp.save(backend)
             #test return code
             self.assertNotEqual(returncode, None)
 def test_backend_delete(self):
     """ test_backend_delete
         inset all report and save the returned id in a list
         for each id remove the item and test if not present
     """
     id_list = []
     result_list = []
     for url in self.urls:
         backend = BackendPluginFactory.create(**url)
         for nrp in self.reportList:
             id_list.append(nrp.save(backend))
         for rep_id in id_list:
             result_list.append(backend.delete(rep_id))
             self.assertEqual(backend.get(rep_id), None)
         id_list = []
         result_list = []
Пример #6
0
 def test_backend_delete(self):
     """ test_backend_delete
         inset all report and save the returned id in a list
         for each id remove the item and test if not present
     """
     id_list = []
     result_list = []
     for url in self.urls:
         backend = BackendPluginFactory.create(**url)
         for nrp in self.reportList:
             id_list.append(nrp.save(backend))
         for rep_id in id_list:
             result_list.append(backend.delete(rep_id))
             self.assertEqual(backend.get(rep_id), None)
         id_list = []
         result_list = []
 def test_backend_getall(self):
     """test_backend_getall
        silly test to be review
     """
     id_list = []
     result_list = []
     for url in self.urls:
         backend = BackendPluginFactory.create(**url)
         for nrp in self.reportList:
             id_list.append(nrp.save(backend))
         # ES may have 1 second delay between put&get
         time.sleep(1)
         result_list = backend.getall()
         print(len(result_list))
         print(len(self.reportList))
         self.assertTrue((len(result_list) > 0))
         id_list = []
         result_list = []
Пример #8
0
 def test_backend_getall(self):
     """test_backend_getall
        silly test to be review
     """
     id_list = []
     result_list = []
     for url in self.urls:
         backend = BackendPluginFactory.create(**url)
         for nrp in self.reportList:
             id_list.append(nrp.save(backend))
         #ES may have 1 second delay between put&get
         time.sleep(1)
         result_list = backend.getall()
         print(len(result_list))
         print(len(self.reportList))
         self.assertTrue((len(result_list) > 0))
         id_list = []
         result_list = []
 def test_backend_get(self):
     """ test_backend_get
         inset all report and save the returned id in a list
         then get each id and create a new list of report
         compare each report (assume eq)
     """
     id_list = []
     result_list = []
     for url in self.urls:
         backend = BackendPluginFactory.create(**url)
         for nrp in self.reportList:
             id_list.append(nrp.save(backend))
         # ES may have 1 second delay between put&get
         time.sleep(1)
         for rep_id in id_list:
             result_list.append(backend.get(rep_id))
         self.assertEqual(len(result_list), len(self.reportList))
         self.assertEqual((result_list), (self.reportList))
         id_list = []
         result_list = []
Пример #10
0
 def test_backend_get(self):
     """ test_backend_get
         inset all report and save the returned id in a list
         then get each id and create a new list of report
         compare each report (assume eq)
     """
     id_list = []
     result_list = []
     for url in self.urls:
         backend = BackendPluginFactory.create(**url)
         for nrp in self.reportList:
             id_list.append(nrp.save(backend))
         #ES may have 1 second delay between put&get
         time.sleep(1)
         for rep_id in id_list:
             result_list.append(backend.get(rep_id))
         self.assertEqual(len(result_list), len(self.reportList))
         self.assertEqual((result_list), (self.reportList))
         id_list = []
         result_list = []
Пример #11
0
from datetime import datetime

# parse args
parser = argparse.ArgumentParser(
    description='This script will load nessusV2 report in an ES datastore')
parser.add_argument('--filename',
                    default="../libnessus/test/files/nessus*",
                    help="path or pattern to a nessusV2 xml")
parser.add_argument('--es_trace',
                    default="/dev/null",
                    help="elasticsearch tracefile location")
args = parser.parse_args()

url = {'plugin_name': "es"}
backend = BackendPluginFactory.create(**url)
index_settings = {
    u'mappings': {
        u'vulnerability': {
            u'properties': {
                u'host-fqdn': {
                    u'type': u'string'
                },
                u'host_ip': {
                    u'type': 'ip',
                    "index": "not_analyzed",
                    "doc_values": "true"
                },
                u'host_name': {
                    u'type': u'string',
                    "index": "not_analyzed",
Пример #12
0
from datetime import datetime

# parse args
parser = argparse.ArgumentParser(
    description='This script will load nessusV2 report in an ES datastore')
parser.add_argument('--filename',
                    default="../libnessus/test/files/nessus*",
                    help="path or pattern to a nessusV2 xml")
parser.add_argument('--es_trace',
                    default="/dev/null",
                    help="elasticsearch tracefile location")
args = parser.parse_args()

url = {'plugin_name': "es"}
backend = BackendPluginFactory.create(**url)
index_settings = {u'mappings': {u'vulnerability': {u'properties': {u'host-fqdn': {u'type': u'string'},
    u'host_ip': {u'type': 'ip', "index" : "not_analyzed","doc_values": "true"},
    u'host_name': {u'type': u'string', "index" : "not_analyzed","doc_values": "true"},
    u'operating-system': {u'type': u'string', "index" : "not_analyzed","doc_values": "true"},
    u'scantime': {u'format': u'dateOptionalTime', u'type': u'date'},
    u'system-type': {u'type': u'string'},
    u'vulninfo': {u'properties': {u'apple-sa': {u'type': u'string'},
      u'bid': {u'type': u'string'},
      u'canvas_package': {u'type': u'string'},
      u'cert': {u'type': u'string'},
      u'cpe': {u'type': u'string', "index" : "not_analyzed","doc_values": "true"},
      u'cve': {u'type': u'string'},
      u'cvss_base_score': {u'type': u'float'},
      u'cvss_temporal_score': {u'type': u'string'},
      u'cvss_temporal_vector': {u'type': u'string'},