src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/sshNoHostKeyVerification.py

branch
eric7
changeset 10507
d1c6608155ef
parent 10439
21c28b0f9e41
child 10638
12558008c269
equal deleted inserted replaced
10506:321555d0303b 10507:d1c6608155ef
12 # 12 #
13 # Original Copyright 2014 Hewlett-Packard Development Company, L.P. 13 # Original Copyright 2014 Hewlett-Packard Development Company, L.P.
14 # 14 #
15 # SPDX-License-Identifier: Apache-2.0 15 # SPDX-License-Identifier: Apache-2.0
16 # 16 #
17
18 import ast
17 19
18 20
19 def getChecks(): 21 def getChecks():
20 """ 22 """
21 Public method to get a dictionary with checks handled by this module. 23 Public method to get a dictionary with checks handled by this module.
43 @type dict 45 @type dict
44 """ 46 """
45 if ( 47 if (
46 context.isModuleImportedLike("paramiko") 48 context.isModuleImportedLike("paramiko")
47 and context.callFunctionName == "set_missing_host_key_policy" 49 and context.callFunctionName == "set_missing_host_key_policy"
48 and context.callArgs 50 and context.node.args
49 and context.callArgs[0] in ["AutoAddPolicy", "WarningPolicy"]
50 ): 51 ):
51 reportError( 52 policyArgument = context.node.args[0]
52 context.node.lineno - 1, 53
53 context.node.col_offset, 54 policyArgumentValue = None
54 "S507", 55 if isinstance(policyArgument, ast.Attribute):
55 "H", 56 policyArgumentValue = policyArgument.attr
56 "M", 57 elif isinstance(policyArgument, ast.Call):
57 ) 58 policyArgumentValue = policyArgument.func.attr
59
60 if policyArgumentValue in ["AutoAddPolicy", "WarningPolicy"]:
61 reportError(
62 context.node.lineno - 1,
63 context.node.col_offset,
64 "S507",
65 "H",
66 "M",
67 )

eric ide

mercurial