@@ -228,11 +228,7 @@ private module CryptographyModel {
228
228
/** Gets a reference to the encryptor of a Cipher instance using algorithm with `algorithmName`. */
229
229
DataFlow:: LocalSourceNode cipherEncryptor ( DataFlow:: TypeTracker t , string algorithmName ) {
230
230
t .start ( ) and
231
- exists ( DataFlow:: AttrRead attr |
232
- result .( DataFlow:: CallCfgNode ) .getFunction ( ) = attr and
233
- attr .getAttributeName ( ) = "encryptor" and
234
- attr .getObject ( ) = cipherInstance ( algorithmName )
235
- )
231
+ result .( DataFlow:: MethodCallNode ) .calls ( cipherInstance ( algorithmName ) , "encryptor" )
236
232
or
237
233
exists ( DataFlow:: TypeTracker t2 | result = cipherEncryptor ( t2 , algorithmName ) .track ( t2 , t ) )
238
234
}
@@ -249,11 +245,7 @@ private module CryptographyModel {
249
245
/** Gets a reference to the dncryptor of a Cipher instance using algorithm with `algorithmName`. */
250
246
DataFlow:: LocalSourceNode cipherDecryptor ( DataFlow:: TypeTracker t , string algorithmName ) {
251
247
t .start ( ) and
252
- exists ( DataFlow:: AttrRead attr |
253
- result .( DataFlow:: CallCfgNode ) .getFunction ( ) = attr and
254
- attr .getAttributeName ( ) = "decryptor" and
255
- attr .getObject ( ) = cipherInstance ( algorithmName )
256
- )
248
+ result .( DataFlow:: MethodCallNode ) .calls ( cipherInstance ( algorithmName ) , "decryptor" )
257
249
or
258
250
exists ( DataFlow:: TypeTracker t2 | result = cipherDecryptor ( t2 , algorithmName ) .track ( t2 , t ) )
259
251
}
@@ -271,19 +263,12 @@ private module CryptographyModel {
271
263
* An encrypt or decrypt operation from `cryptography.hazmat.primitives.ciphers`.
272
264
*/
273
265
class CryptographyGenericCipherOperation extends Cryptography:: CryptographicOperation:: Range ,
274
- DataFlow:: CallCfgNode {
266
+ DataFlow:: MethodCallNode {
275
267
string algorithmName ;
276
268
277
269
CryptographyGenericCipherOperation ( ) {
278
- exists ( DataFlow:: AttrRead attr |
279
- this .getFunction ( ) = attr and
280
- attr .getAttributeName ( ) = [ "update" , "update_into" ] and
281
- (
282
- attr .getObject ( ) = cipherEncryptor ( algorithmName )
283
- or
284
- attr .getObject ( ) = cipherDecryptor ( algorithmName )
285
- )
286
- )
270
+ this .getMethodName ( ) in [ "update" , "update_into" ] and
271
+ this .getReceiver ( ) in [ cipherEncryptor ( algorithmName ) , cipherDecryptor ( algorithmName ) ]
287
272
}
288
273
289
274
override Cryptography:: CryptographicAlgorithm getAlgorithm ( ) {
@@ -337,16 +322,10 @@ private module CryptographyModel {
337
322
* An hashing operation from `cryptography.hazmat.primitives.hashes`.
338
323
*/
339
324
class CryptographyGenericHashOperation extends Cryptography:: CryptographicOperation:: Range ,
340
- DataFlow:: CallCfgNode {
325
+ DataFlow:: MethodCallNode {
341
326
string algorithmName ;
342
327
343
- CryptographyGenericHashOperation ( ) {
344
- exists ( DataFlow:: AttrRead attr |
345
- this .getFunction ( ) = attr and
346
- attr .getAttributeName ( ) = "update" and
347
- attr .getObject ( ) = hashInstance ( algorithmName )
348
- )
349
- }
328
+ CryptographyGenericHashOperation ( ) { this .calls ( hashInstance ( algorithmName ) , "update" ) }
350
329
351
330
override Cryptography:: CryptographicAlgorithm getAlgorithm ( ) {
352
331
result .matchesName ( algorithmName )
0 commit comments