Overlay: Add overlay annotations to Java & shared libraries

This commit is contained in:
Kasper Svendsen
2025-06-16 13:06:31 +02:00
parent 2218a981f6
commit c207cfdeb7
428 changed files with 966 additions and 0 deletions

View File

@@ -10,6 +10,8 @@
* This is a restricted version of SSA.qll that only handles `LocalScopeVariable`s
* in order to not depend on virtual dispatch.
*/
overlay[local?]
module;
import java
private import codeql.ssa.Ssa as SsaImplCommon

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
import java
import semmle.code.java.Collections
import semmle.code.java.Maps

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
private import java
private import DataFlowImplSpecific
private import codeql.dataflow.internal.ContentDataFlowImpl

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
private import java
private import DataFlowPrivate
private import DataFlowUtil
@@ -210,6 +213,7 @@ private module DispatchImpl {
}
/** Holds if arguments at position `apos` match parameters at position `ppos`. */
overlay[caller]
pragma[inline]
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos = apos }
}

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
private import DataFlowImplSpecific
private import codeql.dataflow.internal.DataFlowImpl
private import semmle.code.Location

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
private import DataFlowImplSpecific
private import semmle.code.Location
private import codeql.dataflow.internal.DataFlowImplCommon

View File

@@ -2,6 +2,8 @@
* Provides consistency queries for checking invariants in the language-specific
* data-flow classes and predicates.
*/
overlay[local?]
module;
private import java
private import DataFlowImplSpecific

View File

@@ -1,6 +1,8 @@
/**
* Provides Java-specific definitions for use in the data flow library.
*/
overlay[local?]
module;
private import semmle.code.Location
private import codeql.dataflow.DataFlow

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
private import java
private import semmle.code.java.dataflow.InstanceAccess
private import semmle.code.java.dataflow.ExternalFlow

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
private import java
private import DataFlowUtil
private import DataFlowImplCommon

View File

@@ -1,6 +1,8 @@
/**
* Basic definitions for use in the data flow library.
*/
overlay[local?]
module;
private import java
private import DataFlowPrivate
@@ -77,6 +79,7 @@ private module ThisFlow {
* Holds if data can flow from `node1` to `node2` in zero or more
* local (intra-procedural) steps.
*/
overlay[caller]
pragma[inline]
predicate localFlow(Node node1, Node node2) { node1 = node2 or localFlowStepPlus(node1, node2) }
@@ -86,6 +89,7 @@ private predicate localFlowStepPlus(Node node1, Node node2) = fastTC(localFlowSt
* Holds if data can flow from `e1` to `e2` in zero or more
* local (intra-procedural) steps.
*/
overlay[caller]
pragma[inline]
predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2)) }

View File

@@ -1,6 +1,8 @@
/**
* This module provides extensible predicates for defining MaD models.
*/
overlay[local?]
module;
/**
* Holds if a source model exists for the given parameters.

View File

@@ -1,6 +1,8 @@
/**
* Provides classes and predicates for defining flow summaries.
*/
overlay[local?]
module;
private import java
private import codeql.dataflow.internal.FlowSummaryImpl

View File

@@ -1,4 +1,6 @@
/** Provides classes and predicates for exclusions related to MaD models. */
overlay[local?]
module;
import java

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
import java
private import codeql.ssa.Ssa as SsaImplCommon
private import semmle.code.java.dataflow.SSA

View File

@@ -1,6 +1,8 @@
/**
* Provides Java-specific definitions for use in the taint tracking library.
*/
overlay[local?]
module;
private import codeql.dataflow.TaintTracking
private import DataFlowImplSpecific

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
private import java
private import semmle.code.java.dataflow.DataFlow
private import semmle.code.java.Collections
@@ -20,6 +23,7 @@ private import semmle.code.java.frameworks.JaxWS
* Holds if taint can flow from `src` to `sink` in zero or more
* local (intra-procedural) steps.
*/
overlay[caller]
pragma[inline]
predicate localTaint(DataFlow::Node src, DataFlow::Node sink) { localTaintStep*(src, sink) }
@@ -27,6 +31,7 @@ predicate localTaint(DataFlow::Node src, DataFlow::Node sink) { localTaintStep*(
* Holds if taint can flow from `src` to `sink` in zero or more
* local (intra-procedural) steps.
*/
overlay[caller]
pragma[inline]
predicate localExprTaint(Expr src, Expr sink) {
localTaint(DataFlow::exprNode(src), DataFlow::exprNode(sink))
@@ -69,6 +74,7 @@ module LocalTaintFlow<nodeSig/1 source, nodeSig/1 sink> {
* (intra-procedural) steps that are restricted to be part of a path between
* `source` and `sink`.
*/
overlay[caller]
pragma[inline]
predicate hasFlow(DataFlow::Node n1, DataFlow::Node n2) { step*(n1, n2) }
@@ -77,6 +83,7 @@ module LocalTaintFlow<nodeSig/1 source, nodeSig/1 sink> {
* (intra-procedural) steps that are restricted to be part of a path between
* `source` and `sink`.
*/
overlay[caller]
pragma[inline]
predicate hasExprFlow(Expr n1, Expr n2) {
hasFlow(DataFlow::exprNode(n1), DataFlow::exprNode(n2))

View File

@@ -1,6 +1,8 @@
/**
* Provides Java-specific definitions for bounds.
*/
overlay[local?]
module;
private import java as J
private import semmle.code.java.dataflow.SSA as Ssa

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
module Private {
private import java as J
private import semmle.code.java.dataflow.SSA as Ssa

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
newtype TSign =
TNeg() or
TZero() or

View File

@@ -5,6 +5,8 @@
* The analysis is implemented as an abstract interpretation over the
* three-valued domain `{negative, zero, positive}`.
*/
overlay[local?]
module;
private import SignAnalysisSpecific::Private
private import SsaReadPositionCommon

View File

@@ -1,3 +1,6 @@
overlay[local?]
module;
/**
* Provides Java-specific definitions for use in sign analysis.
*/

View File

@@ -1,6 +1,8 @@
/**
* Provides classes for representing a position at which an SSA variable is read.
*/
overlay[local?]
module;
private import SsaReadPositionSpecific
import SsaReadPositionSpecific::Public

View File

@@ -1,6 +1,8 @@
/**
* Provides Java-specific definitions for use in the `SsaReadPosition`.
*/
overlay[local?]
module;
private import semmle.code.java.dataflow.SSA as Ssa
private import semmle.code.java.controlflow.BasicBlocks as BB