Replace all definitions of Unit by import codeql.util.Unit

This commit is contained in:
Jeroen Ketema
2023-03-23 21:13:52 +01:00
parent 110d666010
commit a87a9438c7
15 changed files with 17 additions and 88 deletions

View File

@@ -8,3 +8,4 @@ upgrades: upgrades
dependencies: dependencies:
codeql/ssa: ${workspace} codeql/ssa: ${workspace}
codeql/tutorial: ${workspace} codeql/tutorial: ${workspace}
codeql/util: ${workspace}

View File

@@ -3,6 +3,7 @@ private import DataFlowUtil
private import DataFlowDispatch private import DataFlowDispatch
private import FlowVar private import FlowVar
private import DataFlowImplConsistency private import DataFlowImplConsistency
import codeql.util.Unit
/** Gets the callable in which this node occurs. */ /** Gets the callable in which this node occurs. */
DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() } DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() }
@@ -264,15 +265,6 @@ int accessPathLimit() { result = 5 }
*/ */
predicate forceHighPrecision(Content c) { none() } predicate forceHighPrecision(Content c) { none() }
/** The unit type. */
private newtype TUnit = TMkUnit()
/** The trivial type with a single element. */
class Unit extends TUnit {
/** Gets a textual representation of this element. */
string toString() { result = "unit" }
}
/** Holds if `n` should be hidden from path explanations. */ /** Holds if `n` should be hidden from path explanations. */
predicate nodeIsHidden(Node n) { none() } predicate nodeIsHidden(Node n) { none() }

View File

@@ -6,6 +6,7 @@ private import DataFlowImplConsistency
private import semmle.code.cpp.ir.internal.IRCppLanguage private import semmle.code.cpp.ir.internal.IRCppLanguage
private import SsaInternals as Ssa private import SsaInternals as Ssa
private import DataFlowImplCommon as DataFlowImplCommon private import DataFlowImplCommon as DataFlowImplCommon
import codeql.util.Unit
cached cached
private module Cached { private module Cached {
@@ -799,15 +800,6 @@ int accessPathLimit() { result = 5 }
*/ */
predicate forceHighPrecision(Content c) { none() } predicate forceHighPrecision(Content c) { none() }
/** The unit type. */
private newtype TUnit = TMkUnit()
/** The trivial type with a single element. */
class Unit extends TUnit {
/** Gets a textual representation of this element. */
string toString() { result = "unit" }
}
/** Holds if `n` should be hidden from path explanations. */ /** Holds if `n` should be hidden from path explanations. */
predicate nodeIsHidden(Node n) { predicate nodeIsHidden(Node n) {
n instanceof OperandNode and n instanceof OperandNode and

View File

@@ -19,6 +19,7 @@ private import semmle.code.csharp.frameworks.system.Collections
private import semmle.code.csharp.frameworks.system.threading.Tasks private import semmle.code.csharp.frameworks.system.threading.Tasks
private import semmle.code.cil.Ssa::Ssa as CilSsa private import semmle.code.cil.Ssa::Ssa as CilSsa
private import semmle.code.cil.internal.SsaImpl as CilSsaImpl private import semmle.code.cil.internal.SsaImpl as CilSsaImpl
import codeql.util.Unit
/** Gets the callable in which this node occurs. */ /** Gets the callable in which this node occurs. */
DataFlowCallable nodeGetEnclosingCallable(NodeImpl n) { result = n.getEnclosingCallableImpl() } DataFlowCallable nodeGetEnclosingCallable(NodeImpl n) { result = n.getEnclosingCallableImpl() }
@@ -2163,15 +2164,6 @@ int accessPathLimit() { result = 5 }
*/ */
predicate forceHighPrecision(Content c) { c instanceof ElementContent } predicate forceHighPrecision(Content c) { c instanceof ElementContent }
/** The unit type. */
private newtype TUnit = TMkUnit()
/** The trivial type with a single element. */
class Unit extends TUnit {
/** Gets a textual representation of this element. */
string toString() { result = "unit" }
}
class LambdaCallKind = Unit; class LambdaCallKind = Unit;
/** Holds if `creation` is an expression that creates a delegate for `c`. */ /** Holds if `creation` is an expression that creates a delegate for `c`. */
@@ -2183,7 +2175,7 @@ predicate lambdaCreation(ExprNode creation, LambdaCallKind kind, DataFlowCallabl
e.(AddressOfExpr).getOperand().(CallableAccess).getTarget().getUnboundDeclaration() e.(AddressOfExpr).getOperand().(CallableAccess).getTarget().getUnboundDeclaration()
] ]
) and ) and
kind = TMkUnit() exists(kind)
} }
private class LambdaConfiguration extends ControlFlowReachabilityConfiguration { private class LambdaConfiguration extends ControlFlowReachabilityConfiguration {
@@ -2214,7 +2206,7 @@ predicate lambdaCall(DataFlowCall call, LambdaCallKind kind, Node receiver) {
or or
receiver = call.(SummaryCall).getReceiver() receiver = call.(SummaryCall).getReceiver()
) and ) and
kind = TMkUnit() exists(kind)
} }
/** Extra data-flow steps needed for lambda flow analysis. */ /** Extra data-flow steps needed for lambda flow analysis. */

View File

@@ -7,5 +7,6 @@ library: true
upgrades: upgrades upgrades: upgrades
dependencies: dependencies:
codeql/tutorial: ${workspace} codeql/tutorial: ${workspace}
codeql/util: ${workspace}
dataExtensions: dataExtensions:
- ext/*.model.yml - ext/*.model.yml

View File

@@ -3,6 +3,7 @@ private import DataFlowUtil
private import DataFlowImplCommon private import DataFlowImplCommon
private import ContainerFlow private import ContainerFlow
private import FlowSummaryImpl as FlowSummaryImpl private import FlowSummaryImpl as FlowSummaryImpl
import codeql.util.Unit
import DataFlowNodes::Private import DataFlowNodes::Private
private newtype TReturnKind = private newtype TReturnKind =
@@ -339,15 +340,6 @@ predicate forceHighPrecision(Content c) {
c instanceof ArrayContent or c instanceof CollectionContent c instanceof ArrayContent or c instanceof CollectionContent
} }
/** The unit type. */
private newtype TUnit = TMkUnit()
/** The trivial type with a single element. */
class Unit extends TUnit {
/** Gets a textual representation of this element. */
string toString() { result = "unit" }
}
/** /**
* Gets the `i`th argument of call `c`, where the receiver of a method call * Gets the `i`th argument of call `c`, where the receiver of a method call
* counts as argument -1. * counts as argument -1.

View File

@@ -4,6 +4,7 @@
private import go private import go
private import FlowSummaryImpl as FlowSummaryImpl private import FlowSummaryImpl as FlowSummaryImpl
private import codeql.util.Unit
/** /**
* Holds if taint can flow from `src` to `sink` in zero or more * Holds if taint can flow from `src` to `sink` in zero or more
@@ -66,14 +67,6 @@ predicate defaultImplicitTaintRead(DataFlow::Node node, DataFlow::Content c) {
) )
} }
private newtype TUnit = TMkUnit()
/** A singleton class containing a single dummy "unit" value. */
private class Unit extends TUnit {
/** Gets a textual representation of this element. */
string toString() { result = "unit" }
}
/** /**
* A unit class for adding additional taint steps. * A unit class for adding additional taint steps.
* *

View File

@@ -1,10 +1,3 @@
/** Provides the `Unit` class. */ /** Provides the `Unit` class. */
/** The unit type. */ import codeql.util.Unit
private newtype TUnit = TMkUnit()
/** The trivial type with a single element. */
class Unit extends TUnit {
/** Gets a textual representation of this element. */
string toString() { result = "unit" }
}

View File

@@ -8,5 +8,6 @@ upgrades: upgrades
dependencies: dependencies:
codeql/regex: ${workspace} codeql/regex: ${workspace}
codeql/tutorial: ${workspace} codeql/tutorial: ${workspace}
codeql/util: ${workspace}
dataExtensions: dataExtensions:
- semmle/javascript/frameworks/**/model.yml - semmle/javascript/frameworks/**/model.yml

View File

@@ -1,10 +1,3 @@
/** Provides the `Unit` class. */ /** Provides the `Unit` class. */
/** The unit type. */ import codeql.util.Unit
private newtype TUnit = TMkUnit()
/** The trivial type with a single element. */
class Unit extends TUnit {
/** Gets a textual representation of this element. */
string toString() { result = "Unit" }
}

View File

@@ -7,7 +7,7 @@ library: true
upgrades: upgrades upgrades: upgrades
dependencies: dependencies:
codeql/regex: ${workspace} codeql/regex: ${workspace}
codeql/util: ${workspace}
codeql/tutorial: ${workspace} codeql/tutorial: ${workspace}
codeql/util: ${workspace}
dataExtensions: dataExtensions:
- semmle/python/frameworks/**/model.yml - semmle/python/frameworks/**/model.yml

View File

@@ -1,10 +1,3 @@
/** Provides the `Unit` class. */ /** Provides the `Unit` class. */
/** The unit type. */ import codeql.util.Unit
private newtype TUnit = TMkUnit()
/** The trivial type with a single element. */
class Unit extends TUnit {
/** Gets a textual representation of this element. */
string toString() { result = "unit" }
}

View File

@@ -9,6 +9,7 @@ private import SsaImpl as SsaImpl
private import FlowSummaryImpl as FlowSummaryImpl private import FlowSummaryImpl as FlowSummaryImpl
private import FlowSummaryImplSpecific as FlowSummaryImplSpecific private import FlowSummaryImplSpecific as FlowSummaryImplSpecific
private import codeql.ruby.frameworks.data.ModelsAsData private import codeql.ruby.frameworks.data.ModelsAsData
import codeql.util.Unit
/** Gets the callable in which this node occurs. */ /** Gets the callable in which this node occurs. */
DataFlowCallable nodeGetEnclosingCallable(NodeImpl n) { result = n.getEnclosingCallable() } DataFlowCallable nodeGetEnclosingCallable(NodeImpl n) { result = n.getEnclosingCallable() }
@@ -1345,15 +1346,6 @@ int accessPathLimit() { result = 5 }
*/ */
predicate forceHighPrecision(Content c) { c instanceof Content::ElementContent } predicate forceHighPrecision(Content c) { c instanceof Content::ElementContent }
/** The unit type. */
private newtype TUnit = TMkUnit()
/** The trivial type with a single element. */
class Unit extends TUnit {
/** Gets a textual representation of this element. */
string toString() { result = "unit" }
}
/** /**
* Holds if the node `n` is unreachable when the call context is `call`. * Holds if the node `n` is unreachable when the call context is `call`.
*/ */

View File

@@ -1,10 +1,3 @@
/** Provides the `Unit` class. */ /** Provides the `Unit` class. */
/** The unit type. */ import codeql.util.Unit
private newtype TUnit = TMkUnit()
/** The trivial type with a single element. */
class Unit extends TUnit {
/** Gets a textual representation of this element. */
string toString() { result = "unit" }
}

View File

@@ -8,3 +8,4 @@ library: true
dependencies: dependencies:
codeql/ssa: ${workspace} codeql/ssa: ${workspace}
codeql/tutorial: ${workspace} codeql/tutorial: ${workspace}
codeql/util: ${workspace}