Example #1
0
                            kwargs["tool_id"] = l_plugin_id
                            if l_family in CATEGORIES:
                                clazz = globals()[ CATEGORIES[l_family] ]
                        except Exception, e:
                            tb = format_exc()
                            Logger.log_error_verbose(
                                "Failed to find category %r, reason: %s" %
                                (l_plugin_id, str(e)))
                            Logger.log_error_more_verbose(tb)

                # Create the vulnerability instance.
                vuln = clazz(**kwargs)

                # Link the vulnerability to the resource.
                if target is not None:
                    target.add_vulnerability(vuln)

                # Add the vulnerability.
                results.append(vuln)

            # Skip on error.
            except Exception, e:
                t = format_exc()
                Logger.log_error_verbose(
                    "Error parsing OpenVAS results: %s" % str(e))
                Logger.log_error_more_verbose(t)
                continue

        # Return the converted results.
        return results
Example #2
0
    def parse_results(openvas_results, ip = None):
        """
        Convert the OpenVAS scan results to the GoLismero data model.

        :param openvas_results: OpenVAS scan results.
        :type openvas_results: list(OpenVASResult)

        :param ip: (Optional) IP address to link the vulnerabilities to.
        :type ip: IP | None

        :returns: Scan results converted to the GoLismero data model.
        :rtype: list(Data)
        """

        # This is where we'll store the results.
        results = []

        # Remember the hosts we've seen so we don't create them twice.
        hosts_seen = {}

        LEVELS_CORRESPONDENCES = {
            'debug' : 'low',
            'log'   : 'informational',
            'low'   : "low",
            'medium': 'middle',
            'high'  : "high",
        }

        # For each OpenVAS result...
        for opv in openvas_results:
            try:

                # Get the host.
                host = opv.host

                # Get or create the vulnerable resource.
                target = ip
                if host in hosts_seen:
                    target = hosts_seen[host]
                elif not ip or ip.address != host:
                    try:
                        target = IP(host)
                    except ValueError:
                        target = Domain(host)
                    hosts_seen[host] = target
                    results.append(target)

                # Get the threat level.
                try:
                    level = opv.threat.lower()
                except Exception:
                    level = "informational"

                # Get the metadata.
                nvt = opv.nvt
                ##references = nvt.xrefs
                ##cvss = nvt.cvss
                ##cve = nvt.cve
                ##vulnerability_type = nvt.category

                # Get the vulnerability description.
                description = opv.description
                if not description:
                    description = nvt.description
                    if not description:
                        description = nvt.summary
                        if not description:
                            description = "A vulnerability has been found."
                if opv.notes:
                    description += "\n" + "\n".join(
                        " - " + note.text
                        for note in opv.notes
                    )

                # Create the vulnerability instance.
                vuln = Vulnerability(
                    level       = LEVELS_CORRESPONDENCES[level.lower()],
                    description = description,
                    ##cvss        = cvss,
                    ##cve         = cve,
                    ##references  = references.split("\n"),
                )
                ##vuln.vulnerability_type = vulnerability_type

                # Link the vulnerability to the resource.
                if target is not None:
                    target.add_vulnerability(vuln)

            # Skip on error.
            except Exception, e:
                t = format_exc()
                Logger.log_error_verbose("Error parsing OpenVAS results: %s" % str(e))
                Logger.log_error_more_verbose(t)
                continue

            # Add the vulnerability.
            results.append(vuln)
Example #3
0
    def parse_results(openvas_results, ip=None):
        """
        Convert the OpenVAS scan results to the GoLismero data model.

        :param openvas_results: OpenVAS scan results.
        :type openvas_results: list(OpenVASResult)

        :param ip: (Optional) IP address to link the vulnerabilities to.
        :type ip: IP | None

        :returns: Scan results converted to the GoLismero data model.
        :rtype: list(Data)
        """

        # This is where we'll store the results.
        results = []

        # Remember the hosts we've seen so we don't create them twice.
        hosts_seen = {}

        LEVELS_CORRESPONDENCES = {
            'debug': 'low',
            'log': 'informational',
            'low': "low",
            'medium': 'middle',
            'high': "high",
        }

        # For each OpenVAS result...
        for opv in openvas_results:
            try:

                # Get the host.
                host = opv.host

                # Get or create the vulnerable resource.
                target = ip
                if host in hosts_seen:
                    target = hosts_seen[host]
                elif not ip or ip.address != host:
                    try:
                        target = IP(host)
                    except ValueError:
                        target = Domain(host)
                    hosts_seen[host] = target
                    results.append(target)

                # Get the threat level.
                try:
                    level = opv.threat.lower()
                except Exception:
                    level = "informational"

                # Get the metadata.
                nvt = opv.nvt
                ##references = nvt.xrefs
                ##cvss = nvt.cvss
                ##cve = nvt.cve
                ##vulnerability_type = nvt.category

                # Get the vulnerability description.
                description = opv.description
                if not description:
                    description = nvt.description
                    if not description:
                        description = nvt.summary
                        if not description:
                            description = "A vulnerability has been found."
                if opv.notes:
                    description += "\n" + "\n".join(" - " + note.text
                                                    for note in opv.notes)

                # Create the vulnerability instance.
                vuln = Vulnerability(
                    level=LEVELS_CORRESPONDENCES[level.lower()],
                    description=description,
                    ##cvss        = cvss,
                    ##cve         = cve,
                    ##references  = references.split("\n"),
                )
                ##vuln.vulnerability_type = vulnerability_type

                # Link the vulnerability to the resource.
                if target is not None:
                    target.add_vulnerability(vuln)

            # Skip on error.
            except Exception, e:
                t = format_exc()
                Logger.log_error_verbose("Error parsing OpenVAS results: %s" %
                                         str(e))
                Logger.log_error_more_verbose(t)
                continue

            # Add the vulnerability.
            results.append(vuln)