|
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 IP address report. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import Qt |
|
11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem |
|
12 |
|
13 from .Ui_VirusTotalIpReportDialog import Ui_VirusTotalIpReportDialog |
|
14 |
|
15 |
|
16 class VirusTotalIpReportDialog(QDialog, Ui_VirusTotalIpReportDialog): |
|
17 """ |
|
18 Class implementing a dialog to show the VirusTotal IP address report. |
|
19 """ |
|
20 def __init__(self, ip, owner, resolutions, urls, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param ip IP address |
|
25 @type str |
|
26 @param owner owner of the IP address |
|
27 @type str |
|
28 @param resolutions list of resolved host names |
|
29 @type list of dict |
|
30 @param urls list of detected URLs |
|
31 @type list of dict |
|
32 @param parent reference to the parent widget |
|
33 @type QWidget |
|
34 """ |
|
35 super(VirusTotalIpReportDialog, self).__init__(parent) |
|
36 self.setupUi(self) |
|
37 self.setWindowFlags(Qt.Window) |
|
38 |
|
39 self.headerLabel.setText( |
|
40 self.tr("<b>Report for IP {0}</b>").format(ip)) |
|
41 self.ownerLabel.setText(owner) |
|
42 |
|
43 for resolution in resolutions: |
|
44 QTreeWidgetItem( |
|
45 self.resolutionsList, |
|
46 [resolution["hostname"], |
|
47 resolution["last_resolved"].split()[0]] |
|
48 ) |
|
49 self.resolutionsList.resizeColumnToContents(0) |
|
50 self.resolutionsList.resizeColumnToContents(1) |
|
51 self.resolutionsList.sortByColumn(0, Qt.AscendingOrder) |
|
52 |
|
53 if not urls: |
|
54 self.detectedUrlsGroup.setVisible(False) |
|
55 for url in urls: |
|
56 QTreeWidgetItem( |
|
57 self.urlsList, |
|
58 [url["url"], |
|
59 self.tr("{0}/{1}", "positives / total").format( |
|
60 url["positives"], url["total"]), |
|
61 url["scan_date"].split()[0]] |
|
62 ) |
|
63 self.urlsList.resizeColumnToContents(0) |
|
64 self.urlsList.resizeColumnToContents(1) |
|
65 self.urlsList.resizeColumnToContents(2) |
|
66 self.urlsList.sortByColumn(0, Qt.AscendingOrder) |