|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2015 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 Qt |
|
11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem |
|
12 |
|
13 from .Ui_VirusTotalDomainReportDialog import Ui_VirusTotalDomainReportDialog |
|
14 |
|
15 |
|
16 class VirusTotalDomainReportDialog(QDialog, Ui_VirusTotalDomainReportDialog): |
|
17 """ |
|
18 Class implementing a dialog to show the VirusTotal domain report. |
|
19 """ |
|
20 def __init__(self, domain, resolutions, urls, subdomains, |
|
21 bdCategory, tmCategory, wtsCategory, categories, parent=None): |
|
22 """ |
|
23 Constructor |
|
24 |
|
25 @param domain domain name |
|
26 @type str |
|
27 @param resolutions list of resolved host names |
|
28 @type list of dict |
|
29 @param urls list of detected URLs |
|
30 @type list of dict |
|
31 @param subdomains list of subdomains |
|
32 @type list of str |
|
33 @param bdCategory BitDefender categorization |
|
34 @type str |
|
35 @param tmCategory TrendMicro categorization |
|
36 @type str |
|
37 @param wtsCategory Websense ThreatSeeker categorization |
|
38 @type str |
|
39 @param categories list of categorizations |
|
40 @type list of str |
|
41 @param parent reference to the parent widget |
|
42 @type QWidget |
|
43 """ |
|
44 super(VirusTotalDomainReportDialog, self).__init__(parent) |
|
45 self.setupUi(self) |
|
46 self.setWindowFlags(Qt.Window) |
|
47 |
|
48 self.headerLabel.setText( |
|
49 self.tr("<b>Report for domain {0}</b>").format(domain)) |
|
50 |
|
51 for resolution in resolutions: |
|
52 QTreeWidgetItem( |
|
53 self.resolutionsList, |
|
54 [resolution["ip_address"], |
|
55 resolution["last_resolved"].split()[0]] |
|
56 ) |
|
57 self.resolutionsList.resizeColumnToContents(0) |
|
58 self.resolutionsList.resizeColumnToContents(1) |
|
59 self.resolutionsList.sortByColumn(0, Qt.AscendingOrder) |
|
60 |
|
61 if not urls: |
|
62 self.detectedUrlsGroup.setVisible(False) |
|
63 for url in urls: |
|
64 QTreeWidgetItem( |
|
65 self.urlsList, |
|
66 [url["url"], |
|
67 self.tr("{0}/{1}", "positives / total").format( |
|
68 url["positives"], url["total"]), |
|
69 url["scan_date"].split()[0]] |
|
70 ) |
|
71 self.urlsList.resizeColumnToContents(0) |
|
72 self.urlsList.resizeColumnToContents(1) |
|
73 self.urlsList.resizeColumnToContents(2) |
|
74 self.urlsList.sortByColumn(0, Qt.AscendingOrder) |
|
75 |
|
76 if not subdomains: |
|
77 self.subdomainsGroup.setVisible(False) |
|
78 else: |
|
79 self.subdomainsList.addItems(subdomains) |
|
80 self.subdomainsList.sortItems() |
|
81 |
|
82 self.bdLabel.setText(bdCategory) |
|
83 self.tmLabel.setText(tmCategory) |
|
84 self.wtsLabel.setText(wtsCategory) |
|
85 ## |
|
86 ## if not categories: |
|
87 ## self.categoriesList.setVisible(False) |
|
88 ## else: |
|
89 ## self.categoriesList.addItems(categories) |
|
90 ## self.categoriesList.sortItems() |