src/eric7/Documentation/Source/eric7.WebBrowser.SafeBrowsing.SafeBrowsingCache.html

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8596
d64760b2da50
child 10479
856476537696
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.WebBrowser.SafeBrowsing.SafeBrowsingCache</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.SafeBrowsingCache</h1>
10
11 <p>
12 Module implementing a cache 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="#SafeBrowsingCache">SafeBrowsingCache</a></td>
25 <td>Class implementing a cache 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="SafeBrowsingCache" ID="SafeBrowsingCache"></a>
36 <h2>SafeBrowsingCache</h2>
37
38 <p>
39 Class implementing a cache for Google Safe Browsing.
40 </p>
41 <h3>Derived from</h3>
42 QObject
43 <h3>Class Attributes</h3>
44
45 <table>
46 <tr><td>create_full_hash_cue_idx</td></tr><tr><td>create_full_hash_expires_idx</td></tr><tr><td>create_full_hash_value_idx</td></tr><tr><td>create_full_hashes_stmt</td></tr><tr><td>create_hash_prefix_stmt</td></tr><tr><td>create_threat_list_stmt</td></tr><tr><td>drop_full_hash_cue_idx</td></tr><tr><td>drop_full_hash_expires_idx</td></tr><tr><td>drop_full_hash_value_idx</td></tr><tr><td>drop_full_hashes_stmt</td></tr><tr><td>drop_hash_prefix_stmt</td></tr><tr><td>drop_threat_list_stmt</td></tr><tr><td>maxProcessEventsTime</td></tr>
47 </table>
48 <h3>Class Methods</h3>
49
50 <table>
51 <tr><td>None</td></tr>
52 </table>
53 <h3>Methods</h3>
54
55 <table>
56
57 <tr>
58 <td><a href="#SafeBrowsingCache.__init__">SafeBrowsingCache</a></td>
59 <td>Constructor</td>
60 </tr>
61 <tr>
62 <td><a href="#SafeBrowsingCache.__openCacheDb">__openCacheDb</a></td>
63 <td>Private method to open the cache database.</td>
64 </tr>
65 <tr>
66 <td><a href="#SafeBrowsingCache.addThreatList">addThreatList</a></td>
67 <td>Public method to add a threat list to the cache.</td>
68 </tr>
69 <tr>
70 <td><a href="#SafeBrowsingCache.cleanupFullHashes">cleanupFullHashes</a></td>
71 <td>Public method to clean up full hash entries expired more than the given time.</td>
72 </tr>
73 <tr>
74 <td><a href="#SafeBrowsingCache.close">close</a></td>
75 <td>Public method to close the database.</td>
76 </tr>
77 <tr>
78 <td><a href="#SafeBrowsingCache.deleteHashPrefixList">deleteHashPrefixList</a></td>
79 <td>Public method to delete hash prefixes for a given threat list.</td>
80 </tr>
81 <tr>
82 <td><a href="#SafeBrowsingCache.deleteThreatList">deleteThreatList</a></td>
83 <td>Public method to delete a threat list from the cache.</td>
84 </tr>
85 <tr>
86 <td><a href="#SafeBrowsingCache.getHashPrefixValuesToRemove">getHashPrefixValuesToRemove</a></td>
87 <td>Public method to get the hash prefix values to be removed from the cache.</td>
88 </tr>
89 <tr>
90 <td><a href="#SafeBrowsingCache.getThreatLists">getThreatLists</a></td>
91 <td>Public method to get the available threat lists.</td>
92 </tr>
93 <tr>
94 <td><a href="#SafeBrowsingCache.hashPrefixListChecksum">hashPrefixListChecksum</a></td>
95 <td>Public method to calculate the SHA256 checksum for an alphabetically sorted concatenated list of hash prefixes.</td>
96 </tr>
97 <tr>
98 <td><a href="#SafeBrowsingCache.lookupFullHashes">lookupFullHashes</a></td>
99 <td>Public method to get a list of threat lists and expiration flag for the given hashes if a hash is blacklisted.</td>
100 </tr>
101 <tr>
102 <td><a href="#SafeBrowsingCache.lookupHashPrefix">lookupHashPrefix</a></td>
103 <td>Public method to look up hash prefixes in the local cache.</td>
104 </tr>
105 <tr>
106 <td><a href="#SafeBrowsingCache.populateHashPrefixList">populateHashPrefixList</a></td>
107 <td>Public method to populate the hash prefixes for a threat list.</td>
108 </tr>
109 <tr>
110 <td><a href="#SafeBrowsingCache.prepareCacheDb">prepareCacheDb</a></td>
111 <td>Public method to prepare the cache database.</td>
112 </tr>
113 <tr>
114 <td><a href="#SafeBrowsingCache.removeHashPrefixIndices">removeHashPrefixIndices</a></td>
115 <td>Public method to remove hash prefixes from the cache.</td>
116 </tr>
117 <tr>
118 <td><a href="#SafeBrowsingCache.storeFullHash">storeFullHash</a></td>
119 <td>Public method to store full hash data in the cache database.</td>
120 </tr>
121 <tr>
122 <td><a href="#SafeBrowsingCache.updateHashPrefixExpiration">updateHashPrefixExpiration</a></td>
123 <td>Public method to update the hash prefix expiration time.</td>
124 </tr>
125 <tr>
126 <td><a href="#SafeBrowsingCache.updateThreatListClientState">updateThreatListClientState</a></td>
127 <td>Public method to update the client state of a threat list.</td>
128 </tr>
129 </table>
130 <h3>Static Methods</h3>
131
132 <table>
133 <tr><td>None</td></tr>
134 </table>
135
136 <a NAME="SafeBrowsingCache.__init__" ID="SafeBrowsingCache.__init__"></a>
137 <h4>SafeBrowsingCache (Constructor)</h4>
138 <b>SafeBrowsingCache</b>(<i>dbPath, parent=None</i>)
139
140 <p>
141 Constructor
142 </p>
143 <dl>
144
145 <dt><i>dbPath</i> (str)</dt>
146 <dd>
147 path to store the cache DB into
148 </dd>
149 <dt><i>parent</i> (QObject)</dt>
150 <dd>
151 reference to the parent object
152 </dd>
153 </dl>
154 <a NAME="SafeBrowsingCache.__openCacheDb" ID="SafeBrowsingCache.__openCacheDb"></a>
155 <h4>SafeBrowsingCache.__openCacheDb</h4>
156 <b>__openCacheDb</b>(<i></i>)
157
158 <p>
159 Private method to open the cache database.
160 </p>
161 <dl>
162 <dt>Return:</dt>
163 <dd>
164 flag indicating the open state
165 </dd>
166 </dl>
167 <dl>
168 <dt>Return Type:</dt>
169 <dd>
170 bool
171 </dd>
172 </dl>
173 <a NAME="SafeBrowsingCache.addThreatList" ID="SafeBrowsingCache.addThreatList"></a>
174 <h4>SafeBrowsingCache.addThreatList</h4>
175 <b>addThreatList</b>(<i>threatList</i>)
176
177 <p>
178 Public method to add a threat list to the cache.
179 </p>
180 <dl>
181
182 <dt><i>threatList</i> (ThreatList)</dt>
183 <dd>
184 threat list to be added
185 </dd>
186 </dl>
187 <a NAME="SafeBrowsingCache.cleanupFullHashes" ID="SafeBrowsingCache.cleanupFullHashes"></a>
188 <h4>SafeBrowsingCache.cleanupFullHashes</h4>
189 <b>cleanupFullHashes</b>(<i>keepExpiredFor=43200</i>)
190
191 <p>
192 Public method to clean up full hash entries expired more than the
193 given time.
194 </p>
195 <dl>
196
197 <dt><i>keepExpiredFor</i> (int or float)</dt>
198 <dd>
199 time period in seconds of entries to be expired
200 </dd>
201 </dl>
202 <a NAME="SafeBrowsingCache.close" ID="SafeBrowsingCache.close"></a>
203 <h4>SafeBrowsingCache.close</h4>
204 <b>close</b>(<i></i>)
205
206 <p>
207 Public method to close the database.
208 </p>
209 <a NAME="SafeBrowsingCache.deleteHashPrefixList" ID="SafeBrowsingCache.deleteHashPrefixList"></a>
210 <h4>SafeBrowsingCache.deleteHashPrefixList</h4>
211 <b>deleteHashPrefixList</b>(<i>threatList</i>)
212
213 <p>
214 Public method to delete hash prefixes for a given threat list.
215 </p>
216 <dl>
217
218 <dt><i>threatList</i> (ThreatList)</dt>
219 <dd>
220 threat list info object
221 </dd>
222 </dl>
223 <a NAME="SafeBrowsingCache.deleteThreatList" ID="SafeBrowsingCache.deleteThreatList"></a>
224 <h4>SafeBrowsingCache.deleteThreatList</h4>
225 <b>deleteThreatList</b>(<i>threatList</i>)
226
227 <p>
228 Public method to delete a threat list from the cache.
229 </p>
230 <dl>
231
232 <dt><i>threatList</i> (ThreatList)</dt>
233 <dd>
234 threat list to be deleted
235 </dd>
236 </dl>
237 <a NAME="SafeBrowsingCache.getHashPrefixValuesToRemove" ID="SafeBrowsingCache.getHashPrefixValuesToRemove"></a>
238 <h4>SafeBrowsingCache.getHashPrefixValuesToRemove</h4>
239 <b>getHashPrefixValuesToRemove</b>(<i>threatList, indexes</i>)
240
241 <p>
242 Public method to get the hash prefix values to be removed from the
243 cache.
244 </p>
245 <dl>
246
247 <dt><i>threatList</i> (ThreatList)</dt>
248 <dd>
249 threat list to remove prefixes from
250 </dd>
251 <dt><i>indexes</i> (list of int)</dt>
252 <dd>
253 list of indexes of prefixes to be removed
254 </dd>
255 </dl>
256 <dl>
257 <dt>Return:</dt>
258 <dd>
259 list of hash prefixes to be removed
260 </dd>
261 </dl>
262 <dl>
263 <dt>Return Type:</dt>
264 <dd>
265 list of bytes
266 </dd>
267 </dl>
268 <a NAME="SafeBrowsingCache.getThreatLists" ID="SafeBrowsingCache.getThreatLists"></a>
269 <h4>SafeBrowsingCache.getThreatLists</h4>
270 <b>getThreatLists</b>(<i></i>)
271
272 <p>
273 Public method to get the available threat lists.
274 </p>
275 <dl>
276 <dt>Return:</dt>
277 <dd>
278 list of available threat lists
279 </dd>
280 </dl>
281 <dl>
282 <dt>Return Type:</dt>
283 <dd>
284 list of tuples of (ThreatList, str)
285 </dd>
286 </dl>
287 <a NAME="SafeBrowsingCache.hashPrefixListChecksum" ID="SafeBrowsingCache.hashPrefixListChecksum"></a>
288 <h4>SafeBrowsingCache.hashPrefixListChecksum</h4>
289 <b>hashPrefixListChecksum</b>(<i>threatList</i>)
290
291 <p>
292 Public method to calculate the SHA256 checksum for an alphabetically
293 sorted concatenated list of hash prefixes.
294 </p>
295 <dl>
296
297 <dt><i>threatList</i> (ThreatList)</dt>
298 <dd>
299 threat list to calculate checksum for
300 </dd>
301 </dl>
302 <dl>
303 <dt>Return:</dt>
304 <dd>
305 SHA256 checksum
306 </dd>
307 </dl>
308 <dl>
309 <dt>Return Type:</dt>
310 <dd>
311 bytes
312 </dd>
313 </dl>
314 <a NAME="SafeBrowsingCache.lookupFullHashes" ID="SafeBrowsingCache.lookupFullHashes"></a>
315 <h4>SafeBrowsingCache.lookupFullHashes</h4>
316 <b>lookupFullHashes</b>(<i>hashValues</i>)
317
318 <p>
319 Public method to get a list of threat lists and expiration flag
320 for the given hashes if a hash is blacklisted.
321 </p>
322 <dl>
323
324 <dt><i>hashValues</i> (list of bytes)</dt>
325 <dd>
326 list of hash values to look up
327 </dd>
328 </dl>
329 <dl>
330 <dt>Return:</dt>
331 <dd>
332 list of tuples containing the threat list info and the
333 expiration flag
334 </dd>
335 </dl>
336 <dl>
337 <dt>Return Type:</dt>
338 <dd>
339 list of tuple of (ThreatList, bool)
340 </dd>
341 </dl>
342 <a NAME="SafeBrowsingCache.lookupHashPrefix" ID="SafeBrowsingCache.lookupHashPrefix"></a>
343 <h4>SafeBrowsingCache.lookupHashPrefix</h4>
344 <b>lookupHashPrefix</b>(<i>prefixes</i>)
345
346 <p>
347 Public method to look up hash prefixes in the local cache.
348 </p>
349 <dl>
350
351 <dt><i>prefixes</i> (list of bytes)</dt>
352 <dd>
353 list of hash prefixes to look up
354 </dd>
355 </dl>
356 <dl>
357 <dt>Return:</dt>
358 <dd>
359 list of tuples containing the threat list, full hash and
360 negative cache expiration flag
361 </dd>
362 </dl>
363 <dl>
364 <dt>Return Type:</dt>
365 <dd>
366 list of tuple of (ThreatList, bytes, bool)
367 </dd>
368 </dl>
369 <a NAME="SafeBrowsingCache.populateHashPrefixList" ID="SafeBrowsingCache.populateHashPrefixList"></a>
370 <h4>SafeBrowsingCache.populateHashPrefixList</h4>
371 <b>populateHashPrefixList</b>(<i>threatList, prefixes</i>)
372
373 <p>
374 Public method to populate the hash prefixes for a threat list.
375 </p>
376 <dl>
377
378 <dt><i>threatList</i> (ThreatList)</dt>
379 <dd>
380 threat list of the hash prefixes
381 </dd>
382 <dt><i>prefixes</i> (HashPrefixList)</dt>
383 <dd>
384 list of hash prefixes to be inserted
385 </dd>
386 </dl>
387 <a NAME="SafeBrowsingCache.prepareCacheDb" ID="SafeBrowsingCache.prepareCacheDb"></a>
388 <h4>SafeBrowsingCache.prepareCacheDb</h4>
389 <b>prepareCacheDb</b>(<i></i>)
390
391 <p>
392 Public method to prepare the cache database.
393 </p>
394 <a NAME="SafeBrowsingCache.removeHashPrefixIndices" ID="SafeBrowsingCache.removeHashPrefixIndices"></a>
395 <h4>SafeBrowsingCache.removeHashPrefixIndices</h4>
396 <b>removeHashPrefixIndices</b>(<i>threatList, indexes</i>)
397
398 <p>
399 Public method to remove hash prefixes from the cache.
400 </p>
401 <dl>
402
403 <dt><i>threatList</i> (ThreatList)</dt>
404 <dd>
405 threat list to delete hash prefixes of
406 </dd>
407 <dt><i>indexes</i> (list of int)</dt>
408 <dd>
409 list of indexes of prefixes to be removed
410 </dd>
411 </dl>
412 <a NAME="SafeBrowsingCache.storeFullHash" ID="SafeBrowsingCache.storeFullHash"></a>
413 <h4>SafeBrowsingCache.storeFullHash</h4>
414 <b>storeFullHash</b>(<i>threatList, hashValue, cacheDuration, malwareThreatType</i>)
415
416 <p>
417 Public method to store full hash data in the cache database.
418 </p>
419 <dl>
420
421 <dt><i>threatList</i> (ThreatList)</dt>
422 <dd>
423 threat list info object
424 </dd>
425 <dt><i>hashValue</i> (bytes)</dt>
426 <dd>
427 hash to be stored
428 </dd>
429 <dt><i>cacheDuration</i> (int or float)</dt>
430 <dd>
431 duration the data should remain in the cache
432 </dd>
433 <dt><i>malwareThreatType</i> (str)</dt>
434 <dd>
435 threat type of the malware
436 </dd>
437 </dl>
438 <a NAME="SafeBrowsingCache.updateHashPrefixExpiration" ID="SafeBrowsingCache.updateHashPrefixExpiration"></a>
439 <h4>SafeBrowsingCache.updateHashPrefixExpiration</h4>
440 <b>updateHashPrefixExpiration</b>(<i>threatList, hashPrefix, negativeCacheDuration</i>)
441
442 <p>
443 Public method to update the hash prefix expiration time.
444 </p>
445 <dl>
446
447 <dt><i>threatList</i> (ThreatList)</dt>
448 <dd>
449 threat list info object
450 </dd>
451 <dt><i>hashPrefix</i> (bytes)</dt>
452 <dd>
453 hash prefix
454 </dd>
455 <dt><i>negativeCacheDuration</i> (int or float)</dt>
456 <dd>
457 time in seconds the entry should remain
458 in the cache
459 </dd>
460 </dl>
461 <a NAME="SafeBrowsingCache.updateThreatListClientState" ID="SafeBrowsingCache.updateThreatListClientState"></a>
462 <h4>SafeBrowsingCache.updateThreatListClientState</h4>
463 <b>updateThreatListClientState</b>(<i>threatList, clientState</i>)
464
465 <p>
466 Public method to update the client state of a threat list.
467 </p>
468 <dl>
469
470 <dt><i>threatList</i> (ThreatList)</dt>
471 <dd>
472 threat list to update the client state for
473 </dd>
474 <dt><i>clientState</i> (str)</dt>
475 <dd>
476 new client state
477 </dd>
478 </dl>
479 <div align="right"><a href="#top">Up</a></div>
480 <hr />
481 </body></html>

eric ide

mercurial