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

changeset 6942
2602857055c5
parent 6233
a64b986abb54
child 7273
391d6b7b1eff
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.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><a NAME="top" ID="top"></a>
22 <h1>eric6.WebBrowser.SafeBrowsing.SafeBrowsingCache</h1>
23 <p>
24 Module implementing a cache 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="#SafeBrowsingCache">SafeBrowsingCache</a></td>
34 <td>Class implementing a cache 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="SafeBrowsingCache" ID="SafeBrowsingCache"></a>
43 <h2>SafeBrowsingCache</h2>
44 <p>
45 Class implementing a cache for Google Safe Browsing.
46 </p>
47 <h3>Derived from</h3>
48 QObject
49 <h3>Class Attributes</h3>
50 <table>
51 <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>
52 </table>
53 <h3>Class Methods</h3>
54 <table>
55 <tr><td>None</td></tr>
56 </table>
57 <h3>Methods</h3>
58 <table>
59 <tr>
60 <td><a href="#SafeBrowsingCache.__init__">SafeBrowsingCache</a></td>
61 <td>Constructor</td>
62 </tr><tr>
63 <td><a href="#SafeBrowsingCache.__openCacheDb">__openCacheDb</a></td>
64 <td>Private method to open the cache database.</td>
65 </tr><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><tr>
69 <td><a href="#SafeBrowsingCache.cleanupFullHashes">cleanupFullHashes</a></td>
70 <td>Public method to clean up full hash entries expired more than the given time.</td>
71 </tr><tr>
72 <td><a href="#SafeBrowsingCache.close">close</a></td>
73 <td>Public method to close the database.</td>
74 </tr><tr>
75 <td><a href="#SafeBrowsingCache.deleteHashPrefixList">deleteHashPrefixList</a></td>
76 <td>Public method to delete hash prefixes for a given threat list.</td>
77 </tr><tr>
78 <td><a href="#SafeBrowsingCache.deleteThreatList">deleteThreatList</a></td>
79 <td>Public method to delete a threat list from the cache.</td>
80 </tr><tr>
81 <td><a href="#SafeBrowsingCache.getHashPrefixValuesToRemove">getHashPrefixValuesToRemove</a></td>
82 <td>Public method to get the hash prefix values to be removed from the cache.</td>
83 </tr><tr>
84 <td><a href="#SafeBrowsingCache.getThreatLists">getThreatLists</a></td>
85 <td>Public method to get the available threat lists.</td>
86 </tr><tr>
87 <td><a href="#SafeBrowsingCache.hashPrefixListChecksum">hashPrefixListChecksum</a></td>
88 <td>Public method to calculate the SHA256 checksum for an alphabetically sorted concatenated list of hash prefixes.</td>
89 </tr><tr>
90 <td><a href="#SafeBrowsingCache.lookupFullHashes">lookupFullHashes</a></td>
91 <td>Public method to get a list of threat lists and expiration flag for the given hashes if a hash is blacklisted.</td>
92 </tr><tr>
93 <td><a href="#SafeBrowsingCache.lookupHashPrefix">lookupHashPrefix</a></td>
94 <td>Public method to look up hash prefixes in the local cache.</td>
95 </tr><tr>
96 <td><a href="#SafeBrowsingCache.populateHashPrefixList">populateHashPrefixList</a></td>
97 <td>Public method to populate the hash prefixes for a threat list.</td>
98 </tr><tr>
99 <td><a href="#SafeBrowsingCache.prepareCacheDb">prepareCacheDb</a></td>
100 <td>Public method to prepare the cache database.</td>
101 </tr><tr>
102 <td><a href="#SafeBrowsingCache.removeHashPrefixIndices">removeHashPrefixIndices</a></td>
103 <td>Public method to remove hash prefixes from the cache.</td>
104 </tr><tr>
105 <td><a href="#SafeBrowsingCache.storeFullHash">storeFullHash</a></td>
106 <td>Public method to store full hash data in the cache database.</td>
107 </tr><tr>
108 <td><a href="#SafeBrowsingCache.updateHashPrefixExpiration">updateHashPrefixExpiration</a></td>
109 <td>Public method to update the hash prefix expiration time.</td>
110 </tr><tr>
111 <td><a href="#SafeBrowsingCache.updateThreatListClientState">updateThreatListClientState</a></td>
112 <td>Public method to update the client state of a threat list.</td>
113 </tr>
114 </table>
115 <h3>Static Methods</h3>
116 <table>
117 <tr><td>None</td></tr>
118 </table>
119 <a NAME="SafeBrowsingCache.__init__" ID="SafeBrowsingCache.__init__"></a>
120 <h4>SafeBrowsingCache (Constructor)</h4>
121 <b>SafeBrowsingCache</b>(<i>dbPath, parent=None</i>)
122 <p>
123 Constructor
124 </p><dl>
125 <dt><i>dbPath</i> (str)</dt>
126 <dd>
127 path to store the cache DB into
128 </dd><dt><i>parent</i> (QObject)</dt>
129 <dd>
130 reference to the parent object
131 </dd>
132 </dl><a NAME="SafeBrowsingCache.__openCacheDb" ID="SafeBrowsingCache.__openCacheDb"></a>
133 <h4>SafeBrowsingCache.__openCacheDb</h4>
134 <b>__openCacheDb</b>(<i></i>)
135 <p>
136 Private method to open the cache database.
137 </p><dl>
138 <dt>Returns:</dt>
139 <dd>
140 flag indicating the open state
141 </dd>
142 </dl><dl>
143 <dt>Return Type:</dt>
144 <dd>
145 bool
146 </dd>
147 </dl><a NAME="SafeBrowsingCache.addThreatList" ID="SafeBrowsingCache.addThreatList"></a>
148 <h4>SafeBrowsingCache.addThreatList</h4>
149 <b>addThreatList</b>(<i>threatList</i>)
150 <p>
151 Public method to add a threat list to the cache.
152 </p><dl>
153 <dt><i>threatList</i> (ThreatList)</dt>
154 <dd>
155 threat list to be added
156 </dd>
157 </dl><a NAME="SafeBrowsingCache.cleanupFullHashes" ID="SafeBrowsingCache.cleanupFullHashes"></a>
158 <h4>SafeBrowsingCache.cleanupFullHashes</h4>
159 <b>cleanupFullHashes</b>(<i>keepExpiredFor=43200</i>)
160 <p>
161 Public method to clean up full hash entries expired more than the
162 given time.
163 </p><dl>
164 <dt><i>keepExpiredFor</i> (int or float)</dt>
165 <dd>
166 time period in seconds of entries to be expired
167 </dd>
168 </dl><a NAME="SafeBrowsingCache.close" ID="SafeBrowsingCache.close"></a>
169 <h4>SafeBrowsingCache.close</h4>
170 <b>close</b>(<i></i>)
171 <p>
172 Public method to close the database.
173 </p><a NAME="SafeBrowsingCache.deleteHashPrefixList" ID="SafeBrowsingCache.deleteHashPrefixList"></a>
174 <h4>SafeBrowsingCache.deleteHashPrefixList</h4>
175 <b>deleteHashPrefixList</b>(<i>threatList</i>)
176 <p>
177 Public method to delete hash prefixes for a given threat list.
178 </p><dl>
179 <dt><i>threatList</i> (ThreatList)</dt>
180 <dd>
181 threat list info object
182 </dd>
183 </dl><a NAME="SafeBrowsingCache.deleteThreatList" ID="SafeBrowsingCache.deleteThreatList"></a>
184 <h4>SafeBrowsingCache.deleteThreatList</h4>
185 <b>deleteThreatList</b>(<i>threatList</i>)
186 <p>
187 Public method to delete a threat list from the cache.
188 </p><dl>
189 <dt><i>threatList</i> (ThreatList)</dt>
190 <dd>
191 threat list to be deleted
192 </dd>
193 </dl><a NAME="SafeBrowsingCache.getHashPrefixValuesToRemove" ID="SafeBrowsingCache.getHashPrefixValuesToRemove"></a>
194 <h4>SafeBrowsingCache.getHashPrefixValuesToRemove</h4>
195 <b>getHashPrefixValuesToRemove</b>(<i>threatList, indexes</i>)
196 <p>
197 Public method to get the hash prefix values to be removed from the
198 cache.
199 </p><dl>
200 <dt><i>threatList</i> (ThreatList)</dt>
201 <dd>
202 threat list to remove prefixes from
203 </dd><dt><i>indexes</i> (list of int)</dt>
204 <dd>
205 list of indexes of prefixes to be removed
206 </dd>
207 </dl><dl>
208 <dt>Returns:</dt>
209 <dd>
210 list of hash prefixes to be removed
211 </dd>
212 </dl><dl>
213 <dt>Return Type:</dt>
214 <dd>
215 list of bytes
216 </dd>
217 </dl><a NAME="SafeBrowsingCache.getThreatLists" ID="SafeBrowsingCache.getThreatLists"></a>
218 <h4>SafeBrowsingCache.getThreatLists</h4>
219 <b>getThreatLists</b>(<i></i>)
220 <p>
221 Public method to get the available threat lists.
222 </p><dl>
223 <dt>Returns:</dt>
224 <dd>
225 list of available threat lists
226 </dd>
227 </dl><dl>
228 <dt>Return Type:</dt>
229 <dd>
230 list of tuples of (ThreatList, str)
231 </dd>
232 </dl><a NAME="SafeBrowsingCache.hashPrefixListChecksum" ID="SafeBrowsingCache.hashPrefixListChecksum"></a>
233 <h4>SafeBrowsingCache.hashPrefixListChecksum</h4>
234 <b>hashPrefixListChecksum</b>(<i>threatList</i>)
235 <p>
236 Public method to calculate the SHA256 checksum for an alphabetically
237 sorted concatenated list of hash prefixes.
238 </p><dl>
239 <dt><i>threatList</i> (ThreatList)</dt>
240 <dd>
241 threat list to calculate checksum for
242 </dd>
243 </dl><dl>
244 <dt>Returns:</dt>
245 <dd>
246 SHA256 checksum
247 </dd>
248 </dl><dl>
249 <dt>Return Type:</dt>
250 <dd>
251 bytes
252 </dd>
253 </dl><a NAME="SafeBrowsingCache.lookupFullHashes" ID="SafeBrowsingCache.lookupFullHashes"></a>
254 <h4>SafeBrowsingCache.lookupFullHashes</h4>
255 <b>lookupFullHashes</b>(<i>hashValues</i>)
256 <p>
257 Public method to get a list of threat lists and expiration flag
258 for the given hashes if a hash is blacklisted.
259 </p><dl>
260 <dt><i>hashValues</i> (list of bytes)</dt>
261 <dd>
262 list of hash values to look up
263 </dd>
264 </dl><dl>
265 <dt>Returns:</dt>
266 <dd>
267 list of tuples containing the threat list info and the
268 expiration flag
269 </dd>
270 </dl><dl>
271 <dt>Return Type:</dt>
272 <dd>
273 list of tuple of (ThreatList, bool)
274 </dd>
275 </dl><a NAME="SafeBrowsingCache.lookupHashPrefix" ID="SafeBrowsingCache.lookupHashPrefix"></a>
276 <h4>SafeBrowsingCache.lookupHashPrefix</h4>
277 <b>lookupHashPrefix</b>(<i>prefixes</i>)
278 <p>
279 Public method to look up hash prefixes in the local cache.
280 </p><dl>
281 <dt><i>prefixes</i> (list of bytes)</dt>
282 <dd>
283 list of hash prefixes to look up
284 </dd>
285 </dl><dl>
286 <dt>Returns:</dt>
287 <dd>
288 list of tuples containing the threat list, full hash and
289 negative cache expiration flag
290 </dd>
291 </dl><dl>
292 <dt>Return Type:</dt>
293 <dd>
294 list of tuple of (ThreatList, bytes, bool)
295 </dd>
296 </dl><a NAME="SafeBrowsingCache.populateHashPrefixList" ID="SafeBrowsingCache.populateHashPrefixList"></a>
297 <h4>SafeBrowsingCache.populateHashPrefixList</h4>
298 <b>populateHashPrefixList</b>(<i>threatList, prefixes</i>)
299 <p>
300 Public method to populate the hash prefixes for a threat list.
301 </p><dl>
302 <dt><i>threatList</i> (ThreatList)</dt>
303 <dd>
304 threat list of the hash prefixes
305 </dd><dt><i>prefixes</i> (HashPrefixList)</dt>
306 <dd>
307 list of hash prefixes to be inserted
308 </dd>
309 </dl><a NAME="SafeBrowsingCache.prepareCacheDb" ID="SafeBrowsingCache.prepareCacheDb"></a>
310 <h4>SafeBrowsingCache.prepareCacheDb</h4>
311 <b>prepareCacheDb</b>(<i></i>)
312 <p>
313 Public method to prepare the cache database.
314 </p><a NAME="SafeBrowsingCache.removeHashPrefixIndices" ID="SafeBrowsingCache.removeHashPrefixIndices"></a>
315 <h4>SafeBrowsingCache.removeHashPrefixIndices</h4>
316 <b>removeHashPrefixIndices</b>(<i>threatList, indexes</i>)
317 <p>
318 Public method to remove hash prefixes from the cache.
319 </p><dl>
320 <dt><i>threatList</i> (ThreatList)</dt>
321 <dd>
322 threat list to delete hash prefixes of
323 </dd><dt><i>indexes</i> (list of int)</dt>
324 <dd>
325 list of indexes of prefixes to be removed
326 </dd>
327 </dl><a NAME="SafeBrowsingCache.storeFullHash" ID="SafeBrowsingCache.storeFullHash"></a>
328 <h4>SafeBrowsingCache.storeFullHash</h4>
329 <b>storeFullHash</b>(<i>threatList, hashValue, cacheDuration, malwareThreatType</i>)
330 <p>
331 Public method to store full hash data in the cache database.
332 </p><dl>
333 <dt><i>threatList</i> (ThreatList)</dt>
334 <dd>
335 threat list info object
336 </dd><dt><i>hashValue</i> (bytes)</dt>
337 <dd>
338 hash to be stored
339 </dd><dt><i>cacheDuration</i> (int or float)</dt>
340 <dd>
341 duration the data should remain in the cache
342 </dd><dt><i>malwareThreatType</i> (str)</dt>
343 <dd>
344 threat type of the malware
345 </dd>
346 </dl><a NAME="SafeBrowsingCache.updateHashPrefixExpiration" ID="SafeBrowsingCache.updateHashPrefixExpiration"></a>
347 <h4>SafeBrowsingCache.updateHashPrefixExpiration</h4>
348 <b>updateHashPrefixExpiration</b>(<i>threatList, hashPrefix, negativeCacheDuration</i>)
349 <p>
350 Public method to update the hash prefix expiration time.
351 </p><dl>
352 <dt><i>threatList</i> (ThreatList)</dt>
353 <dd>
354 threat list info object
355 </dd><dt><i>hashPrefix</i> (bytes)</dt>
356 <dd>
357 hash prefix
358 </dd><dt><i>negativeCacheDuration</i> (int or float)</dt>
359 <dd>
360 time in seconds the entry should remain
361 in the cache
362 </dd>
363 </dl><a NAME="SafeBrowsingCache.updateThreatListClientState" ID="SafeBrowsingCache.updateThreatListClientState"></a>
364 <h4>SafeBrowsingCache.updateThreatListClientState</h4>
365 <b>updateThreatListClientState</b>(<i>threatList, clientState</i>)
366 <p>
367 Public method to update the client state of a threat list.
368 </p><dl>
369 <dt><i>threatList</i> (ThreatList)</dt>
370 <dd>
371 threat list to update the client state for
372 </dd><dt><i>clientState</i> (str)</dt>
373 <dd>
374 new client state
375 </dd>
376 </dl>
377 <div align="right"><a href="#top">Up</a></div>
378 <hr />
379 </body></html>

eric ide

mercurial