|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.PipInterface.PipVulnerabilityChecker</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.PipInterface.PipVulnerabilityChecker</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing a Python package vulnerability checker. |
|
13 </p> |
|
14 <p> |
|
15 The vulnerability data is provided by the open Python vulnerability database |
|
16 <a href="https://github.com/pyupio/safety-db">Safety DB</a>. |
|
17 </p> |
|
18 <h3>Global Attributes</h3> |
|
19 |
|
20 <table> |
|
21 <tr><td>None</td></tr> |
|
22 </table> |
|
23 <h3>Classes</h3> |
|
24 |
|
25 <table> |
|
26 |
|
27 <tr> |
|
28 <td><a href="#Package">Package</a></td> |
|
29 <td>Class containing the package data.</td> |
|
30 </tr> |
|
31 <tr> |
|
32 <td><a href="#PipVulnerabilityChecker">PipVulnerabilityChecker</a></td> |
|
33 <td>Class implementing a Python package vulnerability checker.</td> |
|
34 </tr> |
|
35 <tr> |
|
36 <td><a href="#Vulnerability">Vulnerability</a></td> |
|
37 <td>Class containing the vulnerability data.</td> |
|
38 </tr> |
|
39 <tr> |
|
40 <td><a href="#VulnerabilityCheckError">VulnerabilityCheckError</a></td> |
|
41 <td>Class defining various vulnerability check error states.</td> |
|
42 </tr> |
|
43 </table> |
|
44 <h3>Functions</h3> |
|
45 |
|
46 <table> |
|
47 <tr><td>None</td></tr> |
|
48 </table> |
|
49 <hr /> |
|
50 <hr /> |
|
51 <a NAME="Package" ID="Package"></a> |
|
52 <h2>Package</h2> |
|
53 |
|
54 <p> |
|
55 Class containing the package data. |
|
56 </p> |
|
57 <h3>Derived from</h3> |
|
58 None |
|
59 <h3>Class Attributes</h3> |
|
60 |
|
61 <table> |
|
62 <tr><td>None</td></tr> |
|
63 </table> |
|
64 <h3>Class Methods</h3> |
|
65 |
|
66 <table> |
|
67 <tr><td>None</td></tr> |
|
68 </table> |
|
69 <h3>Methods</h3> |
|
70 |
|
71 <table> |
|
72 <tr><td>None</td></tr> |
|
73 </table> |
|
74 <h3>Static Methods</h3> |
|
75 |
|
76 <table> |
|
77 <tr><td>None</td></tr> |
|
78 </table> |
|
79 |
|
80 <div align="right"><a href="#top">Up</a></div> |
|
81 <hr /> |
|
82 <hr /> |
|
83 <a NAME="PipVulnerabilityChecker" ID="PipVulnerabilityChecker"></a> |
|
84 <h2>PipVulnerabilityChecker</h2> |
|
85 |
|
86 <p> |
|
87 Class implementing a Python package vulnerability checker. |
|
88 </p> |
|
89 <h3>Derived from</h3> |
|
90 QObject |
|
91 <h3>Class Attributes</h3> |
|
92 |
|
93 <table> |
|
94 <tr><td>FullDbFile</td></tr><tr><td>SummaryDbFile</td></tr> |
|
95 </table> |
|
96 <h3>Class Methods</h3> |
|
97 |
|
98 <table> |
|
99 <tr><td>None</td></tr> |
|
100 </table> |
|
101 <h3>Methods</h3> |
|
102 |
|
103 <table> |
|
104 |
|
105 <tr> |
|
106 <td><a href="#PipVulnerabilityChecker.__init__">PipVulnerabilityChecker</a></td> |
|
107 <td>Constructor</td> |
|
108 </tr> |
|
109 <tr> |
|
110 <td><a href="#PipVulnerabilityChecker.__createCacheFile">__createCacheFile</a></td> |
|
111 <td>Private method to create the cache file.</td> |
|
112 </tr> |
|
113 <tr> |
|
114 <td><a href="#PipVulnerabilityChecker.__fetchVulnerabilityDatabase">__fetchVulnerabilityDatabase</a></td> |
|
115 <td>Private method to get the data of the vulnerability database.</td> |
|
116 </tr> |
|
117 <tr> |
|
118 <td><a href="#PipVulnerabilityChecker.__getDataFromCache">__getDataFromCache</a></td> |
|
119 <td>Private method to get the vulnerability database from the cache.</td> |
|
120 </tr> |
|
121 <tr> |
|
122 <td><a href="#PipVulnerabilityChecker.__getVulnerabilities">__getVulnerabilities</a></td> |
|
123 <td>Private method to get the vulnerabilities for a package.</td> |
|
124 </tr> |
|
125 <tr> |
|
126 <td><a href="#PipVulnerabilityChecker.__writeDataToCache">__writeDataToCache</a></td> |
|
127 <td>Private method to write the vulnerability data for a database to the cache.</td> |
|
128 </tr> |
|
129 <tr> |
|
130 <td><a href="#PipVulnerabilityChecker.check">check</a></td> |
|
131 <td>Public method to check the given packages for vulnerabilities.</td> |
|
132 </tr> |
|
133 <tr> |
|
134 <td><a href="#PipVulnerabilityChecker.updateVulnerabilityDb">updateVulnerabilityDb</a></td> |
|
135 <td>Public method to update the cache of the vulnerability databases.</td> |
|
136 </tr> |
|
137 </table> |
|
138 <h3>Static Methods</h3> |
|
139 |
|
140 <table> |
|
141 <tr><td>None</td></tr> |
|
142 </table> |
|
143 |
|
144 <a NAME="PipVulnerabilityChecker.__init__" ID="PipVulnerabilityChecker.__init__"></a> |
|
145 <h4>PipVulnerabilityChecker (Constructor)</h4> |
|
146 <b>PipVulnerabilityChecker</b>(<i>pip, parent=None</i>) |
|
147 |
|
148 <p> |
|
149 Constructor |
|
150 </p> |
|
151 <dl> |
|
152 |
|
153 <dt><i>pip</i> (Pip)</dt> |
|
154 <dd> |
|
155 reference to the global pip interface |
|
156 </dd> |
|
157 <dt><i>parent</i> (QWidget (optional))</dt> |
|
158 <dd> |
|
159 reference to the parent widget (defaults to None) |
|
160 </dd> |
|
161 </dl> |
|
162 <a NAME="PipVulnerabilityChecker.__createCacheFile" ID="PipVulnerabilityChecker.__createCacheFile"></a> |
|
163 <h4>PipVulnerabilityChecker.__createCacheFile</h4> |
|
164 <b>__createCacheFile</b>(<i></i>) |
|
165 |
|
166 <p> |
|
167 Private method to create the cache file. |
|
168 </p> |
|
169 <p> |
|
170 The cache file has the following structure. |
|
171 { |
|
172 "insecure.json": { |
|
173 "cachedAt": 12345678 |
|
174 "db": {} |
|
175 }, |
|
176 "insecure_full.json": { |
|
177 "cachedAt": 12345678 |
|
178 "db": {} |
|
179 }, |
|
180 } |
|
181 </p> |
|
182 <a NAME="PipVulnerabilityChecker.__fetchVulnerabilityDatabase" ID="PipVulnerabilityChecker.__fetchVulnerabilityDatabase"></a> |
|
183 <h4>PipVulnerabilityChecker.__fetchVulnerabilityDatabase</h4> |
|
184 <b>__fetchVulnerabilityDatabase</b>(<i>full=False, forceUpdate=False</i>) |
|
185 |
|
186 <p> |
|
187 Private method to get the data of the vulnerability database. |
|
188 </p> |
|
189 <p> |
|
190 If the cached data is still valid, this data will be used. |
|
191 Otherwise a copy of the requested database will be downloaded |
|
192 and cached. |
|
193 </p> |
|
194 <dl> |
|
195 |
|
196 <dt><i>full</i> (bool (optional))</dt> |
|
197 <dd> |
|
198 flag indicating to get the database containing the full |
|
199 data set (defaults to False) |
|
200 </dd> |
|
201 <dt><i>forceUpdate</i> (bool (optional))</dt> |
|
202 <dd> |
|
203 flag indicating an update of the cache is required |
|
204 (defaults to False) |
|
205 </dd> |
|
206 </dl> |
|
207 <dl> |
|
208 <dt>Return:</dt> |
|
209 <dd> |
|
210 dictionary containing the vulnerability data (full data set or |
|
211 just package name and version specifier) |
|
212 </dd> |
|
213 </dl> |
|
214 <a NAME="PipVulnerabilityChecker.__getDataFromCache" ID="PipVulnerabilityChecker.__getDataFromCache"></a> |
|
215 <h4>PipVulnerabilityChecker.__getDataFromCache</h4> |
|
216 <b>__getDataFromCache</b>(<i>dbName</i>) |
|
217 |
|
218 <p> |
|
219 Private method to get the vulnerability database from the cache. |
|
220 </p> |
|
221 <dl> |
|
222 |
|
223 <dt><i>dbName</i> (str)</dt> |
|
224 <dd> |
|
225 name of the vulnerability database |
|
226 </dd> |
|
227 </dl> |
|
228 <dl> |
|
229 <dt>Return:</dt> |
|
230 <dd> |
|
231 dictionary containing the requested vulnerability data |
|
232 </dd> |
|
233 </dl> |
|
234 <dl> |
|
235 <dt>Return Type:</dt> |
|
236 <dd> |
|
237 dict |
|
238 </dd> |
|
239 </dl> |
|
240 <a NAME="PipVulnerabilityChecker.__getVulnerabilities" ID="PipVulnerabilityChecker.__getVulnerabilities"></a> |
|
241 <h4>PipVulnerabilityChecker.__getVulnerabilities</h4> |
|
242 <b>__getVulnerabilities</b>(<i>package, specifier, db</i>) |
|
243 |
|
244 <p> |
|
245 Private method to get the vulnerabilities for a package. |
|
246 </p> |
|
247 <dl> |
|
248 |
|
249 <dt><i>package</i> (str)</dt> |
|
250 <dd> |
|
251 name of the package |
|
252 </dd> |
|
253 <dt><i>specifier</i> (Specifier)</dt> |
|
254 <dd> |
|
255 package specifier |
|
256 </dd> |
|
257 <dt><i>db</i> (dict)</dt> |
|
258 <dd> |
|
259 vulnerability data |
|
260 </dd> |
|
261 </dl> |
|
262 <dl> |
|
263 <dt>Yield:</dt> |
|
264 <dd> |
|
265 dictionary containing the vulnerability data for the package |
|
266 </dd> |
|
267 </dl> |
|
268 <dl> |
|
269 <dt>Yield Type:</dt> |
|
270 <dd> |
|
271 dict |
|
272 </dd> |
|
273 </dl> |
|
274 <a NAME="PipVulnerabilityChecker.__writeDataToCache" ID="PipVulnerabilityChecker.__writeDataToCache"></a> |
|
275 <h4>PipVulnerabilityChecker.__writeDataToCache</h4> |
|
276 <b>__writeDataToCache</b>(<i>dbName, data</i>) |
|
277 |
|
278 <p> |
|
279 Private method to write the vulnerability data for a database to the |
|
280 cache. |
|
281 </p> |
|
282 <dl> |
|
283 |
|
284 <dt><i>dbName</i> (str)</dt> |
|
285 <dd> |
|
286 name of the vulnerability database |
|
287 </dd> |
|
288 <dt><i>data</i> (dict)</dt> |
|
289 <dd> |
|
290 dictionary containing the vulnerability data |
|
291 </dd> |
|
292 </dl> |
|
293 <a NAME="PipVulnerabilityChecker.check" ID="PipVulnerabilityChecker.check"></a> |
|
294 <h4>PipVulnerabilityChecker.check</h4> |
|
295 <b>check</b>(<i>packages</i>) |
|
296 |
|
297 <p> |
|
298 Public method to check the given packages for vulnerabilities. |
|
299 </p> |
|
300 <dl> |
|
301 |
|
302 <dt><i>packages</i> (Package)</dt> |
|
303 <dd> |
|
304 list of packages |
|
305 </dd> |
|
306 </dl> |
|
307 <dl> |
|
308 <dt>Return:</dt> |
|
309 <dd> |
|
310 tuple containing an error status and a dictionary containing |
|
311 detected vulnerable packages keyed by package name |
|
312 </dd> |
|
313 </dl> |
|
314 <dl> |
|
315 <dt>Return Type:</dt> |
|
316 <dd> |
|
317 tuple of (VulnerabilityCheckError, list of Vulnerability) |
|
318 </dd> |
|
319 </dl> |
|
320 <a NAME="PipVulnerabilityChecker.updateVulnerabilityDb" ID="PipVulnerabilityChecker.updateVulnerabilityDb"></a> |
|
321 <h4>PipVulnerabilityChecker.updateVulnerabilityDb</h4> |
|
322 <b>updateVulnerabilityDb</b>(<i></i>) |
|
323 |
|
324 <p> |
|
325 Public method to update the cache of the vulnerability databases. |
|
326 </p> |
|
327 <div align="right"><a href="#top">Up</a></div> |
|
328 <hr /> |
|
329 <hr /> |
|
330 <a NAME="Vulnerability" ID="Vulnerability"></a> |
|
331 <h2>Vulnerability</h2> |
|
332 |
|
333 <p> |
|
334 Class containing the vulnerability data. |
|
335 </p> |
|
336 <h3>Derived from</h3> |
|
337 None |
|
338 <h3>Class Attributes</h3> |
|
339 |
|
340 <table> |
|
341 <tr><td>None</td></tr> |
|
342 </table> |
|
343 <h3>Class Methods</h3> |
|
344 |
|
345 <table> |
|
346 <tr><td>None</td></tr> |
|
347 </table> |
|
348 <h3>Methods</h3> |
|
349 |
|
350 <table> |
|
351 <tr><td>None</td></tr> |
|
352 </table> |
|
353 <h3>Static Methods</h3> |
|
354 |
|
355 <table> |
|
356 <tr><td>None</td></tr> |
|
357 </table> |
|
358 |
|
359 <div align="right"><a href="#top">Up</a></div> |
|
360 <hr /> |
|
361 <hr /> |
|
362 <a NAME="VulnerabilityCheckError" ID="VulnerabilityCheckError"></a> |
|
363 <h2>VulnerabilityCheckError</h2> |
|
364 |
|
365 <p> |
|
366 Class defining various vulnerability check error states. |
|
367 </p> |
|
368 <h3>Derived from</h3> |
|
369 enum.Enum |
|
370 <h3>Class Attributes</h3> |
|
371 |
|
372 <table> |
|
373 <tr><td>FullDbUnavailable</td></tr><tr><td>OK</td></tr><tr><td>SummaryDbUnavailable</td></tr> |
|
374 </table> |
|
375 <h3>Class Methods</h3> |
|
376 |
|
377 <table> |
|
378 <tr><td>None</td></tr> |
|
379 </table> |
|
380 <h3>Methods</h3> |
|
381 |
|
382 <table> |
|
383 <tr><td>None</td></tr> |
|
384 </table> |
|
385 <h3>Static Methods</h3> |
|
386 |
|
387 <table> |
|
388 <tr><td>None</td></tr> |
|
389 </table> |
|
390 |
|
391 <div align="right"><a href="#top">Up</a></div> |
|
392 <hr /> |
|
393 </body></html> |