Skip to content

Commit 222c087

Browse files
committed
Python: Remove type-tracking performance workaround
Since we shouldn't need it anymore (yay)
1 parent b822099 commit 222c087

File tree

2 files changed

+5
-79
lines changed

2 files changed

+5
-79
lines changed

python/ql/src/semmle/python/frameworks/Cryptography.qll

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,7 @@ private module CryptographyModel {
206206
]
207207
)
208208
or
209-
// Due to bad performance when using normal setup with `cipherInstance(t2, algorithmName).track(t2, t)`
210-
// we have inlined that code and forced a join
211-
exists(DataFlow::TypeTracker t2 |
212-
exists(DataFlow::StepSummary summary |
213-
cipherInstance_first_join(t2, algorithmName, result, summary) and
214-
t = t2.append(summary)
215-
)
216-
)
217-
}
218-
219-
pragma[nomagic]
220-
private predicate cipherInstance_first_join(
221-
DataFlow::TypeTracker t2, string algorithmName, DataFlow::Node res,
222-
DataFlow::StepSummary summary
223-
) {
224-
DataFlow::StepSummary::step(cipherInstance(t2, algorithmName), res, summary)
209+
exists(DataFlow::TypeTracker t2 | result = cipherInstance(t2, algorithmName).track(t2, t))
225210
}
226211

227212
/** Gets a reference to the encryptor of a Cipher instance using algorithm with `algorithmName`. */
@@ -233,22 +218,7 @@ private module CryptographyModel {
233218
attr.getObject() = cipherInstance(algorithmName)
234219
)
235220
or
236-
// Due to bad performance when using normal setup with `cipherEncryptor(t2, algorithmName).track(t2, t)`
237-
// we have inlined that code and forced a join
238-
exists(DataFlow::TypeTracker t2 |
239-
exists(DataFlow::StepSummary summary |
240-
cipherEncryptor_first_join(t2, algorithmName, result, summary) and
241-
t = t2.append(summary)
242-
)
243-
)
244-
}
245-
246-
pragma[nomagic]
247-
private predicate cipherEncryptor_first_join(
248-
DataFlow::TypeTracker t2, string algorithmName, DataFlow::Node res,
249-
DataFlow::StepSummary summary
250-
) {
251-
DataFlow::StepSummary::step(cipherEncryptor(t2, algorithmName), res, summary)
221+
exists(DataFlow::TypeTracker t2 | result = cipherEncryptor(t2, algorithmName).track(t2, t))
252222
}
253223

254224
/** Gets a reference to the dncryptor of a Cipher instance using algorithm with `algorithmName`. */
@@ -260,22 +230,7 @@ private module CryptographyModel {
260230
attr.getObject() = cipherInstance(algorithmName)
261231
)
262232
or
263-
// Due to bad performance when using normal setup with `cipherDecryptor(t2, algorithmName).track(t2, t)`
264-
// we have inlined that code and forced a join
265-
exists(DataFlow::TypeTracker t2 |
266-
exists(DataFlow::StepSummary summary |
267-
cipherDecryptor_first_join(t2, algorithmName, result, summary) and
268-
t = t2.append(summary)
269-
)
270-
)
271-
}
272-
273-
pragma[nomagic]
274-
private predicate cipherDecryptor_first_join(
275-
DataFlow::TypeTracker t2, string algorithmName, DataFlow::Node res,
276-
DataFlow::StepSummary summary
277-
) {
278-
DataFlow::StepSummary::step(cipherDecryptor(t2, algorithmName), res, summary)
233+
exists(DataFlow::TypeTracker t2 | result = cipherDecryptor(t2, algorithmName).track(t2, t))
279234
}
280235
}
281236

@@ -362,22 +317,7 @@ private module CryptographyModel {
362317
]
363318
)
364319
or
365-
// Due to bad performance when using normal setup with `hashInstance(t2, algorithmName).track(t2, t)`
366-
// we have inlined that code and forced a join
367-
exists(DataFlow::TypeTracker t2 |
368-
exists(DataFlow::StepSummary summary |
369-
hashInstance_first_join(t2, algorithmName, result, summary) and
370-
t = t2.append(summary)
371-
)
372-
)
373-
}
374-
375-
pragma[nomagic]
376-
private predicate hashInstance_first_join(
377-
DataFlow::TypeTracker t2, string algorithmName, DataFlow::Node res,
378-
DataFlow::StepSummary summary
379-
) {
380-
DataFlow::StepSummary::step(hashInstance(t2, algorithmName), res, summary)
320+
exists(DataFlow::TypeTracker t2 | result = hashInstance(t2, algorithmName).track(t2, t))
381321
}
382322

383323
/** Gets a reference to a Hash instance using algorithm with `algorithmName`. */

python/ql/src/semmle/python/frameworks/Stdlib.qll

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -886,21 +886,7 @@ private DataFlow::LocalSourceNode hashlibNewResult(DataFlow::TypeTracker t, stri
886886
t.start() and
887887
result = hashlibNewCall(algorithmName)
888888
or
889-
// Due to bad performance when using normal setup with `hashlibNewResult(t2, algorithmName).track(t2, t)`
890-
// we have inlined that code and forced a join
891-
exists(DataFlow::TypeTracker t2 |
892-
exists(DataFlow::StepSummary summary |
893-
hashlibNewResult_first_join(t2, algorithmName, result, summary) and
894-
t = t2.append(summary)
895-
)
896-
)
897-
}
898-
899-
pragma[nomagic]
900-
private predicate hashlibNewResult_first_join(
901-
DataFlow::TypeTracker t2, string algorithmName, DataFlow::Node res, DataFlow::StepSummary summary
902-
) {
903-
DataFlow::StepSummary::step(hashlibNewResult(t2, algorithmName), res, summary)
889+
exists(DataFlow::TypeTracker t2 | result = hashlibNewResult(t2, algorithmName).track(t2, t))
904890
}
905891

906892
/** Gets a reference to the result of calling `hashlib.new` with `algorithmName` as the first argument. */

0 commit comments

Comments
 (0)