class NmapSqlPlugin(NmapBackendPlugin): (source)
This class handle the persistence of NmapRepport object in SQL backend Implementation is made using sqlalchemy(0.8.1) usage : #get a nmapReport object from libnmap.parser import NmapParser from libnmap.reportjson import ReportDecoder, ReportEncoder import json nmap_report_obj = NmapParser.parse_fromfile( '/home/vagrant/python-nmap-lib/libnmap/test/files/1_hosts.xml') #get a backend with in memory sqlite from libnmap.plugins.backendpluginFactory import BackendPluginFactory mybackend_mem = BackendPluginFactory.create(plugin_name='sql', url='sqlite://', echo=True) mybackend_mysql = BackendPluginFactory.create(plugin_name='sql', url='mysql+mysqldb://scott:tiger@localhost/foo', echo=True) mybackend = BackendPluginFactory.create(plugin_name='sql', url='sqlite:////tmp/reportdb.sql', echo=True) #lets save!! nmap_report_obj.save(mybackend) mybackend.getall() mybackend.get(1)
Class |
|
Embeded class for ORM map NmapReport to a simple three column table |
Method | __init__ |
constructor receive a **kwargs as the **kwargs in the sqlalchemy create_engine() method (see sqlalchemy docs) You must add to this **kwargs an 'url' key with the url to your database This constructor will : - create all the necessary obj to discuss with the DB - create all the mapping(ORM)... |
Method | delete |
Remove a report from the backend |
Method | get |
retrieve a NmapReport from the backend |
Method | getall |
:param filter: Nice to have implement a filter capability |
Method | insert |
insert NmapReport in the backend |
Instance Variable | engine |
Undocumented |
Instance Variable |
|
Undocumented |
Instance Variable | url |
Undocumented |
Inherited from NmapBackendPlugin
:
Instance Variable | dbname |
Undocumented |
Instance Variable | store |
Undocumented |
constructor receive a **kwargs as the **kwargs in the sqlalchemy create_engine() method (see sqlalchemy docs) You must add to this **kwargs an 'url' key with the url to your database This constructor will : - create all the necessary obj to discuss with the DB - create all the mapping(ORM) todo : support the : sqlalchemy.engine_from_config :param **kwargs: :raises: ValueError if no url is given, all exception sqlalchemy can throw ie sqlite in memory url='sqlite://' echo=True ie sqlite file on hd url='sqlite:////tmp/reportdb.sql' echo=True ie mysql url='mysql+mysqldb://scott:tiger@localhost/foo'
:param filter: Nice to have implement a filter capability :returns: collection of tuple (id,NmapReport)