Java: Hnalde global files as exceptions rather than annotating them

This allows us to merge them without redundent annoations for now.
This commit is contained in:
Alex Eyers-Taylor
2025-09-10 14:41:31 +01:00
parent 5c19aad012
commit dcc5572767
5 changed files with 9 additions and 8 deletions

View File

@@ -177,6 +177,12 @@ def insert_overlay_caller_annotations(lines):
out_lines.append(line) out_lines.append(line)
return out_lines 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): 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 ((filename.endswith("Query.qll") or filename.endswith("Config.qll")) and
any("implements DataFlow::ConfigSig" in line for line in lines))): any("implements DataFlow::ConfigSig" in line for line in lines))):
return None 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()): elif not any(line for line in lines if line.strip()):
return None return None

View File

@@ -5,8 +5,6 @@
* data flow check for lambdas, anonymous classes, and other sufficiently * data flow check for lambdas, anonymous classes, and other sufficiently
* private classes where all object instantiations are accounted for. * private classes where all object instantiations are accounted for.
*/ */
overlay[global]
module;
import java import java
private import VirtualDispatch private import VirtualDispatch

View File

@@ -6,8 +6,6 @@
* The set of dispatch targets for `Object.toString()` calls are reduced based * 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. * on possible data flow from objects of more specific types to the qualifier.
*/ */
overlay[global]
module;
import java import java
private import VirtualDispatch private import VirtualDispatch

View File

@@ -2,8 +2,6 @@
* Provides predicates for reasoning about runtime call targets through virtual * Provides predicates for reasoning about runtime call targets through virtual
* dispatch. * dispatch.
*/ */
overlay[global]
module;
import java import java
import semmle.code.java.dataflow.TypeFlow import semmle.code.java.dataflow.TypeFlow

View File

@@ -1,8 +1,6 @@
/** /**
* Provides a module to check whether two `ParameterizedType`s are unifiable. * Provides a module to check whether two `ParameterizedType`s are unifiable.
*/ */
overlay[global]
module;
import java import java