Skip to content

Commit 2748bbf

Browse files
author
Benjamin Muskalla
authored
Merge pull request github#7656 from bmuskalla/excludeMainLoggingGenerator
Java: Exclude irrelevant rows from models
2 parents 547f492 + 52406dc commit 2748bbf

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ string captureSink(TargetAPI api) {
4848
config.hasFlow(src, sink) and
4949
sinkNode(sink, kind) and
5050
api = src.getEnclosingCallable() and
51+
not kind = "logging" and
5152
result = asSinkModel(api, asInputArgument(src), kind)
5253
)
5354
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ private string isExtensible(RefType ref) {
2929

3030
predicate isRelevantForModels(Callable api) {
3131
not isInTestFile(api.getCompilationUnit().getFile()) and
32-
not isJdkInternal(api.getCompilationUnit())
32+
not isJdkInternal(api.getCompilationUnit()) and
33+
not api instanceof MainMethod
3334
}
3435

3536
private predicate isInTestFile(File file) {

java/ql/test/utils/model-generator/p/Sinks.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.nio.charset.Charset;
88
import java.nio.file.Files;
99
import java.nio.file.Path;
10+
import java.util.logging.Logger;
1011

1112
public class Sinks {
1213

@@ -21,4 +22,13 @@ public String readUrl(final URL url, Charset encoding) throws IOException {
2122
}
2223
}
2324

25+
public static void main(String[] args) throws IOException {
26+
String foo = new Sinks().readUrl(new URL(args[0]), Charset.defaultCharset());
27+
}
28+
29+
public void propagate(String s) {
30+
Logger logger = Logger.getLogger(Sinks.class.getSimpleName());
31+
logger.warning(s);
32+
}
33+
2434
}

0 commit comments

Comments
 (0)