def setupInitialObjects(): """FOR TESTING - create some basic objects""" generalPluginFamily = PluginFamily(shortName="General") generalPluginFamily.save() openPort = Plugin(severity="I", pluginId=0, version="$Revision 0$", pluginName="Open network port detected", pluginFamily=generalPluginFamily) openPort.save() net = Network(name="Test network") net.save() fw_group = FirewallGroup(shortName="FC", description="Fully Closed") fw_group.save() ns = NetworkSlice(startIP="130.126.0.0", endIP="130.126.255.255", firewallGroup=fw_group, network=net) ns.save() unreviewed = Classification(shortName="Unreviewed", description="Vulnerability has not been reviewed by a system or service"\ " admin yet.") unreviewed.save() unapproved = Status(shortName="Unapproved", description="Classification has not been approved by the Security Office"\ " yet.") unapproved.save() scanner = Scanner(shortName="Nessus", importEnabled=True, importModuleName="loaders.nessus") scanner.save() return openPort, net, fw_group, ns, unreviewed, unapproved, scanner
vulnerability.result = result if not vuln.get("pluginID"): continue if vuln["pluginID"] == "0": plugin = openPort else: pluginVersion = vuln.get("plugin_version", "$Revision 0$") plugins = Plugin.objects.filter(pluginId=vuln["pluginID"], version=pluginVersion) if not plugins: if settings.DEBUG: print "Adding plugin %s." % vuln["pluginName"] plugin = Plugin() plugin_severity_map = {"3": "H", "2": "M", "1": "L", "0": "I"} plugin.severity = plugin_severity_map[vuln["severity"]] plugin.pluginId = vuln["pluginID"] plugin.version = pluginVersion plugin.pluginName = vuln["pluginName"] pluginFamilies = PluginFamily.objects.filter\ (shortName=vuln["pluginFamily"]) if not pluginFamilies: if settings.DEBUG: print "Adding plugin family %s." % vuln["pluginFamily"] pluginFamily = PluginFamily() pluginFamily.shortName = vuln["pluginFamily"] pluginFamily.save() elif len(pluginFamilies) == 1: