Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ruby/ql/consistency-queries/DataFlowConsistency.ql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import codeql.ruby.AST
import codeql.ruby.DataFlow::DataFlow
import codeql.ruby.dataflow.internal.DataFlowPrivate
import codeql.ruby.dataflow.internal.DataFlowImplConsistency::Consistency
Expand All @@ -11,5 +12,7 @@ private class MyConsistencyConfiguration extends ConsistencyConfiguration {
n instanceof SummaryNode
or
n instanceof SynthHashSplatArgumentNode
or
not isNonConstantExpr(n.asExpr())
}
}
9 changes: 1 addition & 8 deletions ruby/ql/lib/codeql/ruby/ast/internal/Module.qll
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,7 @@ private module Cached {
}

cached
Method lookupMethod(Module m, string name) {
// The syntax_suggest library redefines Kernel.require/require_relative.
// Somehow this causes performance issues on ruby/ruby. As a workaround
// we exclude 'require' and 'require_relative'.
// TODO: find the actual cause of the slowdown and fix things properly.
not name = ["require", "require_relative"] and
TMethod(result) = lookupMethodOrConst(m, name)
}
Method lookupMethod(Module m, string name) { TMethod(result) = lookupMethodOrConst(m, name) }

cached
Expr lookupConst(Module m, string name) {
Expand Down
10 changes: 6 additions & 4 deletions ruby/ql/lib/codeql/ruby/controlflow/BasicBlocks.qll
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ private module Cached {
}

cached
predicate immediatelyControls(ConditionBlock cb, BasicBlock succ, BooleanSuccessor s) {
predicate immediatelyControls(ConditionBlock cb, BasicBlock succ, ConditionalSuccessor s) {
succ = cb.getASuccessor(s) and
forall(BasicBlock pred | pred = succ.getAPredecessor() and pred != cb | succ.dominates(pred))
}

cached
predicate controls(ConditionBlock cb, BasicBlock controlled, BooleanSuccessor s) {
predicate controls(ConditionBlock cb, BasicBlock controlled, ConditionalSuccessor s) {
exists(BasicBlock succ | cb.immediatelyControls(succ, s) | succ.dominates(controlled))
}
}
Expand Down Expand Up @@ -406,7 +406,7 @@ class ConditionBlock extends BasicBlock {
* successor of this block, and `succ` can only be reached from
* the callable entry point by going via the `s` edge out of this basic block.
*/
predicate immediatelyControls(BasicBlock succ, BooleanSuccessor s) {
predicate immediatelyControls(BasicBlock succ, ConditionalSuccessor s) {
immediatelyControls(this, succ, s)
}

Expand All @@ -415,5 +415,7 @@ class ConditionBlock extends BasicBlock {
* conditional value `s`. That is, `controlled` can only be reached from
* the callable entry point by going via the `s` edge out of this basic block.
*/
predicate controls(BasicBlock controlled, BooleanSuccessor s) { controls(this, controlled, s) }
predicate controls(BasicBlock controlled, ConditionalSuccessor s) {
controls(this, controlled, s)
}
}
5 changes: 4 additions & 1 deletion ruby/ql/lib/codeql/ruby/controlflow/CfgNodes.qll
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ module ExprNodes {
}

private class WhenClauseChildMapping extends NonExprChildMapping, WhenClause {
override predicate relevantChild(AstNode e) { e = this.getBody() }
override predicate relevantChild(AstNode e) { e = [this.getBody(), this.getAPattern()] }
}

/** A control-flow node that wraps a `WhenClause` AST expression. */
Expand All @@ -444,6 +444,9 @@ module ExprNodes {

/** Gets the body of this `when`-clause. */
final ExprCfgNode getBody() { e.hasCfgChild(e.getBody(), this, result) }

/** Gets the `i`th pattern this `when`-clause. */
final ExprCfgNode getPattern(int i) { e.hasCfgChild(e.getPattern(i), this, result) }
}

/** A control-flow node that wraps a `CasePattern`. */
Expand Down
2 changes: 1 addition & 1 deletion ruby/ql/lib/codeql/ruby/controlflow/ControlFlowGraph.qll
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CfgNode extends TCfgNode {
final File getFile() { result = this.getLocation().getFile() }

/** Holds if this control flow node has conditional successors. */
final predicate isCondition() { exists(this.getASuccessor(any(BooleanSuccessor bs))) }
final predicate isCondition() { exists(this.getASuccessor(any(ConditionalSuccessor bs))) }

/** Gets the scope of this node. */
final CfgScope getScope() { result = getNodeCfgScope(this) }
Expand Down
Loading