112 if protocol == "": |
112 if protocol == "": |
113 urlStr = self.GetFileReportUrl |
113 urlStr = self.GetFileReportUrl |
114 else: |
114 else: |
115 urlStr = self.GetFileReportPattern.format(protocol) |
115 urlStr = self.GetFileReportPattern.format(protocol) |
116 request = QNetworkRequest(QUrl(urlStr)) |
116 request = QNetworkRequest(QUrl(urlStr)) |
117 request.setHeader(QNetworkRequest.ContentTypeHeader, |
117 request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, |
118 "application/x-www-form-urlencoded") |
118 "application/x-www-form-urlencoded") |
119 params = QByteArray("apikey={0}&resource={1}".format( |
119 params = QByteArray("apikey={0}&resource={1}".format( |
120 key, self.TestServiceKeyScanID).encode("utf-8")) |
120 key, self.TestServiceKeyScanID).encode("utf-8")) |
121 |
121 |
122 import WebBrowser.WebBrowserWindow |
122 import WebBrowser.WebBrowserWindow |
154 Public method to submit an URL to be scanned. |
154 Public method to submit an URL to be scanned. |
155 |
155 |
156 @param url url to be scanned (QUrl) |
156 @param url url to be scanned (QUrl) |
157 """ |
157 """ |
158 request = QNetworkRequest(QUrl(self.ScanUrlUrl)) |
158 request = QNetworkRequest(QUrl(self.ScanUrlUrl)) |
159 request.setHeader(QNetworkRequest.ContentTypeHeader, |
159 request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, |
160 "application/x-www-form-urlencoded") |
160 "application/x-www-form-urlencoded") |
161 params = QByteArray("apikey={0}&url=".format( |
161 params = QByteArray("apikey={0}&url=".format( |
162 Preferences.getWebBrowser("VirusTotalServiceKey")) |
162 Preferences.getWebBrowser("VirusTotalServiceKey")) |
163 .encode("utf-8")).append(QUrl.toPercentEncoding(url.toString())) |
163 .encode("utf-8")).append(QUrl.toPercentEncoding(url.toString())) |
164 |
164 |
175 Private slot to determine the result of the URL scan submission. |
175 Private slot to determine the result of the URL scan submission. |
176 |
176 |
177 @param reply reference to the network reply |
177 @param reply reference to the network reply |
178 @type QNetworkReply |
178 @type QNetworkReply |
179 """ |
179 """ |
180 if reply.error() == QNetworkReply.NoError: |
180 if reply.error() == QNetworkReply.NetworkError.NoError: |
181 result = json.loads(str(reply.readAll(), "utf-8")) |
181 result = json.loads(str(reply.readAll(), "utf-8")) |
182 if result["response_code"] == self.ServiceResult_ItemPresent: |
182 if result["response_code"] == self.ServiceResult_ItemPresent: |
183 self.urlScanReport.emit(result["permalink"]) |
183 self.urlScanReport.emit(result["permalink"]) |
184 self.__getUrlScanReportUrl(result["scan_id"]) |
184 self.__getUrlScanReportUrl(result["scan_id"]) |
185 else: |
185 else: |
201 Private method to get the report URL for a URL scan. |
201 Private method to get the report URL for a URL scan. |
202 |
202 |
203 @param scanId ID of the scan to get the report URL for (string) |
203 @param scanId ID of the scan to get the report URL for (string) |
204 """ |
204 """ |
205 request = QNetworkRequest(QUrl(self.GetUrlReportUrl)) |
205 request = QNetworkRequest(QUrl(self.GetUrlReportUrl)) |
206 request.setHeader(QNetworkRequest.ContentTypeHeader, |
206 request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, |
207 "application/x-www-form-urlencoded") |
207 "application/x-www-form-urlencoded") |
208 params = QByteArray("apikey={0}&resource={1}".format( |
208 params = QByteArray("apikey={0}&resource={1}".format( |
209 Preferences.getWebBrowser("VirusTotalServiceKey"), scanId) |
209 Preferences.getWebBrowser("VirusTotalServiceKey"), scanId) |
210 .encode("utf-8")) |
210 .encode("utf-8")) |
211 |
211 |
223 |
223 |
224 @param reply reference to the network reply |
224 @param reply reference to the network reply |
225 @type QNetworkReply |
225 @type QNetworkReply |
226 request. |
226 request. |
227 """ |
227 """ |
228 if reply.error() == QNetworkReply.NoError: |
228 if reply.error() == QNetworkReply.NetworkError.NoError: |
229 result = json.loads(str(reply.readAll(), "utf-8")) |
229 result = json.loads(str(reply.readAll(), "utf-8")) |
230 if "filescan_id" in result and result["filescan_id"] is not None: |
230 if "filescan_id" in result and result["filescan_id"] is not None: |
231 self.__getFileScanReportUrl(result["filescan_id"]) |
231 self.__getFileScanReportUrl(result["filescan_id"]) |
232 self.__replies.remove(reply) |
232 self.__replies.remove(reply) |
233 reply.deleteLater() |
233 reply.deleteLater() |
237 Private method to get the report URL for a file scan. |
237 Private method to get the report URL for a file scan. |
238 |
238 |
239 @param scanId ID of the scan to get the report URL for (string) |
239 @param scanId ID of the scan to get the report URL for (string) |
240 """ |
240 """ |
241 request = QNetworkRequest(QUrl(self.GetFileReportUrl)) |
241 request = QNetworkRequest(QUrl(self.GetFileReportUrl)) |
242 request.setHeader(QNetworkRequest.ContentTypeHeader, |
242 request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, |
243 "application/x-www-form-urlencoded") |
243 "application/x-www-form-urlencoded") |
244 params = QByteArray("apikey={0}&resource={1}".format( |
244 params = QByteArray("apikey={0}&resource={1}".format( |
245 Preferences.getWebBrowser("VirusTotalServiceKey"), scanId) |
245 Preferences.getWebBrowser("VirusTotalServiceKey"), scanId) |
246 .encode("utf-8")) |
246 .encode("utf-8")) |
247 |
247 |
259 request. |
259 request. |
260 |
260 |
261 @param reply reference to the network reply |
261 @param reply reference to the network reply |
262 @type QNetworkReply |
262 @type QNetworkReply |
263 """ |
263 """ |
264 if reply.error() == QNetworkReply.NoError: |
264 if reply.error() == QNetworkReply.NetworkError.NoError: |
265 result = json.loads(str(reply.readAll(), "utf-8")) |
265 result = json.loads(str(reply.readAll(), "utf-8")) |
266 self.fileScanReport.emit(result["permalink"]) |
266 self.fileScanReport.emit(result["permalink"]) |
267 self.__replies.remove(reply) |
267 self.__replies.remove(reply) |
268 reply.deleteLater() |
268 reply.deleteLater() |
269 |
269 |
299 Private slot to process the IP address report data. |
299 Private slot to process the IP address report data. |
300 |
300 |
301 @param reply reference to the network reply |
301 @param reply reference to the network reply |
302 @type QNetworkReply |
302 @type QNetworkReply |
303 """ |
303 """ |
304 if reply.error() == QNetworkReply.NoError: |
304 if reply.error() == QNetworkReply.NetworkError.NoError: |
305 result = json.loads(str(reply.readAll(), "utf-8")) |
305 result = json.loads(str(reply.readAll(), "utf-8")) |
306 if result["response_code"] == 0: |
306 if result["response_code"] == 0: |
307 E5MessageBox.information( |
307 E5MessageBox.information( |
308 None, |
308 None, |
309 self.tr("VirusTotal IP Address Report"), |
309 self.tr("VirusTotal IP Address Report"), |
361 Private slot to process the IP address report data. |
361 Private slot to process the IP address report data. |
362 |
362 |
363 @param reply reference to the network reply |
363 @param reply reference to the network reply |
364 @type QNetworkReply |
364 @type QNetworkReply |
365 """ |
365 """ |
366 if reply.error() == QNetworkReply.NoError: |
366 if reply.error() == QNetworkReply.NetworkError.NoError: |
367 result = json.loads(str(reply.readAll(), "utf-8")) |
367 result = json.loads(str(reply.readAll(), "utf-8")) |
368 if result["response_code"] == 0: |
368 if result["response_code"] == 0: |
369 E5MessageBox.information( |
369 E5MessageBox.information( |
370 None, |
370 None, |
371 self.tr("VirusTotal Domain Report"), |
371 self.tr("VirusTotal Domain Report"), |