@@ -12,13 +12,12 @@ abstract class WeakCryptoSink extends TaintSink {
1212 }
1313}
1414
15+ /** Modeling the 'pycrypto' pacakge 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 ) and
20+ result .isPackage ( )
2221 }
2322
2423 class CipherInstance extends TaintKind {
@@ -51,15 +50,15 @@ module Pycrypto {
5150 CipherInstanceSource ( ) {
5251 exists ( AttrNode attr |
5352 this .( CallNode ) .getFunction ( ) = attr and
54- attr .getObject ( "new" ) .refersTo ( cipher ( instance .getName ( ) ) )
53+ attr .getObject ( "new" ) .pointsTo ( cipher ( instance .getName ( ) ) )
5554 )
5655 }
5756
5857 override string toString ( ) {
5958 result = "Source of " + instance
6059 }
6160
62- override predicate isSourceOf ( TaintKind kind ) {
61+ override predicate isSourceOf ( TaintKind kind ) {
6362 kind = instance
6463 }
6564
@@ -70,12 +69,12 @@ module Pycrypto {
7069 string name ;
7170
7271 PycryptoWeakCryptoSink ( ) {
73- exists ( CallNode call , AttrNode method , CipherInstance Cipher |
72+ exists ( CallNode call , AttrNode method , CipherInstance cipher |
7473 call .getAnArg ( ) = this and
7574 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
7978 )
8079 }
8180
@@ -89,25 +88,25 @@ module Pycrypto {
8988
9089module Cryptography {
9190
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 ( )
9494 }
9595
96- class CipherClass extends ClassObject {
96+ class CipherClass extends ClassValue {
9797 CipherClass ( ) {
9898 ciphers ( ) .attr ( "Cipher" ) = this
9999 }
100-
101100 }
102101
103- class AlgorithmClass extends ClassObject {
102+ class AlgorithmClass extends ClassValue {
104103
105104 AlgorithmClass ( ) {
106- ciphers ( ) .submodule ( "algorithms" ) .attr ( _) = this
105+ ciphers ( ) .attr ( "algorithms" ) .attr ( _) = this
107106 }
108107
109108 string getAlgorithmName ( ) {
110- result = this .declaredAttribute ( "name" ) .( StringObject ) .getText ( )
109+ result = this .declaredAttribute ( "name" ) .( StringValue ) .getText ( )
111110 }
112111
113112 predicate isWeak ( ) {
@@ -134,7 +133,7 @@ module Cryptography {
134133 cls .isWeak ( )
135134 }
136135
137- override TaintKind getTaintOfMethodResult ( string name ) {
136+ override TaintKind getTaintOfMethodResult ( string name ) {
138137 name = "encryptor" and
139138 result .( Encryptor ) .getAlgorithm ( ) = this .getAlgorithm ( )
140139 }
@@ -144,11 +143,11 @@ module Cryptography {
144143 class CipherSource extends TaintSource {
145144
146145 CipherSource ( ) {
147- this .( CallNode ) .getFunction ( ) .refersTo ( any ( CipherClass cls ) )
146+ this .( CallNode ) .getFunction ( ) .pointsTo ( any ( CipherClass cls ) )
148147 }
149148
150149 override predicate isSourceOf ( TaintKind kind ) {
151- this .( CallNode ) .getArg ( 0 ) .refersTo ( _ , kind .( CipherInstance ) .getAlgorithm ( ) , _ )
150+ this .( CallNode ) .getArg ( 0 ) .pointsTo ( ) . getClass ( ) = kind .( CipherInstance ) .getAlgorithm ( )
152151 }
153152
154153 override string toString ( ) {
@@ -203,5 +202,3 @@ private class CipherConfig extends TaintTracking::Configuration {
203202 }
204203
205204}
206-
207-
0 commit comments