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