File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
python/ql/src/Security/CWE-295 Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 1010 */
1111
1212import python
13+ import semmle.python.ApiGraphs
1314
14- private ModuleValue theParamikoClientModule ( ) { result = Value:: named ( "paramiko.client" ) }
15-
16- private ClassValue theParamikoSSHClientClass ( ) {
17- result = theParamikoClientModule ( ) .attr ( "SSHClient" )
15+ private API:: Node unsafe_paramiko_policy ( string name ) {
16+ name in [ "AutoAddPolicy" , "WarningPolicy" ] and
17+ result = API:: moduleImport ( "paramiko" ) .getMember ( "client" ) .getMember ( name )
1818}
1919
20- private ClassValue unsafe_paramiko_policy ( string name ) {
21- ( name = "AutoAddPolicy" or name = "WarningPolicy" ) and
22- result = theParamikoClientModule ( ) .attr ( name )
20+ private API:: Node paramikoSSHClientInstance ( ) {
21+ result = API:: moduleImport ( "paramiko" ) .getMember ( "client" ) .getMember ( "SSHClient" ) .getReturn ( )
2322}
2423
2524from CallNode call , ControlFlowNode arg , string name
2625where
27- call =
28- theParamikoSSHClientClass ( ) .lookup ( "set_missing_host_key_policy" ) .( FunctionValue ) .getACall ( ) and
26+ call = paramikoSSHClientInstance ( ) .getMember ( "set_missing_host_key_policy" ) .getACall ( ) .asCfgNode ( ) and
2927 arg = call .getAnArg ( ) and
3028 (
31- arg . pointsTo ( unsafe_paramiko_policy ( name ) ) or
32- arg . pointsTo ( ) .getClass ( ) = unsafe_paramiko_policy ( name )
29+ arg = unsafe_paramiko_policy ( name ) . getAUse ( ) . asCfgNode ( ) or
30+ arg = unsafe_paramiko_policy ( name ) . getReturn ( ) .getAUse ( ) . asCfgNode ( )
3331 )
3432select call , "Setting missing host key policy to " + name + " may be unsafe."
You can’t perform that action at this time.
0 commit comments