Esempio n. 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
Esempio n. 2
0
                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"])

            vulnerability.plugin = plugin
            vulnerability.output = vuln.get("plugin_output", "")
            vulnerability.port = vuln.get("port", "0")
            vulnerability.serviceName = vuln.get("svc_name", "Unknown")

            vulnerability_protocol_map = {"tcp": "T", "udp": "U", "icmp": "I",
                                          "none": "N", "other": "O"}
            vulnerability.protocol = vulnerability_protocol_map[