1+ /**
2+ * @name Capture source models.
3+ * @description Finds APIs that act as sources as they expose already known sources.
4+ * @id java/utils/model-generator/sink-models
5+ */
6+
17import java
2- import Telemetry.ExternalAPI
3- import semmle.code.java.dataflow.DataFlow
4- import semmle.code.java.dataflow.TaintTracking
5- import semmle.code.java.dataflow.ExternalFlow
6- import ModelGeneratorUtils
8+ private import Telemetry.ExternalAPI
9+ private import semmle.code.java.dataflow.DataFlow
10+ private import semmle.code.java.dataflow.TaintTracking
11+ private import semmle.code.java.dataflow.ExternalFlow
12+ private import ModelGeneratorUtils
713private import semmle.code.java.dataflow.internal.FlowSummaryImplSpecific
814private import semmle.code.java.dataflow.internal.FlowSummaryImpl
915
10- class Configuration extends TaintTracking:: Configuration {
11- Configuration ( ) { this = "Configuration " }
16+ class FromSourceConfiguration extends TaintTracking:: Configuration {
17+ FromSourceConfiguration ( ) { this = "FromSourceConfiguration " }
1218
1319 override predicate isSource ( DataFlow:: Node source ) { sourceNode ( source , _) }
1420
@@ -21,14 +27,17 @@ class Configuration extends TaintTracking::Configuration {
2127 }
2228}
2329
24- // TODO: internals
30+ // TODO: better way than rely on internals?
2531cached
2632predicate specificSourceNode ( DataFlow:: Node node , string output , string kind ) {
2733 exists ( InterpretNode n | Private:: External:: isSourceNode ( n , output , kind ) and n .asNode ( ) = node )
2834}
2935
3036string captureSink ( Callable api ) {
31- exists ( DataFlow:: Node src , DataFlow:: Node sink , Configuration config , string kind , string output |
37+ exists (
38+ DataFlow:: Node src , DataFlow:: Node sink , FromSourceConfiguration config , string kind ,
39+ string output
40+ |
3241 config .hasFlow ( src , sink ) and
3342 specificSourceNode ( sink , output , kind ) and
3443 api = src .asExpr ( ) .getEnclosingCallable ( ) and
0 commit comments