eric7/WebBrowser/VirusTotal/VirusTotalDomainReportDialog.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to show the VirusTotal domain report.
8 """
9
10 from PyQt5.QtCore import pyqtSlot, Qt
11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
12
13 from .Ui_VirusTotalDomainReportDialog import Ui_VirusTotalDomainReportDialog
14
15 import UI.PixmapCache
16
17
18 class VirusTotalDomainReportDialog(QDialog, Ui_VirusTotalDomainReportDialog):
19 """
20 Class implementing a dialog to show the VirusTotal domain report.
21 """
22 def __init__(self, domain, resolutions, urls, subdomains,
23 bdCategory, tmCategory, wtsCategory, whois, parent=None):
24 """
25 Constructor
26
27 @param domain domain name
28 @type str
29 @param resolutions list of resolved host names
30 @type list of dict
31 @param urls list of detected URLs
32 @type list of dict
33 @param subdomains list of subdomains
34 @type list of str
35 @param bdCategory BitDefender categorization
36 @type str
37 @param tmCategory TrendMicro categorization
38 @type str
39 @param wtsCategory Websense ThreatSeeker categorization
40 @type str
41 @param whois whois information
42 @type str
43 @param parent reference to the parent widget
44 @type QWidget
45 """
46 super().__init__(parent)
47 self.setupUi(self)
48 self.setWindowFlags(Qt.WindowType.Window)
49
50 self.headerLabel.setText(
51 self.tr("<b>Report for domain {0}</b>").format(domain))
52 self.headerPixmap.setPixmap(
53 UI.PixmapCache.getPixmap("virustotal"))
54
55 for resolution in resolutions:
56 QTreeWidgetItem(
57 self.resolutionsList,
58 [resolution["ip_address"],
59 resolution["last_resolved"].split()[0]]
60 )
61 self.resolutionsList.resizeColumnToContents(0)
62 self.resolutionsList.resizeColumnToContents(1)
63 self.resolutionsList.sortByColumn(0, Qt.SortOrder.AscendingOrder)
64
65 if not urls:
66 self.detectedUrlsGroup.setVisible(False)
67 for url in urls:
68 QTreeWidgetItem(
69 self.urlsList,
70 [url["url"],
71 self.tr("{0}/{1}", "positives / total").format(
72 url["positives"], url["total"]),
73 url["scan_date"].split()[0]]
74 )
75 self.urlsList.resizeColumnToContents(0)
76 self.urlsList.resizeColumnToContents(1)
77 self.urlsList.resizeColumnToContents(2)
78 self.urlsList.sortByColumn(0, Qt.SortOrder.AscendingOrder)
79
80 if not subdomains:
81 self.subdomainsGroup.setVisible(False)
82 else:
83 self.subdomainsList.addItems(subdomains)
84 self.subdomainsList.sortItems()
85
86 self.bdLabel.setText(bdCategory)
87 self.tmLabel.setText(tmCategory)
88 self.wtsLabel.setText(wtsCategory)
89
90 self.__whois = whois
91 self.__whoisDomain = domain
92 self.whoisButton.setEnabled(bool(whois))
93
94 @pyqtSlot()
95 def on_whoisButton_clicked(self):
96 """
97 Private slot to show the whois information.
98 """
99 from .VirusTotalWhoisDialog import VirusTotalWhoisDialog
100 dlg = VirusTotalWhoisDialog(self.__whoisDomain, self.__whois)
101 dlg.exec()

eric ide

mercurial