Skip to content

Commit 2bc7d4e

Browse files
committed
Ruby: Clean up
1 parent 7a01c4a commit 2bc7d4e

File tree

1 file changed

+26
-48
lines changed
  • ruby/ql/lib/codeql/ruby/frameworks/actioncontroller

1 file changed

+26
-48
lines changed

ruby/ql/lib/codeql/ruby/frameworks/actioncontroller/Filters.qll

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,7 @@ module Filters {
397397
/**
398398
* Holds if `n` is a post-update node for `self` in method `m`.
399399
*/
400-
predicate selfPostUpdate(DataFlow::PostUpdateNode n, Method m) {
401-
n.getPreUpdateNode().asExpr() instanceof SelfVariableAccessCfgNode and
400+
private predicate selfPostUpdate(DataFlow::PostUpdateNode n, Method m) {
402401
m = n.getPreUpdateNode().asExpr().getExpr().getEnclosingCallable() and
403402
n.getPreUpdateNode()
404403
.asExpr()
@@ -408,24 +407,6 @@ module Filters {
408407
.getDeclaringScope() = m
409408
}
410409

411-
/**
412-
* Holds if `n` is the syntactically last dataflow node in `m` that satisfies `selfPostUpdate`.
413-
* In the example below, `n` is the post-update node for `bar`.
414-
* ```rb
415-
* def m
416-
* foo
417-
* bar
418-
* end
419-
* ```
420-
*/
421-
predicate lastSelfPostUpdate(DataFlow::PostUpdateNode n, Method m) {
422-
selfPostUpdate(n, m) and
423-
not exists(DataFlow::PostUpdateNode n2 |
424-
selfPostUpdate(n2, m) and
425-
n.getPreUpdateNode().asExpr().getASuccessor+() = n2.getPreUpdateNode().asExpr()
426-
)
427-
}
428-
429410
/**
430411
* Holds if `n` is the self parameter of method `m`.
431412
*/
@@ -444,34 +425,31 @@ module Filters {
444425
* part of the callback chain.
445426
*/
446427
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
447-
exists(Method predMethod, Method succMethod |
448-
next(predMethod, succMethod) and
449-
(
450-
// Flow from a post-update node of self in `pred` to the self parameter of `succ`
451-
//
452-
// def a
453-
// foo() ---------+
454-
// @x = 1 ---+ |
455-
// end | |
456-
// | |
457-
// def b <----+----+
458-
// ...
459-
//
460-
selfPostUpdate(pred, predMethod) and
461-
selfParameter(succ, succMethod)
462-
or
463-
// Flow from the self parameter of `pred` to the self parameter of `succ`
464-
//
465-
// def a ---+
466-
// ... |
467-
// end |
468-
// |
469-
// def b <-+
470-
// ...
471-
//
472-
selfParameter(pred, predMethod) and
473-
selfParameter(succ, succMethod)
474-
)
428+
exists(Method predMethod, Method succMethod | next(predMethod, succMethod) |
429+
// Flow from a post-update node of self in `pred` to the self parameter of `succ`
430+
//
431+
// def a
432+
// foo() ---------+
433+
// @x = 1 ---+ |
434+
// end | |
435+
// | |
436+
// def b <----+----+
437+
// ...
438+
//
439+
selfPostUpdate(pred, predMethod) and
440+
selfParameter(succ, succMethod)
441+
or
442+
// Flow from the self parameter of `pred` to the self parameter of `succ`
443+
//
444+
// def a ---+
445+
// ... |
446+
// end |
447+
// |
448+
// def b <-+
449+
// ...
450+
//
451+
selfParameter(pred, predMethod) and
452+
selfParameter(succ, succMethod)
475453
)
476454
}
477455
}

0 commit comments

Comments
 (0)