@@ -12,13 +12,11 @@ abstract class WeakCryptoSink extends TaintSink {
1212 }
1313}
1414
15+ /** Modeling the 'pycrypto' package https://github.com/dlitz/pycrypto (latest release 2013) */
1516module Pycrypto {
1617
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 )
2220 }
2321
2422 class CipherInstance extends TaintKind {
@@ -51,15 +49,15 @@ module Pycrypto {
5149 CipherInstanceSource ( ) {
5250 exists ( AttrNode attr |
5351 this .( CallNode ) .getFunction ( ) = attr and
54- attr .getObject ( "new" ) .refersTo ( cipher ( instance .getName ( ) ) )
52+ attr .getObject ( "new" ) .pointsTo ( cipher ( instance .getName ( ) ) )
5553 )
5654 }
5755
5856 override string toString ( ) {
5957 result = "Source of " + instance
6058 }
6159
62- override predicate isSourceOf ( TaintKind kind ) {
60+ override predicate isSourceOf ( TaintKind kind ) {
6361 kind = instance
6462 }
6563
@@ -70,12 +68,12 @@ module Pycrypto {
7068 string name ;
7169
7270 PycryptoWeakCryptoSink ( ) {
73- exists ( CallNode call , AttrNode method , CipherInstance Cipher |
71+ exists ( CallNode call , AttrNode method , CipherInstance cipher |
7472 call .getAnArg ( ) = this and
7573 call .getFunction ( ) = method and
76- Cipher .taints ( method .getObject ( "encrypt" ) ) and
77- Cipher .isWeak ( ) and
78- Cipher .getName ( ) = name
74+ cipher .taints ( method .getObject ( "encrypt" ) ) and
75+ cipher .isWeak ( ) and
76+ cipher .getName ( ) = name
7977 )
8078 }
8179
@@ -89,25 +87,25 @@ module Pycrypto {
8987
9088module Cryptography {
9189
92- PackageObject ciphers ( ) {
93- result .getName ( ) = "cryptography.hazmat.primitives.ciphers"
90+ ModuleValue ciphers ( ) {
91+ result = Module:: named ( "cryptography.hazmat.primitives.ciphers" ) and
92+ result .isPackage ( )
9493 }
9594
96- class CipherClass extends ClassObject {
95+ class CipherClass extends ClassValue {
9796 CipherClass ( ) {
9897 ciphers ( ) .attr ( "Cipher" ) = this
9998 }
100-
10199 }
102100
103- class AlgorithmClass extends ClassObject {
101+ class AlgorithmClass extends ClassValue {
104102
105103 AlgorithmClass ( ) {
106- ciphers ( ) .submodule ( "algorithms" ) .attr ( _) = this
104+ ciphers ( ) .attr ( "algorithms" ) .attr ( _) = this
107105 }
108106
109107 string getAlgorithmName ( ) {
110- result = this .declaredAttribute ( "name" ) .( StringObject ) .getText ( )
108+ result = this .declaredAttribute ( "name" ) .( StringValue ) .getText ( )
111109 }
112110
113111 predicate isWeak ( ) {
@@ -134,7 +132,7 @@ module Cryptography {
134132 cls .isWeak ( )
135133 }
136134
137- override TaintKind getTaintOfMethodResult ( string name ) {
135+ override TaintKind getTaintOfMethodResult ( string name ) {
138136 name = "encryptor" and
139137 result .( Encryptor ) .getAlgorithm ( ) = this .getAlgorithm ( )
140138 }
@@ -144,11 +142,11 @@ module Cryptography {
144142 class CipherSource extends TaintSource {
145143
146144 CipherSource ( ) {
147- this .( CallNode ) .getFunction ( ) .refersTo ( any ( CipherClass cls ) )
145+ this .( CallNode ) .getFunction ( ) .pointsTo ( any ( CipherClass cls ) )
148146 }
149147
150148 override predicate isSourceOf ( TaintKind kind ) {
151- this .( CallNode ) .getArg ( 0 ) .refersTo ( _ , kind .( CipherInstance ) .getAlgorithm ( ) , _ )
149+ this .( CallNode ) .getArg ( 0 ) .pointsTo ( ) . getClass ( ) = kind .( CipherInstance ) .getAlgorithm ( )
152150 }
153151
154152 override string toString ( ) {
@@ -203,5 +201,3 @@ private class CipherConfig extends TaintTracking::Configuration {
203201 }
204202
205203}
206-
207-
0 commit comments