From bb97df1d717de826fdad8827d6ddccc9f99c262c Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Fri, 1 Mar 2024 12:11:40 +0000 Subject: [PATCH] do not generate models for lambda flow methods --- .../java/dataflow/internal/ModelExclusions.qll | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/java/ql/lib/semmle/code/java/dataflow/internal/ModelExclusions.qll b/java/ql/lib/semmle/code/java/dataflow/internal/ModelExclusions.qll index 22a37275244..d1a6e47ecca 100644 --- a/java/ql/lib/semmle/code/java/dataflow/internal/ModelExclusions.qll +++ b/java/ql/lib/semmle/code/java/dataflow/internal/ModelExclusions.qll @@ -59,12 +59,26 @@ private predicate isInternal(CompilationUnit cu) { cu.getPackage().getName().matches("%internal%") } +/** A method relating to lambda flow. */ +private class LambdaFlowMethod extends Method { + LambdaFlowMethod() { + this.hasQualifiedName("java.lang", "Runnable", "run") or + this.hasQualifiedName("java.util", "Comparator", "comparing") or + this.hasQualifiedName("java.util.function", "BiConsumer", "accept") or + this.hasQualifiedName("java.util.function", "BiFunction", "apply") or + this.hasQualifiedName("java.util.function", "Consumer", "accept") or + this.hasQualifiedName("java.util.function", "Function", "apply") or + this.hasQualifiedName("java.util.function", "Supplier", "get") + } +} + /** Holds if the given callable is not worth modeling. */ predicate isUninterestingForModels(Callable c) { isInTestFile(c.getCompilationUnit().getFile()) or isInternal(c.getCompilationUnit()) or c instanceof MainMethod or c instanceof ToStringMethod or + c instanceof LambdaFlowMethod or c instanceof StaticInitializer or exists(FunctionalExpr funcExpr | c = funcExpr.asMethod()) or c.getDeclaringType() instanceof TestLibrary or