Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ee03837

Browse files
committed
Python: small refactor
1 parent cbbc7b2 commit ee03837

3 files changed

Lines changed: 6 additions & 11 deletions

File tree

python/ql/src/Security/CWE-327/PyOpenSSL.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ class UnspecificPyOpenSSLContextCreation extends PyOpenSSLContextCreation, Unspe
5151
class PyOpenSSL extends TlsLibrary {
5252
PyOpenSSL() { this = "pyOpenSSL" }
5353

54-
override string specific_insecure_version_name(ProtocolVersion version) {
55-
version in ["SSLv2", "SSLv3", "TLSv1", "TLSv1_1"] and
56-
result = version + "_METHOD"
57-
}
54+
override string specific_version_name(ProtocolVersion version) { result = version + "_METHOD" }
5855

5956
override string unspecific_version_name(ProtocolFamily family) {
6057
// `"TLS_METHOD"` is not actually available in pyOpenSSL yet, but should be coming soon..

python/ql/src/Security/CWE-327/Ssl.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ class UnspecificSSLContextCreation extends SSLContextCreation, UnspecificContext
135135
class Ssl extends TlsLibrary {
136136
Ssl() { this = "ssl" }
137137

138-
override string specific_insecure_version_name(ProtocolVersion version) {
139-
version in ["SSLv2", "SSLv3", "TLSv1", "TLSv1_1"] and
140-
result = "PROTOCOL_" + version
141-
}
138+
override string specific_version_name(ProtocolVersion version) { result = "PROTOCOL_" + version }
142139

143140
override string unspecific_version_name(ProtocolFamily family) { result = "PROTOCOL_" + family }
144141

python/ql/src/Security/CWE-327/TlsLibraryModel.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ abstract class UnspecificContextCreation extends ContextCreation, ProtocolUnrest
8080
abstract class TlsLibrary extends string {
8181
TlsLibrary() { this in ["ssl", "pyOpenSSL"] }
8282

83-
/** The name of a specific protocol version, known to be insecure. */
84-
abstract string specific_insecure_version_name(ProtocolVersion version);
83+
/** The name of a specific protocol version. */
84+
abstract string specific_version_name(ProtocolVersion version);
8585

8686
/** The name of an unspecific protocol version, say TLS, known to have insecure instances. */
8787
abstract string unspecific_version_name(ProtocolFamily family);
@@ -91,7 +91,8 @@ abstract class TlsLibrary extends string {
9191

9292
/** A dataflow node representing a specific protocol version, known to be insecure. */
9393
DataFlow::Node insecure_version(ProtocolVersion version) {
94-
result = version_constants().getMember(specific_insecure_version_name(version)).getAUse()
94+
version.isInsecure() and
95+
result = version_constants().getMember(specific_version_name(version)).getAUse()
9596
}
9697

9798
/** A dataflow node representing an unspecific protocol version, say TLS, known to have insecure instances. */

0 commit comments

Comments
 (0)