Skip to content

Commit 6d893d4

Browse files
author
Max Schaefer
committed
JavaScript: Allow additional sources, sinks and steps to specify flow labels.
1 parent 98a763a commit 6d893d4

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

javascript/ql/src/semmle/javascript/dataflow/Configuration.qll

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,19 @@ abstract class AdditionalFlowStep extends DataFlow::Node {
324324
* Holds if `pred` → `succ` should be considered a data flow edge.
325325
*/
326326
cached
327-
abstract predicate step(DataFlow::Node pred, DataFlow::Node succ);
327+
predicate step(DataFlow::Node pred, DataFlow::Node succ) { none() }
328+
329+
/**
330+
* Holds if `pred` → `succ` should be considered a data flow edge
331+
* transforming values with label `predlbl` to have label `succlbl`.
332+
*/
333+
cached
334+
predicate step(
335+
DataFlow::Node pred, DataFlow::Node succ, DataFlow::FlowLabel predlbl,
336+
DataFlow::FlowLabel succlbl
337+
) {
338+
none()
339+
}
328340
}
329341

330342
/**
@@ -336,7 +348,13 @@ abstract class AdditionalSource extends DataFlow::Node {
336348
* Holds if this data flow node should be considered a source node for
337349
* configuration `cfg`.
338350
*/
339-
abstract predicate isSourceFor(Configuration cfg);
351+
predicate isSourceFor(Configuration cfg) { none() }
352+
353+
/**
354+
* Holds if this data flow node should be considered a source node for
355+
* values labeled with `lbl` under configuration `cfg`.
356+
*/
357+
predicate isSourceFor(Configuration cfg, FlowLabel lbl) { none() }
340358
}
341359

342360
/**
@@ -348,7 +366,13 @@ abstract class AdditionalSink extends DataFlow::Node {
348366
* Holds if this data flow node should be considered a sink node for
349367
* configuration `cfg`.
350368
*/
351-
abstract predicate isSinkFor(Configuration cfg);
369+
predicate isSinkFor(Configuration cfg) { none() }
370+
371+
/**
372+
* Holds if this data flow node should be considered a sink node for
373+
* values labeled with `lbl` under configuration `cfg`.
374+
*/
375+
predicate isSinkFor(Configuration cfg, FlowLabel lbl) { none() }
352376
}
353377

354378
/**
@@ -476,6 +500,8 @@ private predicate isSource(DataFlow::Node nd, DataFlow::Configuration cfg, FlowL
476500
(cfg.isSource(nd) or nd.(AdditionalSource).isSourceFor(cfg)) and
477501
lbl = FlowLabel::data()
478502
or
503+
nd.(AdditionalSource).isSourceFor(cfg, lbl)
504+
or
479505
cfg.isSource(nd, lbl)
480506
}
481507

@@ -486,6 +512,8 @@ private predicate isSink(DataFlow::Node nd, DataFlow::Configuration cfg, FlowLab
486512
(cfg.isSink(nd) or nd.(AdditionalSink).isSinkFor(cfg)) and
487513
lbl = any(StandardFlowLabel f)
488514
or
515+
nd.(AdditionalSink).isSinkFor(cfg, lbl)
516+
or
489517
cfg.isSink(nd, lbl)
490518
}
491519

javascript/ql/src/semmle/javascript/dataflow/internal/FlowSteps.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ predicate localFlowStep(
7575
or
7676
any(DataFlow::AdditionalFlowStep afs).step(pred, succ) and predlbl = succlbl
7777
or
78+
any(DataFlow::AdditionalFlowStep afs).step(pred, succ, predlbl, succlbl)
79+
or
7880
exists(boolean vp | configuration.isAdditionalFlowStep(pred, succ, vp) |
7981
vp = true and
8082
predlbl = succlbl

0 commit comments

Comments
 (0)