Avoid certain test sources in models

This commit is contained in:
Benjamin Muskalla
2021-10-06 11:18:34 +02:00
parent e607953b9c
commit 060862ab3b
2 changed files with 5 additions and 4 deletions

View File

@@ -12,10 +12,10 @@ import semmle.code.java.dataflow.ExternalFlow
import ModelGeneratorUtils
class PropagateToSinkConfiguration extends TaintTracking::Configuration {
PropagateToSinkConfiguration() { this = "public methods calling sinks" }
PropagateToSinkConfiguration() { this = "parameters on public api flowing into sinks" }
override predicate isSource(DataFlow::Node source) {
source.asParameter().getCallable().isPublic()
source instanceof DataFlow::ParameterNode and source.asParameter().getCallable().isPublic() and source.asParameter().getCallable().getDeclaringType().isPublic()
}
override predicate isSink(DataFlow::Node sink) { sinkNode(sink, _) }
@@ -29,7 +29,7 @@ string captureSink(Callable api) {
exists(DataFlow::Node src, DataFlow::Node sink, PropagateToSinkConfiguration config, string kind |
config.hasFlow(src, sink) and
sinkNode(sink, kind) and
api = src.asParameter().getCallable() and
api = src.getEnclosingCallable() and
result = asSinkModel(api, asInputArgument(src), kind)
)
}

View File

@@ -60,5 +60,6 @@ string parameterAccess(Parameter p) {
predicate isInTestFile(Callable api) {
api.getCompilationUnit().getFile().getAbsolutePath().matches("%src/test/%") or
api.getCompilationUnit().getFile().getAbsolutePath().matches("%src/guava-tests/%")
api.getCompilationUnit().getFile().getAbsolutePath().matches("%/guava-tests/%") or
api.getCompilationUnit().getFile().getAbsolutePath().matches("%/guava-testlib/%")
}