@@ -12,13 +12,12 @@ abstract class WeakCryptoSink extends TaintSink {
12
12
}
13
13
}
14
14
15
+ /** Modeling the 'pycrypto' pacakge https://github.com/dlitz/pycrypto (latest release 2013) */
15
16
module Pycrypto {
16
17
17
- ModuleObject cipher ( string name ) {
18
- exists ( PackageObject crypto |
19
- crypto .getName ( ) = "Crypto.Cipher" |
20
- crypto .submodule ( name ) = result
21
- )
18
+ ModuleValue cipher ( string name ) {
19
+ result = Module:: named ( "Crypto.Cipher" ) .attr ( name ) and
20
+ result .isPackage ( )
22
21
}
23
22
24
23
class CipherInstance extends TaintKind {
@@ -51,15 +50,15 @@ module Pycrypto {
51
50
CipherInstanceSource ( ) {
52
51
exists ( AttrNode attr |
53
52
this .( CallNode ) .getFunction ( ) = attr and
54
- attr .getObject ( "new" ) .refersTo ( cipher ( instance .getName ( ) ) )
53
+ attr .getObject ( "new" ) .pointsTo ( cipher ( instance .getName ( ) ) )
55
54
)
56
55
}
57
56
58
57
override string toString ( ) {
59
58
result = "Source of " + instance
60
59
}
61
60
62
- override predicate isSourceOf ( TaintKind kind ) {
61
+ override predicate isSourceOf ( TaintKind kind ) {
63
62
kind = instance
64
63
}
65
64
@@ -70,12 +69,12 @@ module Pycrypto {
70
69
string name ;
71
70
72
71
PycryptoWeakCryptoSink ( ) {
73
- exists ( CallNode call , AttrNode method , CipherInstance Cipher |
72
+ exists ( CallNode call , AttrNode method , CipherInstance cipher |
74
73
call .getAnArg ( ) = this and
75
74
call .getFunction ( ) = method and
76
- Cipher .taints ( method .getObject ( "encrypt" ) ) and
77
- Cipher .isWeak ( ) and
78
- Cipher .getName ( ) = name
75
+ cipher .taints ( method .getObject ( "encrypt" ) ) and
76
+ cipher .isWeak ( ) and
77
+ cipher .getName ( ) = name
79
78
)
80
79
}
81
80
@@ -89,25 +88,25 @@ module Pycrypto {
89
88
90
89
module Cryptography {
91
90
92
- PackageObject ciphers ( ) {
93
- result .getName ( ) = "cryptography.hazmat.primitives.ciphers"
91
+ ModuleValue ciphers ( ) {
92
+ result = Module:: named ( "cryptography.hazmat.primitives.ciphers" ) and
93
+ result .isPackage ( )
94
94
}
95
95
96
- class CipherClass extends ClassObject {
96
+ class CipherClass extends ClassValue {
97
97
CipherClass ( ) {
98
98
ciphers ( ) .attr ( "Cipher" ) = this
99
99
}
100
-
101
100
}
102
101
103
- class AlgorithmClass extends ClassObject {
102
+ class AlgorithmClass extends ClassValue {
104
103
105
104
AlgorithmClass ( ) {
106
- ciphers ( ) .submodule ( "algorithms" ) .attr ( _) = this
105
+ ciphers ( ) .attr ( "algorithms" ) .attr ( _) = this
107
106
}
108
107
109
108
string getAlgorithmName ( ) {
110
- result = this .declaredAttribute ( "name" ) .( StringObject ) .getText ( )
109
+ result = this .declaredAttribute ( "name" ) .( StringValue ) .getText ( )
111
110
}
112
111
113
112
predicate isWeak ( ) {
@@ -134,7 +133,7 @@ module Cryptography {
134
133
cls .isWeak ( )
135
134
}
136
135
137
- override TaintKind getTaintOfMethodResult ( string name ) {
136
+ override TaintKind getTaintOfMethodResult ( string name ) {
138
137
name = "encryptor" and
139
138
result .( Encryptor ) .getAlgorithm ( ) = this .getAlgorithm ( )
140
139
}
@@ -144,11 +143,11 @@ module Cryptography {
144
143
class CipherSource extends TaintSource {
145
144
146
145
CipherSource ( ) {
147
- this .( CallNode ) .getFunction ( ) .refersTo ( any ( CipherClass cls ) )
146
+ this .( CallNode ) .getFunction ( ) .pointsTo ( any ( CipherClass cls ) )
148
147
}
149
148
150
149
override predicate isSourceOf ( TaintKind kind ) {
151
- this .( CallNode ) .getArg ( 0 ) .refersTo ( _ , kind .( CipherInstance ) .getAlgorithm ( ) , _ )
150
+ this .( CallNode ) .getArg ( 0 ) .pointsTo ( ) . getClass ( ) = kind .( CipherInstance ) .getAlgorithm ( )
152
151
}
153
152
154
153
override string toString ( ) {
@@ -203,5 +202,3 @@ private class CipherConfig extends TaintTracking::Configuration {
203
202
}
204
203
205
204
}
206
-
207
-
0 commit comments