Skip to content

Commit 5bb4a1a

Browse files
committed
Python: Use explicit argument specification instead of getAnArg
I've seen quite a few places where `getAnArg` leads to wrong behavior, and I generally just don't like it.
1 parent c3d2001 commit 5bb4a1a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

python/ql/src/Security/CWE-295/MissingHostKeyValidation.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ private API::Node paramikoSSHClientInstance() {
2424

2525
from DataFlow::CallCfgNode call, DataFlow::Node arg, string name
2626
where
27+
// see http://docs.paramiko.org/en/stable/api/client.html#paramiko.client.SSHClient.set_missing_host_key_policy
2728
call = paramikoSSHClientInstance().getMember("set_missing_host_key_policy").getACall() and
28-
arg = call.getAnArg() and
29+
arg in [call.getArg(0), call.getArgByName("policy")] and
2930
(
3031
arg = unsafe_paramiko_policy(name).getAUse() or
3132
arg = unsafe_paramiko_policy(name).getReturn().getAUse()

0 commit comments

Comments
 (0)