@@ -183,64 +183,42 @@ private module CryptographyModel {
183
183
.getMember ( algorithmName )
184
184
}
185
185
186
- /**
187
- * Internal module making it easy to hide verbose type-tracking helpers.
188
- *
189
- * These turned out to be so verbose, that it was impossible to get an overview of
190
- * the relevant predicates without hiding them away.
191
- */
192
- private module InternalTypeTracking {
193
- /** Gets a reference to a Cipher instance using algorithm with `algorithmName`. */
194
- DataFlow:: LocalSourceNode cipherInstance ( DataFlow:: TypeTracker t , string algorithmName ) {
195
- t .start ( ) and
196
- exists ( DataFlow:: CallCfgNode call | result = call |
197
- call =
198
- API:: moduleImport ( "cryptography" )
199
- .getMember ( "hazmat" )
200
- .getMember ( "primitives" )
201
- .getMember ( "ciphers" )
202
- .getMember ( "Cipher" )
203
- .getACall ( ) and
204
- algorithmClassRef ( algorithmName ) .getReturn ( ) .getAUse ( ) in [
205
- call .getArg ( 0 ) , call .getArgByName ( "algorithm" )
206
- ]
207
- )
208
- or
209
- exists ( DataFlow:: TypeTracker t2 | result = cipherInstance ( t2 , algorithmName ) .track ( t2 , t ) )
210
- }
211
-
212
- /** Gets a reference to the encryptor of a Cipher instance using algorithm with `algorithmName`. */
213
- DataFlow:: LocalSourceNode cipherEncryptor ( DataFlow:: TypeTracker t , string algorithmName ) {
214
- t .start ( ) and
215
- exists ( DataFlow:: AttrRead attr |
216
- result .( DataFlow:: CallCfgNode ) .getFunction ( ) = attr and
217
- attr .getAttributeName ( ) = "encryptor" and
218
- attr .getObject ( ) = cipherInstance ( algorithmName )
219
- )
220
- or
221
- exists ( DataFlow:: TypeTracker t2 | result = cipherEncryptor ( t2 , algorithmName ) .track ( t2 , t ) )
222
- }
223
-
224
- /** Gets a reference to the dncryptor of a Cipher instance using algorithm with `algorithmName`. */
225
- DataFlow:: LocalSourceNode cipherDecryptor ( DataFlow:: TypeTracker t , string algorithmName ) {
226
- t .start ( ) and
227
- exists ( DataFlow:: AttrRead attr |
228
- result .( DataFlow:: CallCfgNode ) .getFunction ( ) = attr and
229
- attr .getAttributeName ( ) = "decryptor" and
230
- attr .getObject ( ) = cipherInstance ( algorithmName )
231
- )
232
- or
233
- exists ( DataFlow:: TypeTracker t2 | result = cipherDecryptor ( t2 , algorithmName ) .track ( t2 , t ) )
234
- }
186
+ /** Gets a reference to a Cipher instance using algorithm with `algorithmName`. */
187
+ DataFlow:: LocalSourceNode cipherInstance ( DataFlow:: TypeTracker t , string algorithmName ) {
188
+ t .start ( ) and
189
+ exists ( DataFlow:: CallCfgNode call | result = call |
190
+ call =
191
+ API:: moduleImport ( "cryptography" )
192
+ .getMember ( "hazmat" )
193
+ .getMember ( "primitives" )
194
+ .getMember ( "ciphers" )
195
+ .getMember ( "Cipher" )
196
+ .getACall ( ) and
197
+ algorithmClassRef ( algorithmName ) .getReturn ( ) .getAUse ( ) in [
198
+ call .getArg ( 0 ) , call .getArgByName ( "algorithm" )
199
+ ]
200
+ )
201
+ or
202
+ exists ( DataFlow:: TypeTracker t2 | result = cipherInstance ( t2 , algorithmName ) .track ( t2 , t ) )
235
203
}
236
204
237
- private import InternalTypeTracking
238
-
239
205
/** Gets a reference to a Cipher instance using algorithm with `algorithmName`. */
240
206
DataFlow:: Node cipherInstance ( string algorithmName ) {
241
207
cipherInstance ( DataFlow:: TypeTracker:: end ( ) , algorithmName ) .flowsTo ( result )
242
208
}
243
209
210
+ /** Gets a reference to the encryptor of a Cipher instance using algorithm with `algorithmName`. */
211
+ DataFlow:: LocalSourceNode cipherEncryptor ( DataFlow:: TypeTracker t , string algorithmName ) {
212
+ t .start ( ) and
213
+ exists ( DataFlow:: AttrRead attr |
214
+ result .( DataFlow:: CallCfgNode ) .getFunction ( ) = attr and
215
+ attr .getAttributeName ( ) = "encryptor" and
216
+ attr .getObject ( ) = cipherInstance ( algorithmName )
217
+ )
218
+ or
219
+ exists ( DataFlow:: TypeTracker t2 | result = cipherEncryptor ( t2 , algorithmName ) .track ( t2 , t ) )
220
+ }
221
+
244
222
/**
245
223
* Gets a reference to the encryptor of a Cipher instance using algorithm with `algorithmName`.
246
224
*
@@ -250,6 +228,18 @@ private module CryptographyModel {
250
228
cipherEncryptor ( DataFlow:: TypeTracker:: end ( ) , algorithmName ) .flowsTo ( result )
251
229
}
252
230
231
+ /** Gets a reference to the dncryptor of a Cipher instance using algorithm with `algorithmName`. */
232
+ DataFlow:: LocalSourceNode cipherDecryptor ( DataFlow:: TypeTracker t , string algorithmName ) {
233
+ t .start ( ) and
234
+ exists ( DataFlow:: AttrRead attr |
235
+ result .( DataFlow:: CallCfgNode ) .getFunction ( ) = attr and
236
+ attr .getAttributeName ( ) = "decryptor" and
237
+ attr .getObject ( ) = cipherInstance ( algorithmName )
238
+ )
239
+ or
240
+ exists ( DataFlow:: TypeTracker t2 | result = cipherDecryptor ( t2 , algorithmName ) .track ( t2 , t ) )
241
+ }
242
+
253
243
/**
254
244
* Gets a reference to the decryptor of a Cipher instance using algorithm with `algorithmName`.
255
245
*
0 commit comments