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