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

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

eric ide

mercurial