コード例 #1
0
    def vulns_table(self):
        column_names = [
            "Location", "Category", "Vulnerability", "Description", "Evidence"
        ]
        vuln_table = PrettyTable(column_names, hrules=ALL)
        vuln_table.align = "l"
        vuln_table.max_width = MAX_TABLE_WIDTH
        vuln_table.sortby = "Category"
        vuln_table.reversesort = True
        vuln_table.padding_width = 1
        vuln_table.header_style = "upper"

        vulnerabilities_lock.acquire()
        for vuln in vulnerabilities:
            row = [
                "{}:{}".format(vuln.host, vuln.port) if vuln.host else "",
                vuln.category.name,
                vuln.get_name(),
                vuln.explain()
            ]
            evidence = str(vuln.evidence)[:EVIDENCE_PREVIEW] + "..." if len(
                str(vuln.evidence)) > EVIDENCE_PREVIEW else str(vuln.evidence)
            row.append(evidence)
            vuln_table.add_row(row)
        vulnerabilities_lock.release()
        return "\nVulnerabilities\n{}\n".format(vuln_table)
コード例 #2
0
ファイル: yaml.py プロジェクト: ndevops/kube-hunter
 def get_vulenrabilities(self):
     vulnerabilities_lock.acquire()
     vulnerabilities_data = [{
         "location":
         "{}:{}".format(vuln.host, vuln.port) if vuln.host else "",
         "category":
         vuln.category.name,
         "vulnerability":
         vuln.get_name(),
         "description":
         vuln.explain(),
         "evidence":
         str(vuln.evidence)
     } for vuln in vulnerabilities]
     vulnerabilities_lock.release()
     return vulnerabilities_data
コード例 #3
0
    def get_report(self):
        """generates report tables"""
        output = ""

        vulnerabilities_lock.acquire()
        vulnerabilities_len = len(vulnerabilities)
        vulnerabilities_lock.release()

        services_lock.acquire()
        services_len = len(services)
        services_lock.release()

        if services_len:
            output += self.nodes_table()
            if not config.mapping:
                output += self.services_table()
                if vulnerabilities_len:
                    output += self.vulns_table()
                else:
                    output += "\nNo vulnerabilities were found"
        else:
            print("\nKube Hunter couldn't find any clusters")
            # print("\nKube Hunter couldn't find any clusters. {}".format("Maybe try with --active?" if not config.active else ""))
        return output