Skip to content

Commit f1634d3

Browse files
committed
Dataflow: Add support for C#/Python/Ruby/Swift.
1 parent 69bf13b commit f1634d3

File tree

8 files changed

+24
-1
lines changed

8 files changed

+24
-1
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,8 @@ predicate jumpStep(Node pred, Node succ) {
15811581
jrk.getTarget() = call.getATarget(_) and
15821582
succ = getAnOutNode(call, jrk.getTargetReturnKind())
15831583
)
1584+
or
1585+
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred, succ)
15841586
}
15851587

15861588
private class StoreStepConfiguration extends ControlFlowReachabilityConfiguration {

csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ DataFlowType getCallbackReturnType(DataFlowType t, ReturnKind rk) {
9191
)
9292
}
9393

94+
/** Gets the type of synthetic global `sg`. */
95+
DataFlowType getSyntheticGlobalType(SummaryComponent::SyntheticGlobal sg) {
96+
exists(sg) and
97+
result = Gvn::getGlobalValueNumber(any(ObjectType t))
98+
}
99+
94100
bindingset[provenance]
95101
private boolean isGenerated(string provenance) {
96102
provenance = "generated" and result = true

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,8 @@ predicate jumpStep(Node nodeFrom, Node nodeTo) {
453453
jumpStepSharedWithTypeTracker(nodeFrom, nodeTo)
454454
or
455455
jumpStepNotSharedWithTypeTracker(nodeFrom, nodeTo)
456+
or
457+
FlowSummaryImpl::Private::Steps::summaryJumpStep(nodeFrom, nodeTo)
456458
}
457459

458460
/**

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImplSpecific.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ DataFlowType getCallbackParameterType(DataFlowType t, int i) { any() }
7373
*/
7474
DataFlowType getCallbackReturnType(DataFlowType t, ReturnKind rk) { any() }
7575

76+
/** Gets the type of synthetic global `sg`. */
77+
DataFlowType getSyntheticGlobalType(SummaryComponent::SyntheticGlobal sg) { any() }
78+
7679
/**
7780
* Holds if an external flow summary exists for `c` with input specification
7881
* `input`, output specification `output`, kind `kind`, and a flag `generated`

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,8 @@ predicate jumpStep(Node pred, Node succ) {
10031003
succ.(SsaDefinitionNode).getDefinition())
10041004
or
10051005
succ.asExpr().getExpr().(ConstantReadAccess).getValue() = pred.asExpr().getExpr()
1006+
or
1007+
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred, succ)
10061008
}
10071009

10081010
private ContentSet getKeywordContent(string name) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ DataFlowType getCallbackParameterType(DataFlowType t, ArgumentPosition pos) { an
4444
*/
4545
DataFlowType getCallbackReturnType(DataFlowType t, ReturnKind rk) { any() }
4646

47+
/** Gets the type of synthetic global `sg`. */
48+
DataFlowType getSyntheticGlobalType(SummaryComponent::SyntheticGlobal sg) { any() }
49+
4750
/**
4851
* Holds if an external flow summary exists for `c` with input specification
4952
* `input`, output specification `output`, kind `kind`, and a flag `generated`

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,9 @@ private module OutNodes {
486486

487487
import OutNodes
488488

489-
predicate jumpStep(Node pred, Node succ) { none() }
489+
predicate jumpStep(Node pred, Node succ) {
490+
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred, succ)
491+
}
490492

491493
predicate storeStep(Node node1, ContentSet c, Node node2) {
492494
exists(MemberRefExpr ref, AssignExpr assign |

swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ DataFlowType getCallbackReturnType(DataFlowType t, ReturnKind rk) {
5151
any() // TODO once we have type pruning
5252
}
5353

54+
/** Gets the type of synthetic global `sg`. */
55+
DataFlowType getSyntheticGlobalType(SummaryComponent::SyntheticGlobal sg) { any() }
56+
5457
/**
5558
* Holds if an external flow summary exists for `c` with input specification
5659
* `input`, output specification `output`, kind `kind`, and a flag `generated`

0 commit comments

Comments
 (0)