Skip to content

Commit dfe3fc6

Browse files
committed
Pass pyOpenSSL method as parameter instead of keyword argument.
1 parent d604f5c commit dfe3fc6

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

python/ql/src/Security/CWE-327/InsecureProtocol.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ClassObject the_pyOpenSSL_Context_class() {
6868
predicate unsafe_pyOpenSSL_Context_call(CallNode call, string insecure_version) {
6969
call = the_pyOpenSSL_Context_class().getACall() and
7070
insecure_version = insecure_version_name() and
71-
call.getArgByName("method").refersTo(the_pyOpenSSL_module().getAttribute(insecure_version))
71+
call.getArg(0).refersTo(the_pyOpenSSL_module().getAttribute(insecure_version))
7272
}
7373

7474
from CallNode call, string method_name, string insecure_version

python/ql/test/query-tests/Security/CWE-327/InsecureProtocol.expected

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
| InsecureProtocol.py:10:1:10:42 | ControlFlowNode for SSLContext() | Insecure SSL/TLS protocol version PROTOCOL_SSLv2 specified in call to ssl.SSLContext. |
55
| InsecureProtocol.py:11:1:11:42 | ControlFlowNode for SSLContext() | Insecure SSL/TLS protocol version PROTOCOL_SSLv3 specified in call to ssl.SSLContext. |
66
| InsecureProtocol.py:12:1:12:42 | ControlFlowNode for SSLContext() | Insecure SSL/TLS protocol version PROTOCOL_TLSv1 specified in call to ssl.SSLContext. |
7-
| InsecureProtocol.py:14:1:14:36 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version SSLv2_METHOD specified in call to pyOpenSSL.SSL.Context. |
8-
| InsecureProtocol.py:15:1:15:37 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version SSLv23_METHOD specified in call to pyOpenSSL.SSL.Context. |
9-
| InsecureProtocol.py:16:1:16:36 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version SSLv3_METHOD specified in call to pyOpenSSL.SSL.Context. |
10-
| InsecureProtocol.py:17:1:17:36 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version TLSv1_METHOD specified in call to pyOpenSSL.SSL.Context. |
11-
| InsecureProtocol.py:32:1:32:26 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version SSLv2_METHOD specified in call to pyOpenSSL.SSL.Context. |
7+
| InsecureProtocol.py:14:1:14:29 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version SSLv2_METHOD specified in call to pyOpenSSL.SSL.Context. |
8+
| InsecureProtocol.py:15:1:15:30 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version SSLv23_METHOD specified in call to pyOpenSSL.SSL.Context. |
9+
| InsecureProtocol.py:16:1:16:29 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version SSLv3_METHOD specified in call to pyOpenSSL.SSL.Context. |
10+
| InsecureProtocol.py:17:1:17:29 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version TLSv1_METHOD specified in call to pyOpenSSL.SSL.Context. |
11+
| InsecureProtocol.py:32:1:32:19 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version SSLv2_METHOD specified in call to pyOpenSSL.SSL.Context. |

python/ql/test/query-tests/Security/CWE-327/InsecureProtocol.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@
1111
SSLContext(ssl_version=ssl.PROTOCOL_SSLv3)
1212
SSLContext(ssl_version=ssl.PROTOCOL_TLSv1)
1313

14-
SSL.Context(method=SSL.SSLv2_METHOD)
15-
SSL.Context(method=SSL.SSLv23_METHOD)
16-
SSL.Context(method=SSL.SSLv3_METHOD)
17-
SSL.Context(method=SSL.TLSv1_METHOD)
14+
SSL.Context(SSL.SSLv2_METHOD)
15+
SSL.Context(SSL.SSLv23_METHOD)
16+
SSL.Context(SSL.SSLv3_METHOD)
17+
SSL.Context(SSL.TLSv1_METHOD)
1818

1919
# not relevant
2020
wrap_socket(ssl_version=ssl.PROTOCOL_SSLv3)
2121
wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1)
2222
wrap_socket(ssl_version=ssl.PROTOCOL_SSLv2)
2323

24-
Context(method=SSL.SSLv3_METHOD)
25-
Context(method=SSL.TLSv1_METHOD)
26-
Context(method=SSL.SSLv2_METHOD)
27-
Context(method=SSL.SSLv23_METHOD)
24+
Context(SSL.SSLv3_METHOD)
25+
Context(SSL.TLSv1_METHOD)
26+
Context(SSL.SSLv2_METHOD)
27+
Context(SSL.SSLv23_METHOD)
2828

2929
# true positive using flow
3030

3131
METHOD = SSL.SSLv2_METHOD
32-
SSL.Context(method=METHOD)
32+
SSL.Context(METHOD)
3333

3434
# secure versions
3535

3636
ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1_1)
3737
SSLContext(ssl_version=ssl.PROTOCOL_TLSv1_1)
38-
SSL.Context(method=SSL.TLSv1_1_METHOD)
38+
SSL.Context(SSL.TLSv1_1_METHOD)
3939

4040
# possibly insecure default
4141
ssl.wrap_socket()

0 commit comments

Comments
 (0)