From 96e16e30fc843542d70275d3ecd327e73ac71cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lopes?= Date: Wed, 10 Oct 2018 15:57:02 -0300 Subject: [PATCH] added method to retrieve list of netbox prefixes --- netbox-scanner/dac.py | 7 +++++++ netbox-scanner/nbscan.py | 4 ++++ setup.py | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/netbox-scanner/dac.py b/netbox-scanner/dac.py index 5cf588c..d93817d 100644 --- a/netbox-scanner/dac.py +++ b/netbox-scanner/dac.py @@ -1,3 +1,10 @@ +# This script can be used sanitize the list of networks +# to be scanned. In practice, (almost) the same routine +# is executed everytime NetBoxScanner().sync() is +# called, but if you want to debug this list or even +# keep a more organized version, you can use dac.py. +## + import re from config import NETWORKS diff --git a/netbox-scanner/nbscan.py b/netbox-scanner/nbscan.py index 4773468..3eb3bf0 100644 --- a/netbox-scanner/nbscan.py +++ b/netbox-scanner/nbscan.py @@ -41,6 +41,10 @@ class NetBoxScanner(object): if not re.match(ipv4, net): return net return False + + def get_networks(self): + '''Retrieves all networks/prefixes recorded into NetBox.''' + return [str(net) for net in self.netbox.ipam.prefixes.all()] def get_description(self, address, name, cpe): '''Define a description based on hostname and CPE''' diff --git a/setup.py b/setup.py index e1a5755..95de765 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open('README.md', 'r') as fh: setuptools.setup( name='netbox-scanner', - version='0.5.5', + version='0.5.6', author='José Lopes de Oliveira Jr.', author_email='jlojunior@gmail.com', description='A scanner util for NetBox',