src/eric7/WebBrowser/VirusTotal/VirusTotalDomainReportDialog.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2015 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to show the VirusTotal domain report.
8 """
9
10 from PyQt6.QtCore import pyqtSlot, Qt
11 from PyQt6.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 categories, webutation, 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 categories dictionary with various categorizations with keys
36 'bitdefender', 'sophos', 'valkyrie', 'alpha', 'forcepoint'
37 @type dict
38 @param webutation dictionary with Webutation data with keys
39 'adult', 'safety', 'verdict'
40 @param whois whois information
41 @type str
42 @param parent reference to the parent widget
43 @type QWidget
44 """
45 super().__init__(parent)
46 self.setupUi(self)
47 self.setWindowFlags(Qt.WindowType.Window)
48
49 self.headerLabel.setText(
50 self.tr("<b>Report for domain {0}</b>").format(domain))
51 self.headerPixmap.setPixmap(
52 UI.PixmapCache.getPixmap("virustotal"))
53
54 for resolution in resolutions:
55 QTreeWidgetItem(
56 self.resolutionsList,
57 [resolution["ip_address"],
58 resolution["last_resolved"].split()[0]]
59 )
60 self.resolutionsList.resizeColumnToContents(0)
61 self.resolutionsList.resizeColumnToContents(1)
62 self.resolutionsList.sortByColumn(0, Qt.SortOrder.AscendingOrder)
63
64 for url in urls:
65 QTreeWidgetItem(
66 self.urlsList,
67 [url["url"],
68 self.tr("{0}/{1}", "positives / total").format(
69 url["positives"], url["total"]),
70 url["scan_date"].split()[0]]
71 )
72 self.urlsList.resizeColumnToContents(0)
73 self.urlsList.resizeColumnToContents(1)
74 self.urlsList.resizeColumnToContents(2)
75 self.urlsList.sortByColumn(0, Qt.SortOrder.AscendingOrder)
76
77 if subdomains:
78 self.subdomainsList.addItems(subdomains)
79 self.subdomainsList.sortItems()
80
81 self.bdLabel.setText(categories["bitdefender"])
82 self.soLabel.setText(categories["sophos"])
83 self.vvLabel.setText(categories["valkyrie"])
84 self.amLabel.setText(categories["alpha"])
85 self.ftsLabel.setText(categories["forcepoint"])
86
87 self.webutationAdultLabel.setText(webutation["adult"])
88 self.webutationSafetyLabel.setText(str(webutation["safety"]))
89 self.webutationVerdictLabel.setText(webutation["verdict"])
90
91 self.__whois = whois
92 self.__whoisDomain = domain
93 self.whoisButton.setEnabled(bool(whois))
94
95 @pyqtSlot()
96 def on_whoisButton_clicked(self):
97 """
98 Private slot to show the whois information.
99 """
100 from .VirusTotalWhoisDialog import VirusTotalWhoisDialog
101 dlg = VirusTotalWhoisDialog(self.__whoisDomain, self.__whois)
102 dlg.exec()

eric ide

mercurial