mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Avoid certain test sources in models
This commit is contained in:
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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/%")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user