@@ -41,18 +41,30 @@ private module Printing implements PrintingSig {
41
41
42
42
module ModelPrinting = PrintingImpl< Printing > ;
43
43
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
+
44
60
/**
45
61
* Holds if data can flow from `node1` to `node2` either via a read or a write of an intermediate field `f`.
46
62
*/
47
63
private predicate isRelevantTaintStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
48
64
exists ( DataFlow:: Content f |
49
65
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 ) )
56
68
)
57
69
or
58
70
exists ( DataFlow:: Content f | DataFlowPrivate:: storeStep ( node1 , f , node2 ) |
@@ -61,12 +73,11 @@ private predicate isRelevantTaintStep(DataFlow::Node node1, DataFlow::Node node2
61
73
}
62
74
63
75
/**
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.
66
78
*/
67
79
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
70
81
DataFlowPrivate:: containerContent ( c )
71
82
}
72
83
@@ -258,6 +269,10 @@ module PropagateToSinkConfig implements DataFlow::ConfigSig {
258
269
predicate isBarrier ( DataFlow:: Node node ) { sinkModelSanitizer ( node ) }
259
270
260
271
DataFlow:: FlowFeature getAFeature ( ) { result instanceof DataFlow:: FeatureHasSourceCallContext }
272
+
273
+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
274
+ isRelevantTaintStep ( node1 , node2 )
275
+ }
261
276
}
262
277
263
278
private module PropagateToSink = TaintTracking:: Global< PropagateToSinkConfig > ;
0 commit comments