Skip to content

Commit 5eb63ae

Browse files
committed
Fix false positive and add test.
1 parent 9cb35a8 commit 5eb63ae

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ CallNode unsafe_call(string method_name) {
2727
or
2828
result = ssl_Context_class().getACall() and
2929
not exists(result.getArgByName("protocol")) and
30+
not exists(result.getArg(0)) and
3031
method_name = "ssl.SSLContext"
3132
}
3233

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
| InsecureProtocol.py:32:1:32:19 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version SSLv2_METHOD specified in call to pyOpenSSL.SSL.Context. |
1212
| InsecureProtocol.py:48:1:48:43 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version PROTOCOL_SSLv2 specified in call to deprecated method ssl.wrap_socket. |
1313
| InsecureProtocol.py:49:1:49:35 | ControlFlowNode for SSLContext() | Insecure SSL/TLS protocol version PROTOCOL_SSLv2 specified in call to ssl.SSLContext. |
14+
| InsecureProtocol.py:52:1:52:33 | ControlFlowNode for Attribute() | Insecure SSL/TLS protocol version SSLv23_METHOD specified in call to ssl.SSLContext. |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@
4848
ssl.wrap_socket(ssl_version=PROTOCOL_SSLv2)
4949
SSLContext(protocol=PROTOCOL_SSLv2)
5050

51+
# FP for insecure default
52+
ssl.SSLContext(ssl.SSLv23_METHOD)

0 commit comments

Comments
 (0)