eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/certificateValidation.py

changeset 7613
382f89c11e27
child 7923
91e843545d9a
equal deleted inserted replaced
7612:ca1ce1e0fcff 7613:382f89c11e27
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2020 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing checks for switched off certificate validation.
8 """
9
10 #
11 # This is a modified version of the one found in the bandit package.
12 #
13 # Original Copyright 2014 Hewlett-Packard Development Company, L.P.
14 #
15 # SPDX-License-Identifier: Apache-2.0
16 #
17
18
19 def getChecks():
20 """
21 Public method to get a dictionary with checks handled by this module.
22
23 @return dictionary containing checker lists containing checker function and
24 list of codes
25 @rtype dict
26 """
27 return {
28 "Call": [
29 (checkNoCertificateValidation, ("S501",)),
30 ],
31 }
32
33
34 def checkNoCertificateValidation(reportError, context, config):
35 """
36 Function to check for switched off certificate validation.
37
38 @param reportError function to be used to report errors
39 @type func
40 @param context security context object
41 @type SecurityContext
42 @param config dictionary with configuration data
43 @type dict
44 """
45 http_verbs = ('get', 'options', 'head', 'post', 'put', 'patch', 'delete')
46 if (
47 'requests' in context.callFunctionNameQual and
48 context.callFunctionName in http_verbs
49 ):
50 if context.checkCallArgValue('verify', 'False'):
51 reportError(
52 context.getLinenoForCallArg('verify') - 1,
53 context.getOffsetForCallArg('verify'),
54 "S501",
55 "H",
56 "H"
57 )

eric ide

mercurial