1
- import python
2
- import semmle.python.ApiGraphs
1
+ private import python
2
+ private import semmle.python.ApiGraphs
3
3
import Ssl
4
4
import PyOpenSSL
5
5
6
6
/**
7
- * A specific protocol version.
8
- * We use this to identify a protocol.
7
+ * A specific protocol version of SSL or TLS.
9
8
*/
10
9
class ProtocolVersion extends string {
11
10
ProtocolVersion ( ) { this in [ "SSLv2" , "SSLv3" , "TLSv1" , "TLSv1_1" , "TLSv1_2" , "TLSv1_3" ] }
12
11
12
+ /** Gets a `ProtocolVersion` that is less than this `ProtocolVersion`, if any. */
13
13
predicate lessThan ( ProtocolVersion version ) {
14
14
this = "SSLv2" and version = "SSLv3"
15
15
or
@@ -20,6 +20,7 @@ class ProtocolVersion extends string {
20
20
this = [ "TLSv1" , "TLSv1_1" , "TLSv1_2" ] and version = "TLSv1_3"
21
21
}
22
22
23
+ /** Holds if this protocol version is known to be insecure. */
23
24
predicate isInsecure ( ) { this in [ "SSLv2" , "SSLv3" , "TLSv1" , "TLSv1_1" ] }
24
25
}
25
26
@@ -81,12 +82,13 @@ abstract class UnspecificContextCreation extends ContextCreation, ProtocolUnrest
81
82
82
83
/** A model of a SSL/TLS library. */
83
84
abstract class TlsLibrary extends string {
84
- TlsLibrary ( ) { this in [ "ssl" , "pyOpenSSL" ] }
85
+ bindingset [ this ]
86
+ TlsLibrary ( ) { any ( ) }
85
87
86
88
/** The name of a specific protocol version. */
87
89
abstract string specific_version_name ( ProtocolVersion version ) ;
88
90
89
- /** The name of an unspecific protocol version, say TLS, known to have insecure instances . */
91
+ /** Gets a name, which is a member of `version_constants`, that can be used to specify the protocol family `family` . */
90
92
abstract string unspecific_version_name ( ProtocolFamily family ) ;
91
93
92
94
/** The module or class holding the version constants. */
@@ -97,12 +99,12 @@ abstract class TlsLibrary extends string {
97
99
result = version_constants ( ) .getMember ( specific_version_name ( version ) ) .getAUse ( )
98
100
}
99
101
100
- /** A dataflow node representing an unspecific protocol version, say TLS, known to have insecure instances . */
102
+ /** Gets a dataflow node representing the protocol family `family` . */
101
103
DataFlow:: Node unspecific_version ( ProtocolFamily family ) {
102
104
result = version_constants ( ) .getMember ( unspecific_version_name ( family ) ) .getAUse ( )
103
105
}
104
106
105
- /** The creation of a context with a deafult protocol. */
107
+ /** The creation of a context with a default protocol. */
106
108
abstract ContextCreation default_context_creation ( ) ;
107
109
108
110
/** The creation of a context with a specific protocol. */
@@ -115,7 +117,7 @@ abstract class TlsLibrary extends string {
115
117
version .isInsecure ( )
116
118
}
117
119
118
- /** The creation of a context with an unspecific protocol version, say TLS , known to have insecure instances. */
120
+ /** Gets a context that was created using `family` , known to have insecure instances. */
119
121
ContextCreation unspecific_context_creation ( ProtocolFamily family ) {
120
122
result in [ specific_context_creation ( ) , default_context_creation ( ) ] and
121
123
result .getProtocol ( ) = family
0 commit comments