Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 060862a

Browse files
author
Benjamin Muskalla
committed
Avoid certain test sources in models
1 parent e607953 commit 060862a

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

java/ql/src/utils/model-generator/CaptureSinkModels.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import semmle.code.java.dataflow.ExternalFlow
1212
import ModelGeneratorUtils
1313

1414
class PropagateToSinkConfiguration extends TaintTracking::Configuration {
15-
PropagateToSinkConfiguration() { this = "public methods calling sinks" }
15+
PropagateToSinkConfiguration() { this = "parameters on public api flowing into sinks" }
1616

1717
override predicate isSource(DataFlow::Node source) {
18-
source.asParameter().getCallable().isPublic()
18+
source instanceof DataFlow::ParameterNode and source.asParameter().getCallable().isPublic() and source.asParameter().getCallable().getDeclaringType().isPublic()
1919
}
2020

2121
override predicate isSink(DataFlow::Node sink) { sinkNode(sink, _) }
@@ -29,7 +29,7 @@ string captureSink(Callable api) {
2929
exists(DataFlow::Node src, DataFlow::Node sink, PropagateToSinkConfiguration config, string kind |
3030
config.hasFlow(src, sink) and
3131
sinkNode(sink, kind) and
32-
api = src.asParameter().getCallable() and
32+
api = src.getEnclosingCallable() and
3333
result = asSinkModel(api, asInputArgument(src), kind)
3434
)
3535
}

java/ql/src/utils/model-generator/ModelGeneratorUtils.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ string parameterAccess(Parameter p) {
6060

6161
predicate isInTestFile(Callable api) {
6262
api.getCompilationUnit().getFile().getAbsolutePath().matches("%src/test/%") or
63-
api.getCompilationUnit().getFile().getAbsolutePath().matches("%src/guava-tests/%")
63+
api.getCompilationUnit().getFile().getAbsolutePath().matches("%/guava-tests/%") or
64+
api.getCompilationUnit().getFile().getAbsolutePath().matches("%/guava-testlib/%")
6465
}

0 commit comments

Comments
 (0)