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 10
10
*/
11
11
12
12
import python
13
+ import semmle.python.ApiGraphs
13
14
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 )
18
18
}
19
19
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 ( )
23
22
}
24
23
25
24
from CallNode call , ControlFlowNode arg , string name
26
25
where
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
29
27
arg = call .getAnArg ( ) and
30
28
(
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 ( )
33
31
)
34
32
select call , "Setting missing host key policy to " + name + " may be unsafe."
You can’t perform that action at this time.
0 commit comments