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