Skip to content

Commit 3112964

Browse files
committed
Minor improvements to ImproperMemoizationQuery
1 parent ff0422c commit 3112964

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ruby/ql/lib/codeql/ruby/security/ImproperMemoizationQuery.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ private class HashMemoStmt extends MemoStmt {
4141
* A method that may be performing memoization.
4242
*/
4343
private class MemoCandidate extends Method {
44-
MemoCandidate() { exists(MemoStmt m | m.getEnclosingMethod() = this) }
44+
MemoCandidate() { this = any(MemoStmt m).getEnclosingMethod() }
4545
}
4646

4747
/**
4848
* Holds if parameter `p` of `m` is read in the right hand side of `assign`.
4949
*/
5050
private predicate parameterUsedInMemoValue(Method m, Parameter p, MemoStmt a) {
5151
p = m.getAParameter() and
52-
a.getParent+() = m and
52+
a.getEnclosingMethod() = m and
5353
p.getAVariable().getAnAccess().getParent*() = a.getRightOperand()
5454
}
5555

@@ -58,7 +58,7 @@ private predicate parameterUsedInMemoValue(Method m, Parameter p, MemoStmt a) {
5858
*/
5959
private predicate parameterUsedInMemoKey(Method m, Parameter p, HashMemoStmt a) {
6060
p = m.getAParameter() and
61-
a.getParent+() = m and
61+
a.getEnclosingMethod() = m and
6262
p.getAVariable().getAnAccess().getParent+() = a.getLeftOperand()
6363
}
6464

0 commit comments

Comments
 (0)