|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.WebBrowser.SafeBrowsing.SafeBrowsingAPIClient</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.WebBrowser.SafeBrowsing.SafeBrowsingAPIClient</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing the low level interface for Google Safe Browsing. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>None</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 |
|
23 <tr> |
|
24 <td><a href="#SafeBrowsingAPIClient">SafeBrowsingAPIClient</a></td> |
|
25 <td>Class implementing the low level interface for Google Safe Browsing.</td> |
|
26 </tr> |
|
27 </table> |
|
28 <h3>Functions</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <hr /> |
|
34 <hr /> |
|
35 <a NAME="SafeBrowsingAPIClient" ID="SafeBrowsingAPIClient"></a> |
|
36 <h2>SafeBrowsingAPIClient</h2> |
|
37 |
|
38 <p> |
|
39 Class implementing the low level interface for Google Safe Browsing. |
|
40 </p> |
|
41 <h3>Signals</h3> |
|
42 <dl> |
|
43 |
|
44 <dt>networkError(str)</dt> |
|
45 <dd> |
|
46 emitted to indicate a network error |
|
47 </dd> |
|
48 </dl> |
|
49 <h3>Derived from</h3> |
|
50 QObject |
|
51 <h3>Class Attributes</h3> |
|
52 |
|
53 <table> |
|
54 <tr><td>ClientId</td></tr><tr><td>ClientVersion</td></tr><tr><td>GsbUrlTemplate</td></tr> |
|
55 </table> |
|
56 <h3>Class Methods</h3> |
|
57 |
|
58 <table> |
|
59 |
|
60 <tr> |
|
61 <td><a href="#SafeBrowsingAPIClient.definedPlatformTypes">definedPlatformTypes</a></td> |
|
62 <td>Class method to get all platform types defined in API v4.</td> |
|
63 </tr> |
|
64 <tr> |
|
65 <td><a href="#SafeBrowsingAPIClient.definedThreatEntryTypes">definedThreatEntryTypes</a></td> |
|
66 <td>Class method to get all threat entry types defined in API v4.</td> |
|
67 </tr> |
|
68 <tr> |
|
69 <td><a href="#SafeBrowsingAPIClient.definedThreatTypes">definedThreatTypes</a></td> |
|
70 <td>Class method to get all threat types defined in API v4.</td> |
|
71 </tr> |
|
72 <tr> |
|
73 <td><a href="#SafeBrowsingAPIClient.getPlatformString">getPlatformString</a></td> |
|
74 <td>Class method to get the platform string for a given platform type.</td> |
|
75 </tr> |
|
76 <tr> |
|
77 <td><a href="#SafeBrowsingAPIClient.getPlatformTypes">getPlatformTypes</a></td> |
|
78 <td>Class method to get the platform types for a given platform.</td> |
|
79 </tr> |
|
80 <tr> |
|
81 <td><a href="#SafeBrowsingAPIClient.getThreatEntryString">getThreatEntryString</a></td> |
|
82 <td>Class method to get the threat entry string.</td> |
|
83 </tr> |
|
84 <tr> |
|
85 <td><a href="#SafeBrowsingAPIClient.getThreatMessage">getThreatMessage</a></td> |
|
86 <td>Class method to get a warning message for the given threat type.</td> |
|
87 </tr> |
|
88 <tr> |
|
89 <td><a href="#SafeBrowsingAPIClient.getThreatType">getThreatType</a></td> |
|
90 <td>Class method to get a display string for a given threat type.</td> |
|
91 </tr> |
|
92 </table> |
|
93 <h3>Methods</h3> |
|
94 |
|
95 <table> |
|
96 |
|
97 <tr> |
|
98 <td><a href="#SafeBrowsingAPIClient.__init__">SafeBrowsingAPIClient</a></td> |
|
99 <td>Constructor</td> |
|
100 </tr> |
|
101 <tr> |
|
102 <td><a href="#SafeBrowsingAPIClient.__extractData">__extractData</a></td> |
|
103 <td>Private method to extract the data of a network reply.</td> |
|
104 </tr> |
|
105 <tr> |
|
106 <td><a href="#SafeBrowsingAPIClient.__setWaitDuration">__setWaitDuration</a></td> |
|
107 <td>Private method to set the minimum wait duration.</td> |
|
108 </tr> |
|
109 <tr> |
|
110 <td><a href="#SafeBrowsingAPIClient.fairUseDelayExpired">fairUseDelayExpired</a></td> |
|
111 <td>Public method to check, if the fair use wait period has expired.</td> |
|
112 </tr> |
|
113 <tr> |
|
114 <td><a href="#SafeBrowsingAPIClient.getFairUseDelayExpirationDateTime">getFairUseDelayExpirationDateTime</a></td> |
|
115 <td>Public method to get the date and time the fair use delay will expire.</td> |
|
116 </tr> |
|
117 <tr> |
|
118 <td><a href="#SafeBrowsingAPIClient.getFullHashes">getFullHashes</a></td> |
|
119 <td>Public method to find full hashes matching hash prefixes.</td> |
|
120 </tr> |
|
121 <tr> |
|
122 <td><a href="#SafeBrowsingAPIClient.getThreatLists">getThreatLists</a></td> |
|
123 <td>Public method to retrieve all available threat lists.</td> |
|
124 </tr> |
|
125 <tr> |
|
126 <td><a href="#SafeBrowsingAPIClient.getThreatsUpdate">getThreatsUpdate</a></td> |
|
127 <td>Public method to fetch hash prefix updates for the given threat list.</td> |
|
128 </tr> |
|
129 <tr> |
|
130 <td><a href="#SafeBrowsingAPIClient.lookupUrl">lookupUrl</a></td> |
|
131 <td>Public method to send an URL to Google for checking.</td> |
|
132 </tr> |
|
133 <tr> |
|
134 <td><a href="#SafeBrowsingAPIClient.setApiKey">setApiKey</a></td> |
|
135 <td>Public method to set the API key.</td> |
|
136 </tr> |
|
137 </table> |
|
138 <h3>Static Methods</h3> |
|
139 |
|
140 <table> |
|
141 <tr><td>None</td></tr> |
|
142 </table> |
|
143 |
|
144 <a NAME="SafeBrowsingAPIClient.definedPlatformTypes" ID="SafeBrowsingAPIClient.definedPlatformTypes"></a> |
|
145 <h4>SafeBrowsingAPIClient.definedPlatformTypes (class method)</h4> |
|
146 <b>definedPlatformTypes</b>(<i></i>) |
|
147 |
|
148 <p> |
|
149 Class method to get all platform types defined in API v4. |
|
150 </p> |
|
151 <dl> |
|
152 <dt>Return:</dt> |
|
153 <dd> |
|
154 list of all defined platform types |
|
155 </dd> |
|
156 </dl> |
|
157 <dl> |
|
158 <dt>Return Type:</dt> |
|
159 <dd> |
|
160 list of str |
|
161 </dd> |
|
162 </dl> |
|
163 <a NAME="SafeBrowsingAPIClient.definedThreatEntryTypes" ID="SafeBrowsingAPIClient.definedThreatEntryTypes"></a> |
|
164 <h4>SafeBrowsingAPIClient.definedThreatEntryTypes (class method)</h4> |
|
165 <b>definedThreatEntryTypes</b>(<i></i>) |
|
166 |
|
167 <p> |
|
168 Class method to get all threat entry types defined in API v4. |
|
169 </p> |
|
170 <dl> |
|
171 <dt>Return:</dt> |
|
172 <dd> |
|
173 list of all defined threat entry types |
|
174 </dd> |
|
175 </dl> |
|
176 <dl> |
|
177 <dt>Return Type:</dt> |
|
178 <dd> |
|
179 list of str |
|
180 </dd> |
|
181 </dl> |
|
182 <a NAME="SafeBrowsingAPIClient.definedThreatTypes" ID="SafeBrowsingAPIClient.definedThreatTypes"></a> |
|
183 <h4>SafeBrowsingAPIClient.definedThreatTypes (class method)</h4> |
|
184 <b>definedThreatTypes</b>(<i></i>) |
|
185 |
|
186 <p> |
|
187 Class method to get all threat types defined in API v4. |
|
188 </p> |
|
189 <dl> |
|
190 <dt>Return:</dt> |
|
191 <dd> |
|
192 list of defined threat types |
|
193 </dd> |
|
194 </dl> |
|
195 <dl> |
|
196 <dt>Return Type:</dt> |
|
197 <dd> |
|
198 list of str |
|
199 </dd> |
|
200 </dl> |
|
201 <a NAME="SafeBrowsingAPIClient.getPlatformString" ID="SafeBrowsingAPIClient.getPlatformString"></a> |
|
202 <h4>SafeBrowsingAPIClient.getPlatformString (class method)</h4> |
|
203 <b>getPlatformString</b>(<i>platformType</i>) |
|
204 |
|
205 <p> |
|
206 Class method to get the platform string for a given platform type. |
|
207 </p> |
|
208 <dl> |
|
209 |
|
210 <dt><i>platformType</i> (str)</dt> |
|
211 <dd> |
|
212 platform type as defined in the v4 API |
|
213 </dd> |
|
214 </dl> |
|
215 <dl> |
|
216 <dt>Return:</dt> |
|
217 <dd> |
|
218 platform string |
|
219 </dd> |
|
220 </dl> |
|
221 <dl> |
|
222 <dt>Return Type:</dt> |
|
223 <dd> |
|
224 str |
|
225 </dd> |
|
226 </dl> |
|
227 <a NAME="SafeBrowsingAPIClient.getPlatformTypes" ID="SafeBrowsingAPIClient.getPlatformTypes"></a> |
|
228 <h4>SafeBrowsingAPIClient.getPlatformTypes (class method)</h4> |
|
229 <b>getPlatformTypes</b>(<i>platform</i>) |
|
230 |
|
231 <p> |
|
232 Class method to get the platform types for a given platform. |
|
233 </p> |
|
234 <dl> |
|
235 |
|
236 <dt><i>platform</i> (str (one of 'linux', 'windows', 'macos'))</dt> |
|
237 <dd> |
|
238 platform string |
|
239 </dd> |
|
240 </dl> |
|
241 <dl> |
|
242 <dt>Return:</dt> |
|
243 <dd> |
|
244 list of platform types as defined in the v4 API for the |
|
245 given platform |
|
246 </dd> |
|
247 </dl> |
|
248 <dl> |
|
249 <dt>Return Type:</dt> |
|
250 <dd> |
|
251 list of str |
|
252 </dd> |
|
253 </dl> |
|
254 <dl> |
|
255 |
|
256 <dt>Raises <b>ValueError</b>:</dt> |
|
257 <dd> |
|
258 raised to indicate an invalid platform string |
|
259 </dd> |
|
260 </dl> |
|
261 <a NAME="SafeBrowsingAPIClient.getThreatEntryString" ID="SafeBrowsingAPIClient.getThreatEntryString"></a> |
|
262 <h4>SafeBrowsingAPIClient.getThreatEntryString (class method)</h4> |
|
263 <b>getThreatEntryString</b>(<i>threatEntry</i>) |
|
264 |
|
265 <p> |
|
266 Class method to get the threat entry string. |
|
267 </p> |
|
268 <dl> |
|
269 |
|
270 <dt><i>threatEntry</i> (str)</dt> |
|
271 <dd> |
|
272 threat entry type as defined in the v4 API |
|
273 </dd> |
|
274 </dl> |
|
275 <dl> |
|
276 <dt>Return:</dt> |
|
277 <dd> |
|
278 threat entry string |
|
279 </dd> |
|
280 </dl> |
|
281 <dl> |
|
282 <dt>Return Type:</dt> |
|
283 <dd> |
|
284 str |
|
285 </dd> |
|
286 </dl> |
|
287 <a NAME="SafeBrowsingAPIClient.getThreatMessage" ID="SafeBrowsingAPIClient.getThreatMessage"></a> |
|
288 <h4>SafeBrowsingAPIClient.getThreatMessage (class method)</h4> |
|
289 <b>getThreatMessage</b>(<i>threatType</i>) |
|
290 |
|
291 <p> |
|
292 Class method to get a warning message for the given threat type. |
|
293 </p> |
|
294 <dl> |
|
295 |
|
296 <dt><i>threatType</i> (str)</dt> |
|
297 <dd> |
|
298 threat type to get the message for |
|
299 </dd> |
|
300 </dl> |
|
301 <dl> |
|
302 <dt>Return:</dt> |
|
303 <dd> |
|
304 threat message |
|
305 </dd> |
|
306 </dl> |
|
307 <dl> |
|
308 <dt>Return Type:</dt> |
|
309 <dd> |
|
310 str |
|
311 </dd> |
|
312 </dl> |
|
313 <a NAME="SafeBrowsingAPIClient.getThreatType" ID="SafeBrowsingAPIClient.getThreatType"></a> |
|
314 <h4>SafeBrowsingAPIClient.getThreatType (class method)</h4> |
|
315 <b>getThreatType</b>(<i>threatType</i>) |
|
316 |
|
317 <p> |
|
318 Class method to get a display string for a given threat type. |
|
319 </p> |
|
320 <dl> |
|
321 |
|
322 <dt><i>threatType</i> (str)</dt> |
|
323 <dd> |
|
324 threat type to get display string for |
|
325 </dd> |
|
326 </dl> |
|
327 <dl> |
|
328 <dt>Return:</dt> |
|
329 <dd> |
|
330 display string |
|
331 </dd> |
|
332 </dl> |
|
333 <dl> |
|
334 <dt>Return Type:</dt> |
|
335 <dd> |
|
336 str |
|
337 </dd> |
|
338 </dl> |
|
339 <a NAME="SafeBrowsingAPIClient.__init__" ID="SafeBrowsingAPIClient.__init__"></a> |
|
340 <h4>SafeBrowsingAPIClient (Constructor)</h4> |
|
341 <b>SafeBrowsingAPIClient</b>(<i>apiKey, fairUse=True, parent=None</i>) |
|
342 |
|
343 <p> |
|
344 Constructor |
|
345 </p> |
|
346 <dl> |
|
347 |
|
348 <dt><i>apiKey</i> (str)</dt> |
|
349 <dd> |
|
350 API key to be used |
|
351 </dd> |
|
352 <dt><i>fairUse</i> (bool)</dt> |
|
353 <dd> |
|
354 flag indicating to follow the fair use policy |
|
355 </dd> |
|
356 <dt><i>parent</i> (QObject)</dt> |
|
357 <dd> |
|
358 reference to the parent object |
|
359 </dd> |
|
360 </dl> |
|
361 <a NAME="SafeBrowsingAPIClient.__extractData" ID="SafeBrowsingAPIClient.__extractData"></a> |
|
362 <h4>SafeBrowsingAPIClient.__extractData</h4> |
|
363 <b>__extractData</b>(<i>reply</i>) |
|
364 |
|
365 <p> |
|
366 Private method to extract the data of a network reply. |
|
367 </p> |
|
368 <dl> |
|
369 |
|
370 <dt><i>reply</i> (QNetworkReply)</dt> |
|
371 <dd> |
|
372 reference to the network reply object |
|
373 </dd> |
|
374 </dl> |
|
375 <dl> |
|
376 <dt>Return:</dt> |
|
377 <dd> |
|
378 extracted data |
|
379 </dd> |
|
380 </dl> |
|
381 <dl> |
|
382 <dt>Return Type:</dt> |
|
383 <dd> |
|
384 list or dict |
|
385 </dd> |
|
386 </dl> |
|
387 <a NAME="SafeBrowsingAPIClient.__setWaitDuration" ID="SafeBrowsingAPIClient.__setWaitDuration"></a> |
|
388 <h4>SafeBrowsingAPIClient.__setWaitDuration</h4> |
|
389 <b>__setWaitDuration</b>(<i>minimumWaitDuration</i>) |
|
390 |
|
391 <p> |
|
392 Private method to set the minimum wait duration. |
|
393 </p> |
|
394 <dl> |
|
395 |
|
396 <dt><i>minimumWaitDuration</i> (str)</dt> |
|
397 <dd> |
|
398 duration to be set |
|
399 </dd> |
|
400 </dl> |
|
401 <a NAME="SafeBrowsingAPIClient.fairUseDelayExpired" ID="SafeBrowsingAPIClient.fairUseDelayExpired"></a> |
|
402 <h4>SafeBrowsingAPIClient.fairUseDelayExpired</h4> |
|
403 <b>fairUseDelayExpired</b>(<i></i>) |
|
404 |
|
405 <p> |
|
406 Public method to check, if the fair use wait period has expired. |
|
407 </p> |
|
408 <dl> |
|
409 <dt>Return:</dt> |
|
410 <dd> |
|
411 flag indicating expiration |
|
412 </dd> |
|
413 </dl> |
|
414 <dl> |
|
415 <dt>Return Type:</dt> |
|
416 <dd> |
|
417 bool |
|
418 </dd> |
|
419 </dl> |
|
420 <a NAME="SafeBrowsingAPIClient.getFairUseDelayExpirationDateTime" ID="SafeBrowsingAPIClient.getFairUseDelayExpirationDateTime"></a> |
|
421 <h4>SafeBrowsingAPIClient.getFairUseDelayExpirationDateTime</h4> |
|
422 <b>getFairUseDelayExpirationDateTime</b>(<i></i>) |
|
423 |
|
424 <p> |
|
425 Public method to get the date and time the fair use delay will expire. |
|
426 </p> |
|
427 <dl> |
|
428 <dt>Return:</dt> |
|
429 <dd> |
|
430 fair use delay expiration date and time |
|
431 </dd> |
|
432 </dl> |
|
433 <dl> |
|
434 <dt>Return Type:</dt> |
|
435 <dd> |
|
436 QDateTime |
|
437 </dd> |
|
438 </dl> |
|
439 <a NAME="SafeBrowsingAPIClient.getFullHashes" ID="SafeBrowsingAPIClient.getFullHashes"></a> |
|
440 <h4>SafeBrowsingAPIClient.getFullHashes</h4> |
|
441 <b>getFullHashes</b>(<i>prefixes, clientState</i>) |
|
442 |
|
443 <p> |
|
444 Public method to find full hashes matching hash prefixes. |
|
445 </p> |
|
446 <dl> |
|
447 |
|
448 <dt><i>prefixes</i> (list of bytes)</dt> |
|
449 <dd> |
|
450 list of hash prefixes to find |
|
451 </dd> |
|
452 <dt><i>clientState</i> (dict)</dt> |
|
453 <dd> |
|
454 dictionary of client states with keys like |
|
455 (threatType, platformType, threatEntryType) |
|
456 </dd> |
|
457 </dl> |
|
458 <dl> |
|
459 <dt>Return:</dt> |
|
460 <dd> |
|
461 dictionary containing the list of found hashes and the |
|
462 negative cache duration |
|
463 </dd> |
|
464 </dl> |
|
465 <dl> |
|
466 <dt>Return Type:</dt> |
|
467 <dd> |
|
468 dict |
|
469 </dd> |
|
470 </dl> |
|
471 <a NAME="SafeBrowsingAPIClient.getThreatLists" ID="SafeBrowsingAPIClient.getThreatLists"></a> |
|
472 <h4>SafeBrowsingAPIClient.getThreatLists</h4> |
|
473 <b>getThreatLists</b>(<i></i>) |
|
474 |
|
475 <p> |
|
476 Public method to retrieve all available threat lists. |
|
477 </p> |
|
478 <dl> |
|
479 <dt>Return:</dt> |
|
480 <dd> |
|
481 tuple containing list of threat lists and an error message |
|
482 </dd> |
|
483 </dl> |
|
484 <dl> |
|
485 <dt>Return Type:</dt> |
|
486 <dd> |
|
487 tuple of (list of dict containing 'threatType', 'platformType' |
|
488 and 'threatEntryType', bool) |
|
489 </dd> |
|
490 </dl> |
|
491 <a NAME="SafeBrowsingAPIClient.getThreatsUpdate" ID="SafeBrowsingAPIClient.getThreatsUpdate"></a> |
|
492 <h4>SafeBrowsingAPIClient.getThreatsUpdate</h4> |
|
493 <b>getThreatsUpdate</b>(<i>clientStates</i>) |
|
494 |
|
495 <p> |
|
496 Public method to fetch hash prefix updates for the given threat list. |
|
497 </p> |
|
498 <dl> |
|
499 |
|
500 <dt><i>clientStates</i> (dict)</dt> |
|
501 <dd> |
|
502 dictionary of client states with keys like |
|
503 (threatType, platformType, threatEntryType) |
|
504 </dd> |
|
505 </dl> |
|
506 <dl> |
|
507 <dt>Return:</dt> |
|
508 <dd> |
|
509 tuple containing the list of threat updates and an error |
|
510 message |
|
511 </dd> |
|
512 </dl> |
|
513 <dl> |
|
514 <dt>Return Type:</dt> |
|
515 <dd> |
|
516 tuple of (list of dict, bool) |
|
517 </dd> |
|
518 </dl> |
|
519 <a NAME="SafeBrowsingAPIClient.lookupUrl" ID="SafeBrowsingAPIClient.lookupUrl"></a> |
|
520 <h4>SafeBrowsingAPIClient.lookupUrl</h4> |
|
521 <b>lookupUrl</b>(<i>url, platforms</i>) |
|
522 |
|
523 <p> |
|
524 Public method to send an URL to Google for checking. |
|
525 </p> |
|
526 <dl> |
|
527 |
|
528 <dt><i>url</i> (QUrl)</dt> |
|
529 <dd> |
|
530 URL to be checked |
|
531 </dd> |
|
532 <dt><i>platforms</i> (list of str)</dt> |
|
533 <dd> |
|
534 list of platform types to check against |
|
535 </dd> |
|
536 </dl> |
|
537 <dl> |
|
538 <dt>Return:</dt> |
|
539 <dd> |
|
540 tuple containing the list of threat list info objects and |
|
541 an error message |
|
542 </dd> |
|
543 </dl> |
|
544 <dl> |
|
545 <dt>Return Type:</dt> |
|
546 <dd> |
|
547 tuple of (list of ThreatList, str) |
|
548 </dd> |
|
549 </dl> |
|
550 <a NAME="SafeBrowsingAPIClient.setApiKey" ID="SafeBrowsingAPIClient.setApiKey"></a> |
|
551 <h4>SafeBrowsingAPIClient.setApiKey</h4> |
|
552 <b>setApiKey</b>(<i>apiKey</i>) |
|
553 |
|
554 <p> |
|
555 Public method to set the API key. |
|
556 </p> |
|
557 <dl> |
|
558 |
|
559 <dt><i>apiKey</i> (str)</dt> |
|
560 <dd> |
|
561 API key to be set |
|
562 </dd> |
|
563 </dl> |
|
564 <div align="right"><a href="#top">Up</a></div> |
|
565 <hr /> |
|
566 </body></html> |