Skip to content

Commit 46627a7

Browse files
committed
add an AdditionalTaintStep class for Ruby
1 parent 71135da commit 46627a7

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Provides classes representing various flow steps for taint tracking.
3+
*/
4+
5+
private import codeql.ruby.DataFlow
6+
private import internal.DataFlowPrivate as DFPrivate
7+
8+
private class Unit = DFPrivate::Unit;
9+
10+
/**
11+
* A module importing the frameworks that implement additional flow steps,
12+
* ensuring that they are visible to the taint tracking library.
13+
*/
14+
private module Frameworks { }
15+
16+
/**
17+
* A unit class for adding additional taint steps.
18+
*
19+
* Extend this class to add additional taint steps that should apply to all
20+
* taint configurations.
21+
*/
22+
class AdditionalTaintStep extends Unit {
23+
/**
24+
* Holds if the step from `node1` to `node2` should be considered a taint
25+
* step for all configurations.
26+
*/
27+
abstract predicate step(DataFlow::Node node1, DataFlow::Node node2);
28+
}

ruby/ql/lib/codeql/ruby/dataflow/internal/TaintTrackingPrivate.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ private CfgNodes::ExprNodes::VariableWriteAccessCfgNode variablesInPattern(
6262

6363
cached
6464
private module Cached {
65+
private import codeql.ruby.dataflow.FlowSteps as FlowSteps
66+
6567
cached
6668
predicate forceCachingInSameStage() { any() }
6769

@@ -99,6 +101,8 @@ private module Cached {
99101
or
100102
FlowSummaryImpl::Private::Steps::summaryLocalStep(nodeFrom, nodeTo, false)
101103
or
104+
any(FlowSteps::AdditionalTaintStep s).step(nodeFrom, nodeTo)
105+
or
102106
// Although flow through collections is modeled precisely using stores/reads, we still
103107
// allow flow out of a _tainted_ collection. This is needed in order to support taint-
104108
// tracking configurations where the source is a collection.

0 commit comments

Comments
 (0)