@@ -3,6 +3,8 @@ private import rust
3
3
private import rust as R
4
4
private import codeql.rust.dataflow.DataFlow
5
5
private import codeql.rust.dataflow.internal.DataFlowImpl
6
+ private import codeql.rust.dataflow.FlowSource as FlowSource
7
+ private import codeql.rust.dataflow.FlowSink as FlowSink
6
8
private import codeql.rust.dataflow.internal.TaintTrackingImpl
7
9
private import codeql.mad.modelgenerator.internal.ModelGeneratorImpl
8
10
private import codeql.rust.dataflow.internal.FlowSummaryImpl as FlowSummary
@@ -105,14 +107,19 @@ module ModelGeneratorInput implements ModelGeneratorInputSig<Location, RustDataF
105
107
106
108
predicate sinkModelSanitizer ( DataFlow:: Node node ) { none ( ) }
107
109
108
- predicate apiSource ( DataFlow:: Node source ) { none ( ) }
110
+ /**
111
+ * Holds if `source` is an API entrypoint, i.e., a source of input where data
112
+ * can flow in to a library. This is used for creating sink models, as we
113
+ * only want to mark functions as sinks if input to the function can reach
114
+ * (from an input source) a known sink.
115
+ */
116
+ predicate apiSource ( DataFlow:: Node source ) { source instanceof DataFlow:: ParameterNode }
109
117
110
118
bindingset [ sourceEnclosing, api]
111
119
predicate irrelevantSourceSinkApi ( Callable sourceEnclosing , SourceTargetApi api ) { none ( ) }
112
120
113
121
string getInputArgument ( DataFlow:: Node source ) {
114
- // TODO: Implement when we want to generate sources and sinks
115
- result = "getInputArgument(" + source + ")"
122
+ result = "Argument[" + source .( Node:: SourceParameterNode ) .getPosition ( ) .toString ( ) + "]"
116
123
}
117
124
118
125
bindingset [ kind]
@@ -174,11 +181,9 @@ module ModelGeneratorInput implements ModelGeneratorInputSig<Location, RustDataF
174
181
175
182
string partialNeutralModelRow ( Callable api , int i ) { result = partialModelRow ( api , i ) }
176
183
177
- // TODO: Implement this when we want to generate sources.
178
- predicate sourceNode ( DataFlow:: Node node , string kind ) { none ( ) }
184
+ predicate sourceNode ( DataFlow:: Node node , string kind ) { FlowSource:: sourceNode ( node , kind ) }
179
185
180
- // TODO: Implement this when we want to generate sinks.
181
- predicate sinkNode ( DataFlow:: Node node , string kind ) { none ( ) }
186
+ predicate sinkNode ( DataFlow:: Node node , string kind ) { FlowSink:: sinkNode ( node , kind ) }
182
187
}
183
188
184
189
import MakeModelGenerator< Location , RustDataFlow , RustTaintTracking , ModelGeneratorInput >
0 commit comments