From dcc55727671836eea209ffc264a1fee3d59fa02b Mon Sep 17 00:00:00 2001 From: Alex Eyers-Taylor Date: Wed, 10 Sep 2025 14:41:31 +0100 Subject: [PATCH] Java: Hnalde global files as exceptions rather than annotating them This allows us to merge them without redundent annoations for now. --- config/add-overlay-annotations.py | 9 +++++++++ java/ql/lib/semmle/code/java/dispatch/DispatchFlow.qll | 2 -- java/ql/lib/semmle/code/java/dispatch/ObjFlow.qll | 2 -- .../ql/lib/semmle/code/java/dispatch/VirtualDispatch.qll | 2 -- .../semmle/code/java/dispatch/internal/Unification.qll | 2 -- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config/add-overlay-annotations.py b/config/add-overlay-annotations.py index 85b42026d8d..0a30eee5799 100644 --- a/config/add-overlay-annotations.py +++ b/config/add-overlay-annotations.py @@ -177,6 +177,12 @@ def insert_overlay_caller_annotations(lines): out_lines.append(line) return out_lines +explicitly_global = set([ + "java/ql/lib/semmle/code/java/dispatch/VirtualDispatch.qll", + "java/ql/lib/semmle/code/java/dispatch/DispatchFlow.qll", + "java/ql/lib/semmle/code/java/dispatch/ObjFlow.qll", + "java/ql/lib/semmle/code/java/dispatch/internal/Unification.qll", +]) def annotate_as_appropriate(filename, lines): ''' @@ -196,6 +202,9 @@ def annotate_as_appropriate(filename, lines): ((filename.endswith("Query.qll") or filename.endswith("Config.qll")) and any("implements DataFlow::ConfigSig" in line for line in lines))): return None + elif filename in explicitly_global: + # These files are explicitly global and should not be annotated. + return None elif not any(line for line in lines if line.strip()): return None diff --git a/java/ql/lib/semmle/code/java/dispatch/DispatchFlow.qll b/java/ql/lib/semmle/code/java/dispatch/DispatchFlow.qll index 16b46762524..bd293eed6b3 100644 --- a/java/ql/lib/semmle/code/java/dispatch/DispatchFlow.qll +++ b/java/ql/lib/semmle/code/java/dispatch/DispatchFlow.qll @@ -5,8 +5,6 @@ * data flow check for lambdas, anonymous classes, and other sufficiently * private classes where all object instantiations are accounted for. */ -overlay[global] -module; import java private import VirtualDispatch diff --git a/java/ql/lib/semmle/code/java/dispatch/ObjFlow.qll b/java/ql/lib/semmle/code/java/dispatch/ObjFlow.qll index 0fcd5cb2876..a3da9118acc 100644 --- a/java/ql/lib/semmle/code/java/dispatch/ObjFlow.qll +++ b/java/ql/lib/semmle/code/java/dispatch/ObjFlow.qll @@ -6,8 +6,6 @@ * The set of dispatch targets for `Object.toString()` calls are reduced based * on possible data flow from objects of more specific types to the qualifier. */ -overlay[global] -module; import java private import VirtualDispatch diff --git a/java/ql/lib/semmle/code/java/dispatch/VirtualDispatch.qll b/java/ql/lib/semmle/code/java/dispatch/VirtualDispatch.qll index 837f0bd764c..78bf1ad0bdc 100644 --- a/java/ql/lib/semmle/code/java/dispatch/VirtualDispatch.qll +++ b/java/ql/lib/semmle/code/java/dispatch/VirtualDispatch.qll @@ -2,8 +2,6 @@ * Provides predicates for reasoning about runtime call targets through virtual * dispatch. */ -overlay[global] -module; import java import semmle.code.java.dataflow.TypeFlow diff --git a/java/ql/lib/semmle/code/java/dispatch/internal/Unification.qll b/java/ql/lib/semmle/code/java/dispatch/internal/Unification.qll index e1cbf6be7f6..6c92f7298d9 100644 --- a/java/ql/lib/semmle/code/java/dispatch/internal/Unification.qll +++ b/java/ql/lib/semmle/code/java/dispatch/internal/Unification.qll @@ -1,8 +1,6 @@ /** * Provides a module to check whether two `ParameterizedType`s are unifiable. */ -overlay[global] -module; import java