Skip to content

Commit e247d5b

Browse files
committed
Java: Sync files and make dummy language specific implementation.
1 parent e56c185 commit e247d5b

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

java/ql/src/utils/modelgenerator/internal/CaptureModels.qll

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,30 @@ private module Printing implements PrintingSig {
4141

4242
module ModelPrinting = PrintingImpl<Printing>;
4343

44+
/**
45+
* Gets the underlying type of the content `c`.
46+
*/
47+
private Type getUnderlyingContentType(DataFlow::Content c) {
48+
result = getUnderlyingContentTypeSpecific(c) or
49+
result = c.(DataFlow::FieldContent).getField().getType() or
50+
result = c.(DataFlow::SyntheticFieldContent).getField().getType()
51+
}
52+
53+
/**
54+
* Holds if `c` is a relevant content kind, where the underlying type is relevant.
55+
*/
56+
private predicate isRelevantTypeInContent(DataFlow::Content c) {
57+
isRelevantType(getUnderlyingContentType(c))
58+
}
59+
4460
/**
4561
* Holds if data can flow from `node1` to `node2` either via a read or a write of an intermediate field `f`.
4662
*/
4763
private predicate isRelevantTaintStep(DataFlow::Node node1, DataFlow::Node node2) {
4864
exists(DataFlow::Content f |
4965
DataFlowPrivate::readStep(node1, f, node2) and
50-
if f instanceof DataFlow::FieldContent
51-
then isRelevantType(f.(DataFlow::FieldContent).getField().getType())
52-
else
53-
if f instanceof DataFlow::SyntheticFieldContent
54-
then isRelevantType(f.(DataFlow::SyntheticFieldContent).getField().getType())
55-
else any()
66+
// Partially restrict the content types used for intermediate steps.
67+
(not exists(getUnderlyingContentType(f)) or isRelevantTypeInContent(f))
5668
)
5769
or
5870
exists(DataFlow::Content f | DataFlowPrivate::storeStep(node1, f, node2) |
@@ -61,12 +73,11 @@ private predicate isRelevantTaintStep(DataFlow::Node node1, DataFlow::Node node2
6173
}
6274

6375
/**
64-
* Holds if content `c` is either a field or synthetic field of a relevant type
65-
* or a container like content.
76+
* Holds if content `c` is either a field, a synthetic field or language specific
77+
* content of a relevant type or a container like content.
6678
*/
6779
private predicate isRelevantContent(DataFlow::Content c) {
68-
isRelevantType(c.(DataFlow::FieldContent).getField().getType()) or
69-
isRelevantType(c.(DataFlow::SyntheticFieldContent).getField().getType()) or
80+
isRelevantTypeInContent(c) or
7081
DataFlowPrivate::containerContent(c)
7182
}
7283

@@ -258,6 +269,10 @@ module PropagateToSinkConfig implements DataFlow::ConfigSig {
258269
predicate isBarrier(DataFlow::Node node) { sinkModelSanitizer(node) }
259270

260271
DataFlow::FlowFeature getAFeature() { result instanceof DataFlow::FeatureHasSourceCallContext }
272+
273+
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
274+
isRelevantTaintStep(node1, node2)
275+
}
261276
}
262277

263278
private module PropagateToSink = TaintTracking::Global<PropagateToSinkConfig>;

java/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ predicate isRelevantType(J::Type t) {
186186
)
187187
}
188188

189+
J::Type getUnderlyingContentTypeSpecific(DataFlow::Content c) { none() }
190+
189191
/**
190192
* Gets the MaD string representation of the qualifier.
191193
*/

0 commit comments

Comments
 (0)