44 */
55
66private import CaptureModelsSpecific
7+ private import CaptureModelsPrinting
78
89class DataFlowTargetApi extends TargetApiSpecific {
910 DataFlowTargetApi ( ) { isRelevantForDataFlowModels ( this ) }
1011}
1112
13+ private module Printing implements PrintingSig {
14+ class Api = DataFlowTargetApi ;
15+
16+ string getProvenance ( ) { result = "df-generated" }
17+ }
18+
19+ module ModelPrinting = PrintingImpl< Printing > ;
20+
1221/**
1322 * Holds if data can flow from `node1` to `node2` either via a read or a write of an intermediate field `f`.
1423 */
@@ -52,58 +61,6 @@ string parameterNodeAsInput(DataFlow::ParameterNode p) {
5261 */
5362string asInputArgument ( DataFlow:: Node source ) { result = asInputArgumentSpecific ( source ) }
5463
55- /**
56- * Gets the summary model for `api` with `input`, `output` and `kind`.
57- */
58- bindingset [ input, output, kind]
59- private string asSummaryModel ( TargetApiSpecific api , string input , string output , string kind ) {
60- result =
61- asPartialModel ( api ) + input + ";" //
62- + output + ";" //
63- + kind + ";" //
64- + "generated"
65- }
66-
67- string asNeutralModel ( TargetApiSpecific api ) { result = asPartialNeutralModel ( api ) + "generated" }
68-
69- /**
70- * Gets the value summary model for `api` with `input` and `output`.
71- */
72- bindingset [ input, output]
73- string asValueModel ( TargetApiSpecific api , string input , string output ) {
74- result = asSummaryModel ( api , input , output , "value" )
75- }
76-
77- /**
78- * Gets the taint summary model for `api` with `input` and `output`.
79- */
80- bindingset [ input, output]
81- private string asTaintModel ( TargetApiSpecific api , string input , string output ) {
82- result = asSummaryModel ( api , input , output , "taint" )
83- }
84-
85- /**
86- * Gets the sink model for `api` with `input` and `kind`.
87- */
88- bindingset [ input, kind]
89- private string asSinkModel ( TargetApiSpecific api , string input , string kind ) {
90- result =
91- asPartialModel ( api ) + input + ";" //
92- + kind + ";" //
93- + "generated"
94- }
95-
96- /**
97- * Gets the source model for `api` with `output` and `kind`.
98- */
99- bindingset [ output, kind]
100- private string asSourceModel ( TargetApiSpecific api , string output , string kind ) {
101- result =
102- asPartialModel ( api ) + output + ";" //
103- + kind + ";" //
104- + "generated"
105- }
106-
10764/**
10865 * Gets the summary model of `api`, if it follows the `fluent` programming pattern (returns `this`).
10966 */
@@ -112,7 +69,7 @@ string captureQualifierFlow(TargetApiSpecific api) {
11269 api = returnNodeEnclosingCallable ( ret ) and
11370 isOwnInstanceAccessNode ( ret )
11471 ) and
115- result = asValueModel ( api , qualifierString ( ) , "ReturnValue" )
72+ result = ModelPrinting :: asValueModel ( api , qualifierString ( ) , "ReturnValue" )
11673}
11774
11875private int accessPathLimit ( ) { result = 2 }
@@ -225,7 +182,7 @@ string captureThroughFlow(DataFlowTargetApi api) {
225182 input = parameterNodeAsInput ( p ) and
226183 output = returnNodeAsOutput ( returnNodeExt ) and
227184 input != output and
228- result = asTaintModel ( api , input , output )
185+ result = ModelPrinting :: asTaintModel ( api , input , output )
229186 )
230187}
231188
@@ -264,7 +221,7 @@ string captureSource(DataFlowTargetApi api) {
264221 ExternalFlow:: sourceNode ( source , kind ) and
265222 api = sink .getEnclosingCallable ( ) and
266223 isRelevantSourceKind ( kind ) and
267- result = asSourceModel ( api , returnNodeAsOutput ( sink ) , kind )
224+ result = ModelPrinting :: asSourceModel ( api , returnNodeAsOutput ( sink ) , kind )
268225 )
269226}
270227
@@ -296,6 +253,6 @@ string captureSink(DataFlowTargetApi api) {
296253 ExternalFlow:: sinkNode ( sink , kind ) and
297254 api = src .getEnclosingCallable ( ) and
298255 isRelevantSinkKind ( kind ) and
299- result = asSinkModel ( api , asInputArgument ( src ) , kind )
256+ result = ModelPrinting :: asSinkModel ( api , asInputArgument ( src ) , kind )
300257 )
301258}
0 commit comments