Пример #1
0
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
Пример #2
0
            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:
                    pluginFamily = pluginFamilies[0]
                else:
                    raise KeyError("Multiple plugin families defined with "\
                                   "the name %s." % vuln["pluginFamily"])
                plugin.pluginFamily = pluginFamily
                plugin.save()
            elif len(plugins) == 1:
                plugin = plugins[0]
            else:
                raise KeyError("Multiple plugins defined with the name %s "
                               "and version %s.") % (vuln["pluginID"],
                                                     vuln["plugin_version"])