mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #7245 from erik-krogh/explicit-this-all-the-places
All langs: apply the explicit-this patch to all remaining code
This commit is contained in:
@@ -626,9 +626,9 @@ library class ExprEvaluator extends int {
|
||||
// All assignments must have the same int value
|
||||
result =
|
||||
unique(Expr value |
|
||||
value = v.getAnAssignedValue() and not ignoreVariableAssignment(e, v, value)
|
||||
value = v.getAnAssignedValue() and not this.ignoreVariableAssignment(e, v, value)
|
||||
|
|
||||
getValueInternalNonSubExpr(value)
|
||||
this.getValueInternalNonSubExpr(value)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -452,7 +452,7 @@ class SsaPhiNode extends Node, TSsaPhiNode {
|
||||
|
||||
/** Holds if this phi node has input from the `rnk`'th write operation in block `block`. */
|
||||
final predicate hasInputAtRankInBlock(IRBlock block, int rnk) {
|
||||
hasInputAtRankInBlock(block, rnk, _)
|
||||
this.hasInputAtRankInBlock(block, rnk, _)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -307,7 +307,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe
|
||||
final override string toString() { result = tag.toString() }
|
||||
|
||||
final override Instruction getAnyDef() {
|
||||
result = unique(Instruction defInstr | hasDefinition(defInstr, _))
|
||||
result = unique(Instruction defInstr | this.hasDefinition(defInstr, _))
|
||||
}
|
||||
|
||||
final override Overlap getDefinitionOverlap() { this.hasDefinition(_, result) }
|
||||
|
||||
@@ -307,7 +307,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe
|
||||
final override string toString() { result = tag.toString() }
|
||||
|
||||
final override Instruction getAnyDef() {
|
||||
result = unique(Instruction defInstr | hasDefinition(defInstr, _))
|
||||
result = unique(Instruction defInstr | this.hasDefinition(defInstr, _))
|
||||
}
|
||||
|
||||
final override Overlap getDefinitionOverlap() { this.hasDefinition(_, result) }
|
||||
|
||||
@@ -307,7 +307,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe
|
||||
final override string toString() { result = tag.toString() }
|
||||
|
||||
final override Instruction getAnyDef() {
|
||||
result = unique(Instruction defInstr | hasDefinition(defInstr, _))
|
||||
result = unique(Instruction defInstr | this.hasDefinition(defInstr, _))
|
||||
}
|
||||
|
||||
final override Overlap getDefinitionOverlap() { this.hasDefinition(_, result) }
|
||||
|
||||
@@ -18,12 +18,12 @@ class SuppressionComment extends Comment {
|
||||
(
|
||||
this instanceof CppStyleComment and
|
||||
// strip the beginning slashes
|
||||
text = getContents().suffix(2)
|
||||
text = this.getContents().suffix(2)
|
||||
or
|
||||
this instanceof CStyleComment and
|
||||
// strip both the beginning /* and the end */ the comment
|
||||
exists(string text0 |
|
||||
text0 = getContents().suffix(2) and
|
||||
text0 = this.getContents().suffix(2) and
|
||||
text = text0.prefix(text0.length() - 2)
|
||||
) and
|
||||
// The /* */ comment must be a single-line comment
|
||||
|
||||
@@ -153,12 +153,12 @@ class ExtClass extends Class {
|
||||
}
|
||||
|
||||
predicate hasLocationInfo(string path, int startline, int startcol, int endline, int endcol) {
|
||||
if hasOneVariableGroup()
|
||||
if this.hasOneVariableGroup()
|
||||
then
|
||||
exists(VariableDeclarationGroup vdg | vdg.getClass() = this |
|
||||
vdg.hasLocationInfo(path, startline, startcol, endline, endcol)
|
||||
)
|
||||
else getLocation().hasLocationInfo(path, startline, startcol, endline, endcol)
|
||||
else this.getLocation().hasLocationInfo(path, startline, startcol, endline, endcol)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,9 +103,9 @@ class CallWithBufferSize extends FunctionCall {
|
||||
// `upperBound(e)` defaults to `exprMaxVal(e)` when `e` isn't analyzable. So to get a meaningful
|
||||
// result in this case we pick the minimum value obtainable from dataflow and range analysis.
|
||||
result =
|
||||
upperBound(statedSizeExpr())
|
||||
upperBound(this.statedSizeExpr())
|
||||
.minimum(min(Expr statedSizeSrc |
|
||||
DataFlow::localExprFlow(statedSizeSrc, statedSizeExpr())
|
||||
DataFlow::localExprFlow(statedSizeSrc, this.statedSizeExpr())
|
||||
|
|
||||
statedSizeSrc.getValue().toInt()
|
||||
))
|
||||
|
||||
@@ -22,7 +22,7 @@ abstract class LockOperation extends FunctionCall {
|
||||
ControlFlowNode getAReachedNode() {
|
||||
result = this
|
||||
or
|
||||
exists(ControlFlowNode mid | mid = getAReachedNode() |
|
||||
exists(ControlFlowNode mid | mid = this.getAReachedNode() |
|
||||
not mid != this.getMatchingUnlock() and
|
||||
result = mid.getASuccessor()
|
||||
)
|
||||
|
||||
@@ -156,8 +156,8 @@ abstract class LeapYearFieldAccess extends YearFieldAccess {
|
||||
//
|
||||
// https://aa.usno.navy.mil/faq/docs/calendars.php
|
||||
this.isUsedInMod4Operation() and
|
||||
additionalModulusCheckForLeapYear(400) and
|
||||
additionalModulusCheckForLeapYear(100)
|
||||
this.additionalModulusCheckForLeapYear(400) and
|
||||
this.additionalModulusCheckForLeapYear(100)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,17 +176,17 @@ class StructTmLeapYearFieldAccess extends LeapYearFieldAccess {
|
||||
|
||||
override predicate isUsedInCorrectLeapYearCheck() {
|
||||
this.isUsedInMod4Operation() and
|
||||
additionalModulusCheckForLeapYear(400) and
|
||||
additionalModulusCheckForLeapYear(100) and
|
||||
this.additionalModulusCheckForLeapYear(400) and
|
||||
this.additionalModulusCheckForLeapYear(100) and
|
||||
// tm_year represents years since 1900
|
||||
(
|
||||
additionalAdditionOrSubstractionCheckForLeapYear(1900)
|
||||
this.additionalAdditionOrSubstractionCheckForLeapYear(1900)
|
||||
or
|
||||
// some systems may use 2000 for 2-digit year conversions
|
||||
additionalAdditionOrSubstractionCheckForLeapYear(2000)
|
||||
this.additionalAdditionOrSubstractionCheckForLeapYear(2000)
|
||||
or
|
||||
// converting from/to Unix epoch
|
||||
additionalAdditionOrSubstractionCheckForLeapYear(1970)
|
||||
this.additionalAdditionOrSubstractionCheckForLeapYear(1970)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class LoopWithAlloca extends Stmt {
|
||||
or
|
||||
// `e == 0`
|
||||
exists(EQExpr eq |
|
||||
conditionRequires(eq, truth.booleanNot()) and
|
||||
this.conditionRequires(eq, truth.booleanNot()) and
|
||||
eq.getAnOperand().getValue().toInt() = 0 and
|
||||
e = eq.getAnOperand() and
|
||||
not exists(e.getValue())
|
||||
@@ -65,7 +65,7 @@ class LoopWithAlloca extends Stmt {
|
||||
or
|
||||
// `e != 0`
|
||||
exists(NEExpr eq |
|
||||
conditionRequires(eq, truth) and
|
||||
this.conditionRequires(eq, truth) and
|
||||
eq.getAnOperand().getValue().toInt() = 0 and
|
||||
e = eq.getAnOperand() and
|
||||
not exists(e.getValue())
|
||||
@@ -73,7 +73,7 @@ class LoopWithAlloca extends Stmt {
|
||||
or
|
||||
// `(bool)e == true`
|
||||
exists(EQExpr eq |
|
||||
conditionRequires(eq, truth) and
|
||||
this.conditionRequires(eq, truth) and
|
||||
eq.getAnOperand().getValue().toInt() = 1 and
|
||||
e = eq.getAnOperand() and
|
||||
e.getUnspecifiedType() instanceof BoolType and
|
||||
@@ -82,7 +82,7 @@ class LoopWithAlloca extends Stmt {
|
||||
or
|
||||
// `(bool)e != true`
|
||||
exists(NEExpr eq |
|
||||
conditionRequires(eq, truth.booleanNot()) and
|
||||
this.conditionRequires(eq, truth.booleanNot()) and
|
||||
eq.getAnOperand().getValue().toInt() = 1 and
|
||||
e = eq.getAnOperand() and
|
||||
e.getUnspecifiedType() instanceof BoolType and
|
||||
@@ -90,7 +90,7 @@ class LoopWithAlloca extends Stmt {
|
||||
)
|
||||
or
|
||||
exists(NotExpr notExpr |
|
||||
conditionRequires(notExpr, truth.booleanNot()) and
|
||||
this.conditionRequires(notExpr, truth.booleanNot()) and
|
||||
e = notExpr.getOperand()
|
||||
)
|
||||
or
|
||||
@@ -98,7 +98,7 @@ class LoopWithAlloca extends Stmt {
|
||||
// requires both of its operand to be true as well.
|
||||
exists(LogicalAndExpr andExpr |
|
||||
truth = true and
|
||||
conditionRequires(andExpr, truth) and
|
||||
this.conditionRequires(andExpr, truth) and
|
||||
e = andExpr.getAnOperand()
|
||||
)
|
||||
or
|
||||
@@ -106,7 +106,7 @@ class LoopWithAlloca extends Stmt {
|
||||
// it requires both of its operand to be false as well.
|
||||
exists(LogicalOrExpr orExpr |
|
||||
truth = false and
|
||||
conditionRequires(orExpr, truth) and
|
||||
this.conditionRequires(orExpr, truth) and
|
||||
e = orExpr.getAnOperand()
|
||||
)
|
||||
}
|
||||
@@ -141,9 +141,9 @@ class LoopWithAlloca extends Stmt {
|
||||
* `conditionRequiresInequality`.
|
||||
*/
|
||||
private Variable getAControllingVariable() {
|
||||
conditionRequires(result.getAnAccess(), _)
|
||||
this.conditionRequires(result.getAnAccess(), _)
|
||||
or
|
||||
conditionRequiresInequality(result.getAnAccess(), _, _)
|
||||
this.conditionRequiresInequality(result.getAnAccess(), _, _)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,72 +61,72 @@ class PointerArithmeticAccess extends BufferAccess, Expr {
|
||||
* A pair of buffer accesses through a call to memcpy.
|
||||
*/
|
||||
class MemCpy extends BufferAccess, FunctionCall {
|
||||
MemCpy() { getTarget().hasName("memcpy") }
|
||||
MemCpy() { this.getTarget().hasName("memcpy") }
|
||||
|
||||
override Expr getPointer() {
|
||||
result = getArgument(0) or
|
||||
result = getArgument(1)
|
||||
result = this.getArgument(0) or
|
||||
result = this.getArgument(1)
|
||||
}
|
||||
|
||||
override Expr getAccessedLength() { result = getArgument(2) }
|
||||
override Expr getAccessedLength() { result = this.getArgument(2) }
|
||||
}
|
||||
|
||||
class StrncpySizeExpr extends BufferAccess, FunctionCall {
|
||||
StrncpySizeExpr() { getTarget().hasName("strncpy") }
|
||||
StrncpySizeExpr() { this.getTarget().hasName("strncpy") }
|
||||
|
||||
override Expr getPointer() {
|
||||
result = getArgument(0) or
|
||||
result = getArgument(1)
|
||||
result = this.getArgument(0) or
|
||||
result = this.getArgument(1)
|
||||
}
|
||||
|
||||
override Expr getAccessedLength() { result = getArgument(2) }
|
||||
override Expr getAccessedLength() { result = this.getArgument(2) }
|
||||
}
|
||||
|
||||
class RecvSizeExpr extends BufferAccess, FunctionCall {
|
||||
RecvSizeExpr() { getTarget().hasName("recv") }
|
||||
RecvSizeExpr() { this.getTarget().hasName("recv") }
|
||||
|
||||
override Expr getPointer() { result = getArgument(1) }
|
||||
override Expr getPointer() { result = this.getArgument(1) }
|
||||
|
||||
override Expr getAccessedLength() { result = getArgument(2) }
|
||||
override Expr getAccessedLength() { result = this.getArgument(2) }
|
||||
}
|
||||
|
||||
class SendSizeExpr extends BufferAccess, FunctionCall {
|
||||
SendSizeExpr() { getTarget().hasName("send") }
|
||||
SendSizeExpr() { this.getTarget().hasName("send") }
|
||||
|
||||
override Expr getPointer() { result = getArgument(1) }
|
||||
override Expr getPointer() { result = this.getArgument(1) }
|
||||
|
||||
override Expr getAccessedLength() { result = getArgument(2) }
|
||||
override Expr getAccessedLength() { result = this.getArgument(2) }
|
||||
}
|
||||
|
||||
class SnprintfSizeExpr extends BufferAccess, FunctionCall {
|
||||
SnprintfSizeExpr() { getTarget().hasName("snprintf") }
|
||||
SnprintfSizeExpr() { this.getTarget().hasName("snprintf") }
|
||||
|
||||
override Expr getPointer() { result = getArgument(0) }
|
||||
override Expr getPointer() { result = this.getArgument(0) }
|
||||
|
||||
override Expr getAccessedLength() { result = getArgument(1) }
|
||||
override Expr getAccessedLength() { result = this.getArgument(1) }
|
||||
}
|
||||
|
||||
class MemcmpSizeExpr extends BufferAccess, FunctionCall {
|
||||
MemcmpSizeExpr() { getTarget().hasName("Memcmp") }
|
||||
MemcmpSizeExpr() { this.getTarget().hasName("Memcmp") }
|
||||
|
||||
override Expr getPointer() {
|
||||
result = getArgument(0) or
|
||||
result = getArgument(1)
|
||||
result = this.getArgument(0) or
|
||||
result = this.getArgument(1)
|
||||
}
|
||||
|
||||
override Expr getAccessedLength() { result = getArgument(2) }
|
||||
override Expr getAccessedLength() { result = this.getArgument(2) }
|
||||
}
|
||||
|
||||
class MallocSizeExpr extends BufferAccess, FunctionCall {
|
||||
MallocSizeExpr() { getTarget().hasName("malloc") }
|
||||
MallocSizeExpr() { this.getTarget().hasName("malloc") }
|
||||
|
||||
override Expr getPointer() { none() }
|
||||
|
||||
override Expr getAccessedLength() { result = getArgument(0) }
|
||||
override Expr getAccessedLength() { result = this.getArgument(0) }
|
||||
}
|
||||
|
||||
class NetworkFunctionCall extends FunctionCall {
|
||||
NetworkFunctionCall() { getTarget().hasName(["ntohd", "ntohf", "ntohl", "ntohll", "ntohs"]) }
|
||||
NetworkFunctionCall() { this.getTarget().hasName(["ntohd", "ntohf", "ntohl", "ntohll", "ntohs"]) }
|
||||
}
|
||||
|
||||
class NetworkToBufferSizeConfiguration extends DataFlow::Configuration {
|
||||
|
||||
@@ -13,7 +13,7 @@ import cpp
|
||||
|
||||
class MacroFunctionCall extends MacroInvocation {
|
||||
MacroFunctionCall() {
|
||||
not exists(getParentInvocation()) and
|
||||
not exists(this.getParentInvocation()) and
|
||||
this.getMacro().getHead().matches("%(%")
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import semmle.code.cpp.commons.Assertions
|
||||
|
||||
class MacroFunctionCall extends MacroInvocation {
|
||||
MacroFunctionCall() {
|
||||
not exists(getParentInvocation()) and
|
||||
not exists(this.getParentInvocation()) and
|
||||
this.getMacro().getHead().matches("%(%")
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class ExternalAPIDataNode extends DataFlow::Node {
|
||||
int getIndex() { result = i }
|
||||
|
||||
/** Gets the description of the function being called. */
|
||||
string getFunctionDescription() { result = getExternalFunction().toString() }
|
||||
string getFunctionDescription() { result = this.getExternalFunction().toString() }
|
||||
}
|
||||
|
||||
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalAPIDataNode`s. */
|
||||
|
||||
@@ -38,7 +38,7 @@ class ExternalAPIDataNode extends DataFlow::Node {
|
||||
int getIndex() { result = i }
|
||||
|
||||
/** Gets the description of the function being called. */
|
||||
string getFunctionDescription() { result = getExternalFunction().toString() }
|
||||
string getFunctionDescription() { result = this.getExternalFunction().toString() }
|
||||
}
|
||||
|
||||
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalAPIDataNode`s. */
|
||||
|
||||
@@ -42,7 +42,7 @@ class VarargsFunction extends Function {
|
||||
}
|
||||
|
||||
private int trailingArgValueCount(string value) {
|
||||
result = strictcount(FunctionCall fc | trailingArgValue(fc) = value)
|
||||
result = strictcount(FunctionCall fc | this.trailingArgValue(fc) = value)
|
||||
}
|
||||
|
||||
string nonTrailingVarArgValue(FunctionCall fc, int index) {
|
||||
@@ -58,11 +58,11 @@ class VarargsFunction extends Function {
|
||||
|
||||
string normalTerminator(int cnt) {
|
||||
result = ["0", "-1"] and
|
||||
cnt = trailingArgValueCount(result) and
|
||||
2 * cnt > totalCount() and
|
||||
cnt = this.trailingArgValueCount(result) and
|
||||
2 * cnt > this.totalCount() and
|
||||
not exists(FunctionCall fc, int index |
|
||||
// terminator value is used in a non-terminating position
|
||||
nonTrailingVarArgValue(fc, index) = result
|
||||
this.nonTrailingVarArgValue(fc, index) = result
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class TaintSource extends VariableAccess {
|
||||
definitionUsePair(_, this, va)
|
||||
or
|
||||
exists(VariableAccess mid, Expr def |
|
||||
sourceReaches(mid) and
|
||||
this.sourceReaches(mid) and
|
||||
exprDefinition(_, def, mid) and
|
||||
definitionUsePair(_, def, va)
|
||||
)
|
||||
@@ -53,11 +53,11 @@ class TaintSource extends VariableAccess {
|
||||
* from `va`, possibly using intermediate reassignments.
|
||||
*/
|
||||
private predicate reachesSink(VariableAccess va, VariableAccess sink) {
|
||||
isSink(sink) and
|
||||
this.isSink(sink) and
|
||||
va = sink
|
||||
or
|
||||
exists(VariableAccess mid, Expr def |
|
||||
reachesSink(mid, sink) and
|
||||
this.reachesSink(mid, sink) and
|
||||
exprDefinition(_, def, va) and
|
||||
definitionUsePair(_, def, mid)
|
||||
)
|
||||
@@ -71,15 +71,15 @@ class TaintSource extends VariableAccess {
|
||||
* this source to `sink` found via `tainted(source, sink)`.)
|
||||
*/
|
||||
predicate reaches(VariableAccess sink) {
|
||||
isSink(sink) and
|
||||
this.isSink(sink) and
|
||||
not exists(VariableAccess va |
|
||||
va != this and
|
||||
va != sink and
|
||||
mayAddNullTerminator(_, va)
|
||||
|
|
||||
sourceReaches(va)
|
||||
this.sourceReaches(va)
|
||||
or
|
||||
reachesSink(va, sink)
|
||||
this.reachesSink(va, sink)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ class ParameterNullCheck extends ParameterCheck {
|
||||
p.getFunction() instanceof InitializationFunction and
|
||||
p.getType().getUnspecifiedType() instanceof PointerType and
|
||||
exists(VariableAccess va | va = p.getAnAccess() |
|
||||
nullSuccessor = getATrueSuccessor() and
|
||||
notNullSuccessor = getAFalseSuccessor() and
|
||||
nullSuccessor = this.getATrueSuccessor() and
|
||||
notNullSuccessor = this.getAFalseSuccessor() and
|
||||
(
|
||||
va = this.(NotExpr).getOperand() or
|
||||
va = any(EQExpr eq | eq = this and eq.getAnOperand().getValue() = "0").getAnOperand() or
|
||||
@@ -95,8 +95,8 @@ class ParameterNullCheck extends ParameterCheck {
|
||||
.getAnOperand()
|
||||
)
|
||||
or
|
||||
nullSuccessor = getAFalseSuccessor() and
|
||||
notNullSuccessor = getATrueSuccessor() and
|
||||
nullSuccessor = this.getAFalseSuccessor() and
|
||||
notNullSuccessor = this.getATrueSuccessor() and
|
||||
(
|
||||
va = this or
|
||||
va = any(NEExpr eq | eq = this and eq.getAnOperand().getValue() = "0").getAnOperand() or
|
||||
@@ -132,7 +132,7 @@ class ValidatedExternalCondInitFunction extends ExternalData {
|
||||
ValidatedExternalCondInitFunction() { this.getDataPath().matches("%cond-init%.csv") }
|
||||
|
||||
predicate isExternallyVerified(Function f, int param) {
|
||||
functionSignature(f, getField(1), getField(2)) and param = getFieldAsInt(3)
|
||||
functionSignature(f, this.getField(1), this.getField(2)) and param = this.getFieldAsInt(3)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ class InitializationFunction extends Function {
|
||||
.getAnOverridingFunction+()
|
||||
.(InitializationFunction)
|
||||
.initializedParameter() or
|
||||
getParameter(i) = any(InitializationFunctionCall c).getAnInitParameter()
|
||||
this.getParameter(i) = any(InitializationFunctionCall c).getAnInitParameter()
|
||||
)
|
||||
or
|
||||
// If we have no definition, we look at SAL annotations
|
||||
@@ -227,7 +227,7 @@ class InitializationFunction extends Function {
|
||||
result = getAnInitializedArgument(any(Call c))
|
||||
or
|
||||
exists(IfStmt check | result = check.getCondition().getAChild*() |
|
||||
paramReassignmentCondition(check)
|
||||
this.paramReassignmentCondition(check)
|
||||
)
|
||||
)
|
||||
or
|
||||
@@ -249,15 +249,15 @@ class InitializationFunction extends Function {
|
||||
|
||||
/** Holds if `n` can be reached without the parameter at `index` being reassigned. */
|
||||
predicate paramNotReassignedAt(ControlFlowNode n, int index, Context c) {
|
||||
c = getAContext(index) and
|
||||
c = this.getAContext(index) and
|
||||
(
|
||||
not exists(this.getEntryPoint()) and index = i and n = this
|
||||
or
|
||||
n = this.getEntryPoint() and index = i
|
||||
or
|
||||
exists(ControlFlowNode mid | paramNotReassignedAt(mid, index, c) |
|
||||
exists(ControlFlowNode mid | this.paramNotReassignedAt(mid, index, c) |
|
||||
n = mid.getASuccessor() and
|
||||
not n = paramReassignment(index) and
|
||||
not n = this.paramReassignment(index) and
|
||||
/*
|
||||
* Ignore successor edges where the parameter is null, because it is then confirmed to be
|
||||
* initialized.
|
||||
@@ -265,7 +265,7 @@ class InitializationFunction extends Function {
|
||||
|
||||
not exists(ParameterNullCheck nullCheck |
|
||||
nullCheck = mid and
|
||||
nullCheck = getANullCheck(index) and
|
||||
nullCheck = this.getANullCheck(index) and
|
||||
n = nullCheck.getNullSuccessor()
|
||||
) and
|
||||
/*
|
||||
@@ -281,13 +281,13 @@ class InitializationFunction extends Function {
|
||||
|
||||
/** Gets a null-check on the parameter at `index`. */
|
||||
private ParameterNullCheck getANullCheck(int index) {
|
||||
getParameter(index) = result.getParameter()
|
||||
this.getParameter(index) = result.getParameter()
|
||||
}
|
||||
|
||||
/** Gets a parameter which is not at the given index. */
|
||||
private Parameter getOtherParameter(int index) {
|
||||
index = i and
|
||||
result = getAParameter() and
|
||||
result = this.getAParameter() and
|
||||
not result.getIndex() = index
|
||||
}
|
||||
|
||||
@@ -306,10 +306,10 @@ class InitializationFunction extends Function {
|
||||
if
|
||||
strictcount(Parameter p |
|
||||
exists(Context c | c = ParamNull(p) or c = ParamNotNull(p)) and
|
||||
p = getOtherParameter(index)
|
||||
p = this.getOtherParameter(index)
|
||||
) = 1
|
||||
then
|
||||
exists(Parameter p | p = getOtherParameter(index) |
|
||||
exists(Parameter p | p = this.getOtherParameter(index) |
|
||||
result = ParamNull(p) or result = ParamNotNull(p)
|
||||
)
|
||||
else
|
||||
@@ -424,8 +424,8 @@ class ConditionalInitializationCall extends FunctionCall {
|
||||
|
||||
/** Gets the argument passed for the given parameter to this call. */
|
||||
Expr getArgumentForParameter(Parameter p) {
|
||||
p = getTarget().getAParameter() and
|
||||
result = getArgument(p.getIndex())
|
||||
p = this.getTarget().getAParameter() and
|
||||
result = this.getArgument(p.getIndex())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,7 +442,7 @@ class ConditionalInitializationCall extends FunctionCall {
|
||||
context = ParamNotNull(otherP) or
|
||||
context = ParamNull(otherP)
|
||||
|
|
||||
otherArg = getArgumentForParameter(otherP) and
|
||||
otherArg = this.getArgumentForParameter(otherP) and
|
||||
(otherArg instanceof AddressOfExpr implies context = ParamNotNull(otherP)) and
|
||||
(otherArg.getType() instanceof ArrayType implies context = ParamNotNull(otherP)) and
|
||||
(otherArg.getValue() = "0" implies context = ParamNull(otherP))
|
||||
@@ -511,8 +511,8 @@ class ConditionalInitializationCall extends FunctionCall {
|
||||
)
|
||||
)
|
||||
or
|
||||
exists(ControlFlowNode mid | mid = uncheckedReaches(var) |
|
||||
not mid = getStatusVariable().getAnAccess() and
|
||||
exists(ControlFlowNode mid | mid = this.uncheckedReaches(var) |
|
||||
not mid = this.getStatusVariable().getAnAccess() and
|
||||
not mid = var.getAnAccess() and
|
||||
not exists(VariableAccess write | result = write and write = var.getAnAccess() |
|
||||
write = any(AssignExpr a).getLValue() or
|
||||
|
||||
@@ -44,7 +44,7 @@ class ConditionallyInitializedVariable extends LocalVariable {
|
||||
// Find a call that conditionally initializes this variable
|
||||
hasConditionalInitialization(f, call, this, initAccess, e) and
|
||||
// Ignore cases where the variable is assigned prior to the call
|
||||
not reaches(getAnAssignedValue(), initAccess) and
|
||||
not reaches(this.getAnAssignedValue(), initAccess) and
|
||||
// Ignore cases where the variable is assigned field-wise prior to the call.
|
||||
not exists(FieldAccess fa |
|
||||
exists(Assignment a |
|
||||
@@ -56,7 +56,7 @@ class ConditionallyInitializedVariable extends LocalVariable {
|
||||
) and
|
||||
// Ignore cases where the variable is assigned by a prior call to an initialization function
|
||||
not exists(Call c |
|
||||
getAnAccess() = getAnInitializedArgument(c).(AddressOfExpr).getOperand() and
|
||||
this.getAnAccess() = getAnInitializedArgument(c).(AddressOfExpr).getOperand() and
|
||||
reaches(c, initAccess)
|
||||
) and
|
||||
/*
|
||||
@@ -64,7 +64,7 @@ class ConditionallyInitializedVariable extends LocalVariable {
|
||||
* the CFG, but should always be considered as initialized, so exclude them.
|
||||
*/
|
||||
|
||||
not exists(getInitializer().getExpr())
|
||||
not exists(this.getInitializer().getExpr())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ class ConditionallyInitializedVariable extends LocalVariable {
|
||||
// Variable associated with this particular call
|
||||
call = initializingCall and
|
||||
// Access is a meaningful read access
|
||||
result = getAReadAccess() and
|
||||
result = this.getAReadAccess() and
|
||||
// Which occurs after the call
|
||||
reaches(call, result) and
|
||||
/*
|
||||
@@ -124,7 +124,7 @@ class ConditionallyInitializedVariable extends LocalVariable {
|
||||
call = initializingCall and
|
||||
initializingFunction = f and
|
||||
e = evidence and
|
||||
result = getAReadAccessAfterCall(initializingCall) and
|
||||
result = this.getAReadAccessAfterCall(initializingCall) and
|
||||
(
|
||||
// Access is risky because status return code ignored completely
|
||||
call instanceof ExprInVoidContext
|
||||
@@ -148,7 +148,7 @@ class ConditionallyInitializedVariable extends LocalVariable {
|
||||
call = initializingCall and
|
||||
initializingFunction = f and
|
||||
e = evidence and
|
||||
result = getAReadAccessAfterCall(initializingCall) and
|
||||
result = this.getAReadAccessAfterCall(initializingCall) and
|
||||
exists(LocalVariable status, Assignment a |
|
||||
a.getRValue() = call and
|
||||
call = status.getAnAssignedValue() and
|
||||
@@ -184,7 +184,7 @@ class ConditionallyInitializedVariable extends LocalVariable {
|
||||
ConditionalInitializationFunction initializingFunction,
|
||||
ConditionalInitializationCall initializingCall, Evidence evidence
|
||||
) {
|
||||
result = getARiskyAccessBeforeStatusCheck(initializingFunction, initializingCall, evidence) or
|
||||
result = getARiskyAccessWithNoStatusCheck(initializingFunction, initializingCall, evidence)
|
||||
result = this.getARiskyAccessBeforeStatusCheck(initializingFunction, initializingCall, evidence) or
|
||||
result = this.getARiskyAccessWithNoStatusCheck(initializingFunction, initializingCall, evidence)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,15 +31,15 @@ abstract class SystemData extends Element {
|
||||
*/
|
||||
Expr getAnExprIndirect() {
|
||||
// direct SystemData
|
||||
result = getAnExpr() or
|
||||
result = this.getAnExpr() or
|
||||
// flow via global or member variable (conservative approximation)
|
||||
result = getAnAffectedVar().getAnAccess() or
|
||||
result = this.getAnAffectedVar().getAnAccess() or
|
||||
// flow via stack variable
|
||||
definitionUsePair(_, getAnExprIndirect(), result) or
|
||||
useUsePair(_, getAnExprIndirect(), result) or
|
||||
useUsePair(_, result, getAnExprIndirect()) or
|
||||
definitionUsePair(_, this.getAnExprIndirect(), result) or
|
||||
useUsePair(_, this.getAnExprIndirect(), result) or
|
||||
useUsePair(_, result, this.getAnExprIndirect()) or
|
||||
// flow from assigned value to assignment expression
|
||||
result.(AssignExpr).getRValue() = getAnExprIndirect()
|
||||
result.(AssignExpr).getRValue() = this.getAnExprIndirect()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,16 +67,16 @@ class IFStream extends Type {
|
||||
*/
|
||||
class CinVariable extends NamespaceVariable {
|
||||
CinVariable() {
|
||||
getName() = ["cin", "wcin"] and
|
||||
getNamespace().getName() = "std"
|
||||
this.getName() = ["cin", "wcin"] and
|
||||
this.getNamespace().getName() = "std"
|
||||
}
|
||||
}
|
||||
|
||||
/** A call to `std::operator>>`. */
|
||||
class OperatorRShiftCall extends FunctionCall {
|
||||
OperatorRShiftCall() {
|
||||
getTarget().getNamespace().getName() = "std" and
|
||||
getTarget().hasName("operator>>")
|
||||
this.getTarget().getNamespace().getName() = "std" and
|
||||
this.getTarget().hasName("operator>>")
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -87,15 +87,15 @@ class OperatorRShiftCall extends FunctionCall {
|
||||
*/
|
||||
|
||||
Expr getSource() {
|
||||
if getTarget() instanceof MemberFunction
|
||||
then result = getQualifier()
|
||||
else result = getArgument(0)
|
||||
if this.getTarget() instanceof MemberFunction
|
||||
then result = this.getQualifier()
|
||||
else result = this.getArgument(0)
|
||||
}
|
||||
|
||||
Expr getDest() {
|
||||
if getTarget() instanceof MemberFunction
|
||||
then result = getArgument(0)
|
||||
else result = getArgument(1)
|
||||
if this.getTarget() instanceof MemberFunction
|
||||
then result = this.getArgument(0)
|
||||
else result = this.getArgument(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ abstract class PotentiallyDangerousInput extends Expr {
|
||||
* Gets the width restriction that applies to the input stream
|
||||
* for this expression, if any.
|
||||
*/
|
||||
Expr getWidth() { result = getPreviousAccess().getWidthAfter() }
|
||||
Expr getWidth() { result = this.getPreviousAccess().getWidthAfter() }
|
||||
|
||||
private Expr getWidthSetHere() {
|
||||
exists(FunctionCall widthCall |
|
||||
@@ -154,11 +154,11 @@ abstract class PotentiallyDangerousInput extends Expr {
|
||||
* after this expression, if any.
|
||||
*/
|
||||
Expr getWidthAfter() {
|
||||
result = getWidthSetHere()
|
||||
result = this.getWidthSetHere()
|
||||
or
|
||||
not exists(getWidthSetHere()) and
|
||||
not isWidthConsumedHere() and
|
||||
result = getWidth()
|
||||
not exists(this.getWidthSetHere()) and
|
||||
not this.isWidthConsumedHere() and
|
||||
result = this.getWidth()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ predicate argumentMayBeRoot(Expr e) {
|
||||
|
||||
class SetuidLikeFunctionCall extends FunctionCall {
|
||||
SetuidLikeFunctionCall() {
|
||||
(getTarget().hasGlobalName("setuid") or getTarget().hasGlobalName("setresuid")) and
|
||||
(this.getTarget().hasGlobalName("setuid") or this.getTarget().hasGlobalName("setresuid")) and
|
||||
// setuid/setresuid with the root user are false positives.
|
||||
not argumentMayBeRoot(getArgument(0))
|
||||
not argumentMayBeRoot(this.getArgument(0))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class SetuidLikeWrapperCall extends FunctionCall {
|
||||
|
||||
class CallBeforeSetuidFunctionCall extends FunctionCall {
|
||||
CallBeforeSetuidFunctionCall() {
|
||||
getTarget()
|
||||
this.getTarget()
|
||||
.hasGlobalName([
|
||||
"setgid", "setresgid",
|
||||
// Compatibility may require skipping initgroups and setgroups return checks.
|
||||
@@ -52,7 +52,7 @@ class CallBeforeSetuidFunctionCall extends FunctionCall {
|
||||
"initgroups", "setgroups"
|
||||
]) and
|
||||
// setgid/setresgid/etc with the root group are false positives.
|
||||
not argumentMayBeRoot(getArgument(0))
|
||||
not argumentMayBeRoot(this.getArgument(0))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class CallMayNotReturn extends FunctionCall {
|
||||
not exists(this.(ControlFlowNode).getASuccessor())
|
||||
or
|
||||
// call to another function that may not return
|
||||
exists(CallMayNotReturn exit | getTarget() = exit.getEnclosingFunction())
|
||||
exists(CallMayNotReturn exit | this.getTarget() = exit.getEnclosingFunction())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ private predicate exprReleases(Expr e, Expr released, string kind) {
|
||||
}
|
||||
|
||||
class Resource extends MemberVariable {
|
||||
Resource() { not isStatic() }
|
||||
Resource() { not this.isStatic() }
|
||||
|
||||
// Check that an expr is somewhere in this class - does not have to be a constructor
|
||||
predicate inSameClass(Expr e) {
|
||||
@@ -129,7 +129,7 @@ class Resource extends MemberVariable {
|
||||
f instanceof Destructor and f.getDeclaringType() = this.getDeclaringType()
|
||||
or
|
||||
exists(Function mid, FunctionCall fc |
|
||||
calledFromDestructor(mid) and
|
||||
this.calledFromDestructor(mid) and
|
||||
fc.getEnclosingFunction() = mid and
|
||||
fc.getTarget() = f and
|
||||
f.getDeclaringType() = this.getDeclaringType()
|
||||
@@ -137,7 +137,7 @@ class Resource extends MemberVariable {
|
||||
}
|
||||
|
||||
predicate inDestructor(Expr e) {
|
||||
exists(Function f | f = e.getEnclosingFunction() | calledFromDestructor(f))
|
||||
exists(Function f | f = e.getEnclosingFunction() | this.calledFromDestructor(f))
|
||||
}
|
||||
|
||||
predicate acquisitionWithRequiredKind(Assignment acquireAssign, string kind) {
|
||||
|
||||
@@ -29,7 +29,8 @@ class CustomAddFunctionCall extends SimpleRangeAnalysisExpr, FunctionCall {
|
||||
|
||||
class SelfSub extends SimpleRangeAnalysisExpr, SubExpr {
|
||||
SelfSub() {
|
||||
getLeftOperand().(VariableAccess).getTarget() = getRightOperand().(VariableAccess).getTarget()
|
||||
this.getLeftOperand().(VariableAccess).getTarget() =
|
||||
this.getRightOperand().(VariableAccess).getTarget()
|
||||
}
|
||||
|
||||
override float getLowerBounds() { result = 0 }
|
||||
|
||||
@@ -103,11 +103,11 @@ class DiscardedMethodCall extends MethodCall {
|
||||
|
||||
string query() {
|
||||
exists(Method m |
|
||||
m = getTarget() and
|
||||
m = this.getTarget() and
|
||||
not whitelist(m) and
|
||||
// Do not alert on "void wrapper methods", i.e., methods that are inserted
|
||||
// to deliberately ignore the returned value
|
||||
not getEnclosingCallable().getStatementBody().getNumberOfStmts() = 1
|
||||
not this.getEnclosingCallable().getStatementBody().getNumberOfStmts() = 1
|
||||
|
|
||||
important(m) and result = "should always be checked"
|
||||
or
|
||||
|
||||
@@ -4,35 +4,35 @@ import csharp
|
||||
|
||||
private class WaitCall extends MethodCall {
|
||||
WaitCall() {
|
||||
getTarget().hasName("Wait") and
|
||||
getTarget().getDeclaringType().hasQualifiedName("System.Threading.Monitor")
|
||||
this.getTarget().hasName("Wait") and
|
||||
this.getTarget().getDeclaringType().hasQualifiedName("System.Threading.Monitor")
|
||||
}
|
||||
|
||||
Expr getExpr() { result = getArgument(0) }
|
||||
Expr getExpr() { result = this.getArgument(0) }
|
||||
}
|
||||
|
||||
/** An expression statement containing a `Wait` call. */
|
||||
class WaitStmt extends ExprStmt {
|
||||
WaitStmt() { getExpr() instanceof WaitCall }
|
||||
WaitStmt() { this.getExpr() instanceof WaitCall }
|
||||
|
||||
/** Gets the expression that this wait call is waiting on. */
|
||||
Expr getLock() { result = getExpr().(WaitCall).getExpr() }
|
||||
Expr getLock() { result = this.getExpr().(WaitCall).getExpr() }
|
||||
|
||||
/** Gets the variable that this wait call is waiting on, if any. */
|
||||
Variable getWaitVariable() { result.getAnAccess() = getLock() }
|
||||
Variable getWaitVariable() { result.getAnAccess() = this.getLock() }
|
||||
|
||||
/** Holds if this wait call waits on `this`. */
|
||||
predicate isWaitThis() { getLock() instanceof ThisAccess }
|
||||
predicate isWaitThis() { this.getLock() instanceof ThisAccess }
|
||||
|
||||
/** Gets the type that this wait call waits on, if any. */
|
||||
Type getWaitTypeObject() { result = getLock().(TypeofExpr).getTypeAccess().getTarget() }
|
||||
Type getWaitTypeObject() { result = this.getLock().(TypeofExpr).getTypeAccess().getTarget() }
|
||||
}
|
||||
|
||||
private class SynchronizedMethodAttribute extends Attribute {
|
||||
SynchronizedMethodAttribute() {
|
||||
getType().hasQualifiedName("System.Runtime.CompilerServices.MethodImplAttribute") and
|
||||
this.getType().hasQualifiedName("System.Runtime.CompilerServices.MethodImplAttribute") and
|
||||
exists(MemberConstantAccess a, MemberConstant mc |
|
||||
a = getArgument(0) and
|
||||
a = this.getArgument(0) and
|
||||
a.getTarget() = mc and
|
||||
mc.hasName("Synchronized") and
|
||||
mc.getDeclaringType().hasQualifiedName("System.Runtime.CompilerServices.MethodImplOptions")
|
||||
@@ -42,13 +42,13 @@ private class SynchronizedMethodAttribute extends Attribute {
|
||||
|
||||
/** A method with attribute `[MethodImpl(MethodImplOptions.Synchronized)]`. */
|
||||
private class SynchronizedMethod extends Method {
|
||||
SynchronizedMethod() { getAnAttribute() instanceof SynchronizedMethodAttribute }
|
||||
SynchronizedMethod() { this.getAnAttribute() instanceof SynchronizedMethodAttribute }
|
||||
|
||||
/** Holds if this method locks `this`. */
|
||||
predicate isLockThis() { not isStatic() }
|
||||
predicate isLockThis() { not this.isStatic() }
|
||||
|
||||
/** Gets the type that is locked by this method, if any. */
|
||||
Type getLockTypeObject() { isStatic() and result = getDeclaringType() }
|
||||
Type getLockTypeObject() { this.isStatic() and result = this.getDeclaringType() }
|
||||
}
|
||||
|
||||
/** A block that is locked by a `lock` statement. */
|
||||
@@ -68,7 +68,7 @@ abstract class LockedBlock extends BlockStmt {
|
||||
// delegates and lambdas
|
||||
result.getParent() = this
|
||||
or
|
||||
exists(Stmt mid | mid = getALockedStmt() and result.getParent() = mid)
|
||||
exists(Stmt mid | mid = this.getALockedStmt() and result.getParent() = mid)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,66 +59,66 @@ predicate isDocumentationNeeded(Modifiable decl) {
|
||||
|
||||
/** An XML comment containing a `<returns>` tag. */
|
||||
class ReturnsXmlComment extends XmlComment {
|
||||
ReturnsXmlComment() { getOpenTag(_) = "returns" }
|
||||
ReturnsXmlComment() { this.getOpenTag(_) = "returns" }
|
||||
|
||||
/** Holds if the element in this comment has a body at offset `offset`. */
|
||||
predicate hasBody(int offset) { hasBody("returns", offset) }
|
||||
predicate hasBody(int offset) { this.hasBody("returns", offset) }
|
||||
|
||||
/** Holds if the element in this comment is an opening tag at offset `offset`. */
|
||||
predicate isOpenTag(int offset) { "returns" = getOpenTag(offset) }
|
||||
predicate isOpenTag(int offset) { "returns" = this.getOpenTag(offset) }
|
||||
|
||||
/** Holds if the element in this comment is an empty tag at offset `offset`. */
|
||||
predicate isEmptyTag(int offset) { "returns" = getEmptyTag(offset) }
|
||||
predicate isEmptyTag(int offset) { "returns" = this.getEmptyTag(offset) }
|
||||
}
|
||||
|
||||
/** An XML comment containing an `<exception>` tag. */
|
||||
class ExceptionXmlComment extends XmlComment {
|
||||
ExceptionXmlComment() { getOpenTag(_) = "exception" }
|
||||
ExceptionXmlComment() { this.getOpenTag(_) = "exception" }
|
||||
|
||||
/** Gets a `cref` attribute at offset `offset`, if any. */
|
||||
string getCref(int offset) { result = getAttribute("exception", "cref", offset) }
|
||||
string getCref(int offset) { result = this.getAttribute("exception", "cref", offset) }
|
||||
|
||||
/** Holds if the element in this comment has a body at offset `offset`. */
|
||||
predicate hasBody(int offset) { hasBody("exception", offset) }
|
||||
predicate hasBody(int offset) { this.hasBody("exception", offset) }
|
||||
}
|
||||
|
||||
/** An XML comment containing a `<param>` tag. */
|
||||
class ParamXmlComment extends XmlComment {
|
||||
ParamXmlComment() { getOpenTag(_) = "param" }
|
||||
ParamXmlComment() { this.getOpenTag(_) = "param" }
|
||||
|
||||
/** Gets the name of this parameter at offset `offset`. */
|
||||
string getName(int offset) { getAttribute("param", "name", offset) = result }
|
||||
string getName(int offset) { this.getAttribute("param", "name", offset) = result }
|
||||
|
||||
/** Holds if the element in this comment has a body at offset `offset`. */
|
||||
predicate hasBody(int offset) { hasBody("param", offset) }
|
||||
predicate hasBody(int offset) { this.hasBody("param", offset) }
|
||||
}
|
||||
|
||||
/** An XML comment containing a `<typeparam>` tag. */
|
||||
class TypeparamXmlComment extends XmlComment {
|
||||
TypeparamXmlComment() { getOpenTag(_) = "typeparam" }
|
||||
TypeparamXmlComment() { this.getOpenTag(_) = "typeparam" }
|
||||
|
||||
/** Gets the `name` attribute of this element at offset `offset`. */
|
||||
string getName(int offset) { getAttribute("typeparam", "name", offset) = result }
|
||||
string getName(int offset) { this.getAttribute("typeparam", "name", offset) = result }
|
||||
|
||||
/** Holds if the element in this comment has a body at offset `offset`. */
|
||||
predicate hasBody(int offset) { hasBody("typeparam", offset) }
|
||||
predicate hasBody(int offset) { this.hasBody("typeparam", offset) }
|
||||
}
|
||||
|
||||
/** An XML comment containing a `<summary>` tag. */
|
||||
class SummaryXmlComment extends XmlComment {
|
||||
SummaryXmlComment() { getOpenTag(_) = "summary" }
|
||||
SummaryXmlComment() { this.getOpenTag(_) = "summary" }
|
||||
|
||||
/** Holds if the element in this comment has a body at offset `offset`. */
|
||||
predicate hasBody(int offset) { hasBody("summary", offset) }
|
||||
predicate hasBody(int offset) { this.hasBody("summary", offset) }
|
||||
|
||||
/** Holds if the element in this comment has an open tag at offset `offset`. */
|
||||
predicate isOpenTag(int offset) { "summary" = getOpenTag(offset) }
|
||||
predicate isOpenTag(int offset) { "summary" = this.getOpenTag(offset) }
|
||||
|
||||
/** Holds if the element in this comment is empty at offset `offset`. */
|
||||
predicate isEmptyTag(int offset) { "summary" = getEmptyTag(offset) }
|
||||
predicate isEmptyTag(int offset) { "summary" = this.getEmptyTag(offset) }
|
||||
}
|
||||
|
||||
/** An XML comment containing an `<inheritdoc>` tag. */
|
||||
class InheritDocXmlComment extends XmlComment {
|
||||
InheritDocXmlComment() { getOpenTag(_) = "inheritdoc" }
|
||||
InheritDocXmlComment() { this.getOpenTag(_) = "inheritdoc" }
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class NestedForLoopSameVariable extends ForStmt {
|
||||
|
||||
private predicate haveSameCondition() {
|
||||
exists(NestedForConditions config |
|
||||
config.same(getInnerForStmt().getCondition(), getOuterForStmt().getCondition())
|
||||
config.same(this.getInnerForStmt().getCondition(), this.getOuterForStmt().getCondition())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class NestedForLoopSameVariable extends ForStmt {
|
||||
|
||||
/** Holds if the logic is deemed to be correct in limited circumstances. */
|
||||
predicate isSafe() {
|
||||
haveSameUpdate() and haveSameCondition() and not exists(getAnUnguardedAccess())
|
||||
this.haveSameUpdate() and this.haveSameCondition() and not exists(this.getAnUnguardedAccess())
|
||||
}
|
||||
|
||||
/** Gets the result element. */
|
||||
@@ -95,20 +95,20 @@ class NestedForLoopSameVariable extends ForStmt {
|
||||
|
||||
/** Finds elements inside the outer loop that are no longer guarded by the loop invariant. */
|
||||
private ControlFlow::Node getAnUnguardedNode() {
|
||||
hasChild(getOuterForStmt().getBody(), result.getElement()) and
|
||||
hasChild(this.getOuterForStmt().getBody(), result.getElement()) and
|
||||
(
|
||||
result =
|
||||
this.getCondition().(ControlFlowElement).getAControlFlowExitNode().getAFalseSuccessor()
|
||||
or
|
||||
exists(ControlFlow::Node mid | mid = getAnUnguardedNode() |
|
||||
exists(ControlFlow::Node mid | mid = this.getAnUnguardedNode() |
|
||||
mid.getASuccessor() = result and
|
||||
not exists(getAComparisonTest(result.getElement()))
|
||||
not exists(this.getAComparisonTest(result.getElement()))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private VariableAccess getAnUnguardedAccess() {
|
||||
result = getAnUnguardedNode().getElement() and
|
||||
result = this.getAnUnguardedNode().getElement() and
|
||||
result.getTarget() = iteration
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ class SystemWebSessionStateHttpSessionStateClass extends Class {
|
||||
}
|
||||
|
||||
/** Gets the `Abandon` method. */
|
||||
Method getAbandonMethod() { result = getAMethod("Abandon") }
|
||||
Method getAbandonMethod() { result = this.getAMethod("Abandon") }
|
||||
|
||||
/** Gets the `Clear` method. */
|
||||
Method getClearMethod() { result = getAMethod("Clear") }
|
||||
Method getClearMethod() { result = this.getAMethod("Clear") }
|
||||
}
|
||||
|
||||
/** A method that directly or indirectly clears `HttpSessionState`. */
|
||||
|
||||
@@ -47,7 +47,7 @@ abstract class RequiresEncodingConfiguration extends TaintTracking2::Configurati
|
||||
* to be encoded.
|
||||
*/
|
||||
predicate hasWrongEncoding(PathNode encodedValue, PathNode sink, string kind) {
|
||||
hasFlowPath(encodedValue, sink) and
|
||||
this.hasFlowPath(encodedValue, sink) and
|
||||
kind = this.getKind()
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,9 @@ private class MethodUse extends Use, QualifiableExpr {
|
||||
)
|
||||
}
|
||||
|
||||
override Method getDefinition() { result = getQualifiedDeclaration().getUnboundDeclaration() }
|
||||
override Method getDefinition() {
|
||||
result = this.getQualifiedDeclaration().getUnboundDeclaration()
|
||||
}
|
||||
|
||||
override string getUseType() { result = "M" }
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class ArrayInitWithMod extends ArrayInitializer {
|
||||
predicate isInitialized(int entry) { entry in [0 .. this.getNumberOfElements() - 1] }
|
||||
|
||||
predicate isValueInitialized(int elementIndex) {
|
||||
isInitialized(elementIndex) and
|
||||
this.isInitialized(elementIndex) and
|
||||
not exists(this.getElement(elementIndex))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe
|
||||
final override string toString() { result = tag.toString() }
|
||||
|
||||
final override Instruction getAnyDef() {
|
||||
result = unique(Instruction defInstr | hasDefinition(defInstr, _))
|
||||
result = unique(Instruction defInstr | this.hasDefinition(defInstr, _))
|
||||
}
|
||||
|
||||
final override Overlap getDefinitionOverlap() { this.hasDefinition(_, result) }
|
||||
|
||||
@@ -307,7 +307,7 @@ class NonPhiMemoryOperand extends NonPhiOperand, MemoryOperand, TNonPhiMemoryOpe
|
||||
final override string toString() { result = tag.toString() }
|
||||
|
||||
final override Instruction getAnyDef() {
|
||||
result = unique(Instruction defInstr | hasDefinition(defInstr, _))
|
||||
result = unique(Instruction defInstr | this.hasDefinition(defInstr, _))
|
||||
}
|
||||
|
||||
final override Overlap getDefinitionOverlap() { this.hasDefinition(_, result) }
|
||||
|
||||
@@ -173,27 +173,29 @@ private class GuardConditionFromBinaryLogicalOperator extends GuardCondition {
|
||||
private class GuardConditionFromShortCircuitNot extends GuardCondition, LogicalNotExpr {
|
||||
GuardConditionFromShortCircuitNot() {
|
||||
not exists(Instruction inst | this = inst.getAST()) and
|
||||
exists(IRGuardCondition ir | getOperand() = ir.getAST())
|
||||
exists(IRGuardCondition ir | this.getOperand() = ir.getAST())
|
||||
}
|
||||
|
||||
override predicate controls(BasicBlock controlled, boolean testIsTrue) {
|
||||
getOperand().(GuardCondition).controls(controlled, testIsTrue.booleanNot())
|
||||
this.getOperand().(GuardCondition).controls(controlled, testIsTrue.booleanNot())
|
||||
}
|
||||
|
||||
override predicate comparesLt(Expr left, Expr right, int k, boolean isLessThan, boolean testIsTrue) {
|
||||
getOperand().(GuardCondition).comparesLt(left, right, k, isLessThan, testIsTrue.booleanNot())
|
||||
this.getOperand()
|
||||
.(GuardCondition)
|
||||
.comparesLt(left, right, k, isLessThan, testIsTrue.booleanNot())
|
||||
}
|
||||
|
||||
override predicate ensuresLt(Expr left, Expr right, int k, BasicBlock block, boolean isLessThan) {
|
||||
getOperand().(GuardCondition).ensuresLt(left, right, k, block, isLessThan.booleanNot())
|
||||
this.getOperand().(GuardCondition).ensuresLt(left, right, k, block, isLessThan.booleanNot())
|
||||
}
|
||||
|
||||
override predicate comparesEq(Expr left, Expr right, int k, boolean areEqual, boolean testIsTrue) {
|
||||
getOperand().(GuardCondition).comparesEq(left, right, k, areEqual, testIsTrue.booleanNot())
|
||||
this.getOperand().(GuardCondition).comparesEq(left, right, k, areEqual, testIsTrue.booleanNot())
|
||||
}
|
||||
|
||||
override predicate ensuresEq(Expr left, Expr right, int k, BasicBlock block, boolean areEqual) {
|
||||
getOperand().(GuardCondition).ensuresEq(left, right, k, block, areEqual.booleanNot())
|
||||
this.getOperand().(GuardCondition).ensuresEq(left, right, k, block, areEqual.booleanNot())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import semmle.code.csharp.Conversion
|
||||
|
||||
// Avoid printing conversions for type parameters from library
|
||||
class LibraryTypeParameter extends TypeParameter {
|
||||
LibraryTypeParameter() { fromLibrary() }
|
||||
LibraryTypeParameter() { this.fromLibrary() }
|
||||
|
||||
override string toString() { none() }
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import semmle.code.csharp.Conversion
|
||||
|
||||
// Avoid printing conversions for type parameters from library
|
||||
class LibraryTypeParameter extends TypeParameter {
|
||||
LibraryTypeParameter() { fromLibrary() }
|
||||
LibraryTypeParameter() { this.fromLibrary() }
|
||||
|
||||
override string toString() { none() }
|
||||
}
|
||||
|
||||
@@ -1275,7 +1275,7 @@ class MemberRefExpr extends FunctionalExpr, @memberref {
|
||||
*/
|
||||
RefType getReceiverType() {
|
||||
exists(Stmt stmt, Expr resultExpr |
|
||||
stmt = asMethod().getBody().(SingletonBlock).getStmt() and
|
||||
stmt = this.asMethod().getBody().(SingletonBlock).getStmt() and
|
||||
(
|
||||
resultExpr = stmt.(ReturnStmt).getResult()
|
||||
or
|
||||
|
||||
@@ -258,9 +258,9 @@ module Public {
|
||||
/** Gets the field corresponding to this node. */
|
||||
Field getField() { this = TFieldValueNode(result) }
|
||||
|
||||
override string toString() { result = getField().toString() }
|
||||
override string toString() { result = this.getField().toString() }
|
||||
|
||||
override Location getLocation() { result = getField().getLocation() }
|
||||
override Location getLocation() { result = this.getField().getLocation() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -231,18 +231,18 @@ class DataFlowCallable extends TDataFlowCallable {
|
||||
Field asFieldScope() { this = TFieldScope(result) }
|
||||
|
||||
RefType getDeclaringType() {
|
||||
result = asCallable().getDeclaringType() or
|
||||
result = asFieldScope().getDeclaringType()
|
||||
result = this.asCallable().getDeclaringType() or
|
||||
result = this.asFieldScope().getDeclaringType()
|
||||
}
|
||||
|
||||
string toString() {
|
||||
result = asCallable().toString() or
|
||||
result = "Field scope: " + asFieldScope().toString()
|
||||
result = this.asCallable().toString() or
|
||||
result = "Field scope: " + this.asFieldScope().toString()
|
||||
}
|
||||
|
||||
Location getLocation() {
|
||||
result = asCallable().getLocation() or
|
||||
result = asFieldScope().getLocation()
|
||||
result = this.asCallable().getLocation() or
|
||||
result = this.asFieldScope().getLocation()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ class SuppressionComment extends Javadoc {
|
||||
(
|
||||
isEolComment(this)
|
||||
or
|
||||
isNormalComment(this) and exists(int line | hasLocationInfo(_, line, _, line, _))
|
||||
isNormalComment(this) and exists(int line | this.hasLocationInfo(_, line, _, line, _))
|
||||
) and
|
||||
exists(string text | text = getChild(0).getText() |
|
||||
exists(string text | text = this.getChild(0).getText() |
|
||||
// match `lgtm[...]` anywhere in the comment
|
||||
annotation = text.regexpFind("(?i)\\blgtm\\s*\\[[^\\]]*\\]", _, _)
|
||||
or
|
||||
@@ -32,7 +32,7 @@ class SuppressionComment extends Javadoc {
|
||||
/**
|
||||
* Gets the text of this suppression comment.
|
||||
*/
|
||||
string getText() { result = getChild(0).getText() }
|
||||
string getText() { result = this.getChild(0).getText() }
|
||||
|
||||
/** Gets the suppression annotation in this comment. */
|
||||
string getAnnotation() { result = annotation }
|
||||
|
||||
@@ -33,8 +33,11 @@ class SuppressionAnnotation extends SuppressWarningsAnnotation {
|
||||
string getText() { result = text }
|
||||
|
||||
private Annotation getASiblingAnnotation() {
|
||||
result = getAnnotatedElement().(Annotatable).getAnAnnotation() and
|
||||
(getAnnotatedElement() instanceof Callable or getAnnotatedElement() instanceof RefType)
|
||||
result = this.getAnnotatedElement().(Annotatable).getAnAnnotation() and
|
||||
(
|
||||
this.getAnnotatedElement() instanceof Callable or
|
||||
this.getAnnotatedElement() instanceof RefType
|
||||
)
|
||||
}
|
||||
|
||||
private Annotation firstAnnotation() {
|
||||
@@ -50,11 +53,13 @@ class SuppressionAnnotation extends SuppressWarningsAnnotation {
|
||||
* to column `endcolumn` of line `endline` in file `filepath`.
|
||||
*/
|
||||
predicate covers(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
|
||||
if firstAnnotation().hasLocationInfo(filepath, _, _, _, _)
|
||||
if this.firstAnnotation().hasLocationInfo(filepath, _, _, _, _)
|
||||
then
|
||||
getAnnotatedElement().hasLocationInfo(filepath, _, _, endline, endcolumn) and
|
||||
firstAnnotation().hasLocationInfo(filepath, startline, startcolumn, _, _)
|
||||
else getAnnotatedElement().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
this.getAnnotatedElement().hasLocationInfo(filepath, _, _, endline, endcolumn) and
|
||||
this.firstAnnotation().hasLocationInfo(filepath, startline, startcolumn, _, _)
|
||||
else
|
||||
this.getAnnotatedElement()
|
||||
.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
}
|
||||
|
||||
/** Gets the scope of this suppression. */
|
||||
|
||||
@@ -59,7 +59,7 @@ abstract class JdkInternalAccess extends Element {
|
||||
class JdkInternalTypeAccess extends JdkInternalAccess, TypeAccess {
|
||||
JdkInternalTypeAccess() { jdkInternalApi(this.getType().(RefType).getPackage().getName()) }
|
||||
|
||||
override string getAccessedApi() { result = getType().(RefType).getQualifiedName() }
|
||||
override string getAccessedApi() { result = this.getType().(RefType).getQualifiedName() }
|
||||
|
||||
override string getReplacement() {
|
||||
exists(RefType t | this.getType() = t |
|
||||
|
||||
@@ -98,14 +98,14 @@ predicate containerAccess(string package, string type, int p, string signature,
|
||||
class MismatchedContainerAccess extends MethodAccess {
|
||||
MismatchedContainerAccess() {
|
||||
exists(string package, string type, int i |
|
||||
containerAccess(package, type, _, getCallee().getSignature(), i)
|
||||
containerAccess(package, type, _, this.getCallee().getSignature(), i)
|
||||
|
|
||||
getCallee()
|
||||
this.getCallee()
|
||||
.getDeclaringType()
|
||||
.getASupertype*()
|
||||
.getSourceDeclaration()
|
||||
.hasQualifiedName(package, type) and
|
||||
getCallee().getParameter(i).getType() instanceof TypeObject
|
||||
this.getCallee().getParameter(i).getType() instanceof TypeObject
|
||||
)
|
||||
}
|
||||
|
||||
@@ -115,9 +115,9 @@ class MismatchedContainerAccess extends MethodAccess {
|
||||
*/
|
||||
RefType getReceiverElementType(int i) {
|
||||
exists(RefType t, GenericType g, string package, string type, int p |
|
||||
containerAccess(package, type, p, getCallee().getSignature(), i)
|
||||
containerAccess(package, type, p, this.getCallee().getSignature(), i)
|
||||
|
|
||||
t = getCallee().getDeclaringType() and
|
||||
t = this.getCallee().getDeclaringType() and
|
||||
t.getASupertype*().getSourceDeclaration() = g and
|
||||
g.hasQualifiedName(package, type) and
|
||||
indirectlyInstantiates(t, g, p, result)
|
||||
|
||||
@@ -68,14 +68,14 @@ predicate containerModification(string package, string type, int p, string signa
|
||||
class MismatchedContainerModification extends MethodAccess {
|
||||
MismatchedContainerModification() {
|
||||
exists(string package, string type, int i |
|
||||
containerModification(package, type, _, getCallee().getSignature(), i)
|
||||
containerModification(package, type, _, this.getCallee().getSignature(), i)
|
||||
|
|
||||
getCallee()
|
||||
this.getCallee()
|
||||
.getDeclaringType()
|
||||
.getASupertype*()
|
||||
.getSourceDeclaration()
|
||||
.hasQualifiedName(package, type) and
|
||||
getCallee().getParameter(i).getType() instanceof TypeObject
|
||||
this.getCallee().getParameter(i).getType() instanceof TypeObject
|
||||
)
|
||||
}
|
||||
|
||||
@@ -85,9 +85,9 @@ class MismatchedContainerModification extends MethodAccess {
|
||||
*/
|
||||
RefType getReceiverElementType(int i) {
|
||||
exists(RefType t, GenericType g, string package, string type, int p |
|
||||
containerModification(package, type, p, getCallee().getSignature(), i)
|
||||
containerModification(package, type, p, this.getCallee().getSignature(), i)
|
||||
|
|
||||
t = getCallee().getDeclaringType() and
|
||||
t = this.getCallee().getDeclaringType() and
|
||||
t.getASupertype*().getSourceDeclaration() = g and
|
||||
g.hasQualifiedName(package, type) and
|
||||
indirectlyInstantiates(t, g, p, result)
|
||||
|
||||
@@ -35,7 +35,7 @@ class CompareToMethod extends Method {
|
||||
// To implement `Comparable<T>.compareTo`, the parameter must either have type `T` or `Object`.
|
||||
exists(RefType typeArg, Type firstParamType |
|
||||
implementsComparableOn(this.getDeclaringType(), typeArg) and
|
||||
firstParamType = getParameter(0).getType() and
|
||||
firstParamType = this.getParameter(0).getType() and
|
||||
(firstParamType = typeArg or firstParamType instanceof TypeObject)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ class StaticFieldInit extends AssignExpr {
|
||||
|
||||
IfStmt getAnEnclosingNullCheck() {
|
||||
result.getThen().getAChild*() = this.getEnclosingStmt() and
|
||||
result.getCondition().(NullEQExpr).getAChildExpr() = getField().getAnAccess()
|
||||
result.getCondition().(NullEQExpr).getAChildExpr() = this.getField().getAnAccess()
|
||||
}
|
||||
|
||||
IfStmt getNearestNullCheck() {
|
||||
result = getAnEnclosingNullCheck() and
|
||||
not result.getAChild+() = getAnEnclosingNullCheck()
|
||||
result = this.getAnEnclosingNullCheck() and
|
||||
not result.getAChild+() = this.getAnEnclosingNullCheck()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
import java
|
||||
|
||||
class NewStringBufferOrBuilder extends ClassInstanceExpr {
|
||||
NewStringBufferOrBuilder() { getConstructedType() instanceof StringBuildingType }
|
||||
NewStringBufferOrBuilder() { this.getConstructedType() instanceof StringBuildingType }
|
||||
|
||||
string getName() { result = this.getConstructedType().getName() }
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class RangeCallable extends Callable {
|
||||
or
|
||||
not exists(this.getBody()) and
|
||||
(
|
||||
lastParameter().hasLocationInfo(path, _, _, el, ec)
|
||||
this.lastParameter().hasLocationInfo(path, _, _, el, ec)
|
||||
or
|
||||
not exists(this.getAParameter()) and el = elSuper and ec = ecSuper
|
||||
)
|
||||
@@ -33,8 +33,8 @@ class RangeCallable extends Callable {
|
||||
}
|
||||
|
||||
private Parameter lastParameter() {
|
||||
result = getAParameter() and
|
||||
not getAParameter().getPosition() > result.getPosition()
|
||||
result = this.getAParameter() and
|
||||
not this.getAParameter().getPosition() > result.getPosition()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class RangeCallable extends Callable {
|
||||
class RangeRefType extends RefType {
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
exists(int elSuper, int ecSuper | super.hasLocationInfo(path, sl, sc, elSuper, ecSuper) |
|
||||
lastMember().hasLocationInfo(path, _, _, el, ec)
|
||||
this.lastMember().hasLocationInfo(path, _, _, el, ec)
|
||||
or
|
||||
not exists(this.getAMember()) and el = elSuper and ec = ecSuper
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ private predicate arrayIndexOutOfBoundExceptionCaught(ArrayAccess arrayAccess) {
|
||||
*/
|
||||
class PointlessLoop extends WhileStmt {
|
||||
PointlessLoop() {
|
||||
getCondition().(BooleanLiteral).getBooleanValue() = true and
|
||||
this.getCondition().(BooleanLiteral).getBooleanValue() = true and
|
||||
// The only `break` must be the last statement.
|
||||
forall(BreakStmt break | break.(JumpStmt).getTarget() = this |
|
||||
this.getStmt().(BlockStmt).getLastStmt() = break
|
||||
@@ -65,7 +65,7 @@ class CheckableArrayAccess extends ArrayAccess {
|
||||
// Array accesses within loops can make it difficult to verify whether the index is checked
|
||||
// prior to access. Ignore "pointless" loops of the sort found in Juliet test cases.
|
||||
not exists(LoopStmt loop |
|
||||
loop.getBody().getAChild*() = getEnclosingStmt() and
|
||||
loop.getBody().getAChild*() = this.getEnclosingStmt() and
|
||||
not loop instanceof PointlessLoop
|
||||
) and
|
||||
// The possible exception is not caught
|
||||
@@ -76,7 +76,7 @@ class CheckableArrayAccess extends ArrayAccess {
|
||||
* Holds if we believe this indexing expression can throw an `ArrayIndexOutOfBoundsException`.
|
||||
*/
|
||||
predicate canThrowOutOfBounds(Expr index) {
|
||||
index = getIndexExpr() and
|
||||
index = this.getIndexExpr() and
|
||||
not (
|
||||
// There is a condition dominating this expression ensuring that the index is >= 0.
|
||||
lowerBound(index) >= 0 and
|
||||
|
||||
@@ -19,7 +19,7 @@ import ArithmeticCommon
|
||||
import DataFlow::PathGraph
|
||||
|
||||
abstract class ExtremeValueField extends Field {
|
||||
ExtremeValueField() { getType() instanceof IntegralType }
|
||||
ExtremeValueField() { this.getType() instanceof IntegralType }
|
||||
}
|
||||
|
||||
class MinValueField extends ExtremeValueField {
|
||||
@@ -43,7 +43,7 @@ class MaxValueFlowConfig extends DataFlow::Configuration {
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { overflowSink(_, sink.asExpr()) }
|
||||
|
||||
override predicate isBarrierIn(DataFlow::Node n) { isSource(n) }
|
||||
override predicate isBarrierIn(DataFlow::Node n) { this.isSource(n) }
|
||||
|
||||
override predicate isBarrier(DataFlow::Node n) { overflowBarrier(n) }
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class MinValueFlowConfig extends DataFlow::Configuration {
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { underflowSink(_, sink.asExpr()) }
|
||||
|
||||
override predicate isBarrierIn(DataFlow::Node n) { isSource(n) }
|
||||
override predicate isBarrierIn(DataFlow::Node n) { this.isSource(n) }
|
||||
|
||||
override predicate isBarrier(DataFlow::Node n) { underflowBarrier(n) }
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ import semmle.code.java.security.InformationLeak
|
||||
*/
|
||||
class PrintStackTraceMethod extends Method {
|
||||
PrintStackTraceMethod() {
|
||||
getDeclaringType()
|
||||
this.getDeclaringType()
|
||||
.getSourceDeclaration()
|
||||
.getASourceSupertype*()
|
||||
.hasQualifiedName("java.lang", "Throwable") and
|
||||
getName() = "printStackTrace"
|
||||
this.getName() = "printStackTrace"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ import semmle.code.java.dispatch.VirtualDispatch
|
||||
import PathGraph
|
||||
|
||||
private class ShortStringLiteral extends StringLiteral {
|
||||
ShortStringLiteral() { getValue().length() < 100 }
|
||||
ShortStringLiteral() { this.getValue().length() < 100 }
|
||||
}
|
||||
|
||||
class InsecureAlgoLiteral extends ShortStringLiteral {
|
||||
InsecureAlgoLiteral() {
|
||||
// Algorithm identifiers should be at least two characters.
|
||||
getValue().length() > 1 and
|
||||
exists(string s | s = getValue() |
|
||||
this.getValue().length() > 1 and
|
||||
exists(string s | s = this.getValue() |
|
||||
not s.regexpMatch(getSecureAlgorithmRegex()) and
|
||||
// Exclude results covered by another query.
|
||||
not s.regexpMatch(getInsecureAlgorithmRegex())
|
||||
|
||||
@@ -30,7 +30,7 @@ private class PredictableApacheRandomStringUtilsMethodAccess extends MethodAcces
|
||||
private class VulnerableJHipsterRandomUtilClass extends Class {
|
||||
VulnerableJHipsterRandomUtilClass() {
|
||||
// The package name that JHipster generated the 'RandomUtil' class in was dynamic. Thus 'hasQualifiedName' can not be used here.
|
||||
getName() = "RandomUtil"
|
||||
this.getName() = "RandomUtil"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class PermissionsCheckMethodAccess extends MethodAccess, PermissionsConstruction
|
||||
)
|
||||
}
|
||||
|
||||
override Expr getInput() { result = getArgument(0) }
|
||||
override Expr getInput() { result = this.getArgument(0) }
|
||||
}
|
||||
|
||||
class WCPermissionConstruction extends ClassInstanceExpr, PermissionsConstruction {
|
||||
@@ -49,7 +49,7 @@ class WCPermissionConstruction extends ClassInstanceExpr, PermissionsConstructio
|
||||
this.getConstructor().getDeclaringType() instanceof TypeShiroWCPermission
|
||||
}
|
||||
|
||||
override Expr getInput() { result = getArgument(0) }
|
||||
override Expr getInput() { result = this.getArgument(0) }
|
||||
}
|
||||
|
||||
class TaintedPermissionsCheckFlowConfig extends TaintTracking::Configuration {
|
||||
|
||||
@@ -15,7 +15,7 @@ import java
|
||||
/** A variable of type `ReentrantLock`. */
|
||||
class LockVariable extends Variable {
|
||||
LockVariable() {
|
||||
getType().(RefType).hasQualifiedName("java.util.concurrent.locks", "ReentrantLock")
|
||||
this.getType().(RefType).hasQualifiedName("java.util.concurrent.locks", "ReentrantLock")
|
||||
}
|
||||
|
||||
/** An access to method `lock` on this variable. */
|
||||
|
||||
@@ -16,7 +16,7 @@ class ExternalAPI extends Callable {
|
||||
ExternalAPI() { not this.fromSource() }
|
||||
|
||||
/** Holds if this API is not worth supporting */
|
||||
predicate isUninteresting() { isTestLibrary() or isParameterlessConstructor() }
|
||||
predicate isUninteresting() { this.isTestLibrary() or this.isParameterlessConstructor() }
|
||||
|
||||
/** Holds if this API is is a constructor without parameters */
|
||||
predicate isParameterlessConstructor() {
|
||||
@@ -24,7 +24,7 @@ class ExternalAPI extends Callable {
|
||||
}
|
||||
|
||||
/** Holds if this API is part of a common testing library or framework */
|
||||
private predicate isTestLibrary() { getDeclaringType() instanceof TestLibrary }
|
||||
private predicate isTestLibrary() { this.getDeclaringType() instanceof TestLibrary }
|
||||
|
||||
/**
|
||||
* Gets information about the external API in the form expected by the CSV modeling framework.
|
||||
@@ -38,7 +38,9 @@ class ExternalAPI extends Callable {
|
||||
/**
|
||||
* Gets the jar file containing this API. Normalizes the Java Runtime to "rt.jar" despite the presence of modules.
|
||||
*/
|
||||
string jarContainer() { result = containerAsJar(this.getCompilationUnit().getParentContainer*()) }
|
||||
string jarContainer() {
|
||||
result = this.containerAsJar(this.getCompilationUnit().getParentContainer*())
|
||||
}
|
||||
|
||||
private string containerAsJar(Container container) {
|
||||
if container instanceof JarFile then result = container.getBaseName() else result = "rt.jar"
|
||||
@@ -75,12 +77,12 @@ class ExternalAPI extends Callable {
|
||||
predicate isSink() { sinkNode(this.getAnInput(), _) }
|
||||
|
||||
/** Holds if this API is supported by existing CodeQL libraries, that is, it is either a recognized source or sink or has a flow summary. */
|
||||
predicate isSupported() { hasSummary() or isSource() or isSink() }
|
||||
predicate isSupported() { this.hasSummary() or this.isSource() or this.isSink() }
|
||||
}
|
||||
|
||||
private class TestLibrary extends RefType {
|
||||
TestLibrary() {
|
||||
getPackage()
|
||||
this.getPackage()
|
||||
.getName()
|
||||
.matches([
|
||||
"org.junit%", "junit.%", "org.mockito%", "org.assertj%",
|
||||
|
||||
@@ -122,9 +122,9 @@ class CommentedOutCode extends JavadocFirst {
|
||||
}
|
||||
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
path = getLocation().getFile().getAbsolutePath() and
|
||||
sl = getLocation().getStartLine() and
|
||||
sc = getLocation().getStartColumn() and
|
||||
path = this.getLocation().getFile().getAbsolutePath() and
|
||||
sl = this.getLocation().getStartLine() and
|
||||
sc = this.getLocation().getStartColumn() and
|
||||
exists(Location end | end = this.getLastSuccessor().getLocation() |
|
||||
el = end.getEndLine() and
|
||||
ec = end.getEndColumn()
|
||||
|
||||
@@ -21,7 +21,7 @@ predicate typeWithConstantField(RefType t) { exists(ConstantField f | f.getDecla
|
||||
|
||||
class ConstantRefType extends RefType {
|
||||
ConstantRefType() {
|
||||
fromSource() and
|
||||
this.fromSource() and
|
||||
(
|
||||
this instanceof Interface
|
||||
or
|
||||
|
||||
@@ -42,8 +42,8 @@ class TypeEndpointRequest extends Class {
|
||||
/** A call to `EndpointRequest.toAnyEndpoint` method. */
|
||||
class ToAnyEndpointCall extends MethodAccess {
|
||||
ToAnyEndpointCall() {
|
||||
getMethod().hasName("toAnyEndpoint") and
|
||||
getMethod().getDeclaringType() instanceof TypeEndpointRequest
|
||||
this.getMethod().hasName("toAnyEndpoint") and
|
||||
this.getMethod().getDeclaringType() instanceof TypeEndpointRequest
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ class ToAnyEndpointCall extends MethodAccess {
|
||||
*/
|
||||
class RequestMatcherCall extends MethodAccess {
|
||||
RequestMatcherCall() {
|
||||
getMethod().hasName("requestMatcher") and
|
||||
getMethod().getDeclaringType() instanceof TypeHttpSecurity and
|
||||
getArgument(0) instanceof ToAnyEndpointCall
|
||||
this.getMethod().hasName("requestMatcher") and
|
||||
this.getMethod().getDeclaringType() instanceof TypeHttpSecurity and
|
||||
this.getArgument(0) instanceof ToAnyEndpointCall
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,25 +64,25 @@ class RequestMatcherCall extends MethodAccess {
|
||||
*/
|
||||
class RequestMatchersCall extends MethodAccess {
|
||||
RequestMatchersCall() {
|
||||
getMethod().hasName("requestMatchers") and
|
||||
getMethod().getDeclaringType() instanceof TypeHttpSecurity and
|
||||
getArgument(0).(LambdaExpr).getExprBody() instanceof ToAnyEndpointCall
|
||||
this.getMethod().hasName("requestMatchers") and
|
||||
this.getMethod().getDeclaringType() instanceof TypeHttpSecurity and
|
||||
this.getArgument(0).(LambdaExpr).getExprBody() instanceof ToAnyEndpointCall
|
||||
}
|
||||
}
|
||||
|
||||
/** A call to `HttpSecurity.authorizeRequests` method. */
|
||||
class AuthorizeRequestsCall extends MethodAccess {
|
||||
AuthorizeRequestsCall() {
|
||||
getMethod().hasName("authorizeRequests") and
|
||||
getMethod().getDeclaringType() instanceof TypeHttpSecurity
|
||||
this.getMethod().hasName("authorizeRequests") and
|
||||
this.getMethod().getDeclaringType() instanceof TypeHttpSecurity
|
||||
}
|
||||
}
|
||||
|
||||
/** A call to `AuthorizedUrl.permitAll` method. */
|
||||
class PermitAllCall extends MethodAccess {
|
||||
PermitAllCall() {
|
||||
getMethod().hasName("permitAll") and
|
||||
getMethod().getDeclaringType() instanceof TypeAuthorizedUrl
|
||||
this.getMethod().hasName("permitAll") and
|
||||
this.getMethod().getDeclaringType() instanceof TypeAuthorizedUrl
|
||||
}
|
||||
|
||||
/** Holds if `permitAll` is called on request(s) mapped to actuator endpoint(s). */
|
||||
@@ -137,8 +137,8 @@ class PermitAllCall extends MethodAccess {
|
||||
/** A call to `AbstractRequestMatcherRegistry.anyRequest` method. */
|
||||
class AnyRequestCall extends MethodAccess {
|
||||
AnyRequestCall() {
|
||||
getMethod().hasName("anyRequest") and
|
||||
getMethod().getDeclaringType() instanceof TypeAbstractRequestMatcherRegistry
|
||||
this.getMethod().hasName("anyRequest") and
|
||||
this.getMethod().getDeclaringType() instanceof TypeAbstractRequestMatcherRegistry
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,8 +148,8 @@ class AnyRequestCall extends MethodAccess {
|
||||
*/
|
||||
class RegistryRequestMatchersCall extends MethodAccess {
|
||||
RegistryRequestMatchersCall() {
|
||||
getMethod().hasName("requestMatchers") and
|
||||
getMethod().getDeclaringType() instanceof TypeAbstractRequestMatcherRegistry and
|
||||
getAnArgument() instanceof ToAnyEndpointCall
|
||||
this.getMethod().hasName("requestMatchers") and
|
||||
this.getMethod().getDeclaringType() instanceof TypeAbstractRequestMatcherRegistry and
|
||||
this.getAnArgument() instanceof ToAnyEndpointCall
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,25 +84,25 @@ private class TaintPropagatingCall extends Call {
|
||||
}
|
||||
|
||||
private class JakartaType extends RefType {
|
||||
JakartaType() { getPackage().hasName(["javax.el", "jakarta.el"]) }
|
||||
JakartaType() { this.getPackage().hasName(["javax.el", "jakarta.el"]) }
|
||||
}
|
||||
|
||||
private class ELProcessor extends JakartaType {
|
||||
ELProcessor() { hasName("ELProcessor") }
|
||||
ELProcessor() { this.hasName("ELProcessor") }
|
||||
}
|
||||
|
||||
private class ExpressionFactory extends JakartaType {
|
||||
ExpressionFactory() { hasName("ExpressionFactory") }
|
||||
ExpressionFactory() { this.hasName("ExpressionFactory") }
|
||||
}
|
||||
|
||||
private class ValueExpression extends JakartaType {
|
||||
ValueExpression() { hasName("ValueExpression") }
|
||||
ValueExpression() { this.hasName("ValueExpression") }
|
||||
}
|
||||
|
||||
private class MethodExpression extends JakartaType {
|
||||
MethodExpression() { hasName("MethodExpression") }
|
||||
MethodExpression() { this.hasName("MethodExpression") }
|
||||
}
|
||||
|
||||
private class LambdaExpression extends JakartaType {
|
||||
LambdaExpression() { hasName("LambdaExpression") }
|
||||
LambdaExpression() { this.hasName("LambdaExpression") }
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class PythonInterpreter extends RefType {
|
||||
class InterpretExprMethod extends Method {
|
||||
InterpretExprMethod() {
|
||||
this.getDeclaringType().getAnAncestor*() instanceof PythonInterpreter and
|
||||
getName().matches(["exec%", "run%", "eval", "compile"])
|
||||
this.getName().matches(["exec%", "run%", "eval", "compile"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ predicate runsCode(MethodAccess ma, Expr sink) {
|
||||
class LoadClassMethod extends Method {
|
||||
LoadClassMethod() {
|
||||
this.getDeclaringType().getAnAncestor*() instanceof BytecodeLoader and
|
||||
hasName(["makeClass", "makeCode"])
|
||||
this.hasName(["makeClass", "makeCode"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class Py extends RefType {
|
||||
class PyCompileMethod extends Method {
|
||||
PyCompileMethod() {
|
||||
this.getDeclaringType().getAnAncestor*() instanceof Py and
|
||||
getName().matches("compile%")
|
||||
this.getName().matches("compile%")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ import semmle.code.xml.WebXML
|
||||
private class HttpOnlyConfig extends WebContextParameter {
|
||||
HttpOnlyConfig() { this.getParamName().getValue() = "useHttpOnly" }
|
||||
|
||||
string getParamValueElementValue() { result = getParamValue().getValue() }
|
||||
string getParamValueElementValue() { result = this.getParamValue().getValue() }
|
||||
|
||||
predicate isHTTPOnlySet() { getParamValueElementValue().toLowerCase() = "false" }
|
||||
predicate isHTTPOnlySet() { this.getParamValueElementValue().toLowerCase() = "false" }
|
||||
}
|
||||
|
||||
from HttpOnlyConfig config
|
||||
|
||||
@@ -47,7 +47,7 @@ class GetContentIntentConfig extends TaintTracking2::Configuration {
|
||||
or
|
||||
// Allow the wrapped intent created by Intent.getChooser to be consumed
|
||||
// by at the sink:
|
||||
isSink(node) and
|
||||
this.isSink(node) and
|
||||
allowIntentExtrasImplicitRead(node, content)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ abstract private class ProduceCryptoCall extends MethodAccess {
|
||||
/** A method call that produces a MAC. */
|
||||
private class ProduceMacCall extends ProduceCryptoCall {
|
||||
ProduceMacCall() {
|
||||
getMethod().getDeclaringType().hasQualifiedName("javax.crypto", "Mac") and
|
||||
this.getMethod().getDeclaringType().hasQualifiedName("javax.crypto", "Mac") and
|
||||
(
|
||||
getMethod().hasStringSignature(["doFinal()", "doFinal(byte[])"]) and this = output
|
||||
this.getMethod().hasStringSignature(["doFinal()", "doFinal(byte[])"]) and this = output
|
||||
or
|
||||
getMethod().hasStringSignature("doFinal(byte[], int)") and getArgument(0) = output
|
||||
this.getMethod().hasStringSignature("doFinal(byte[], int)") and this.getArgument(0) = output
|
||||
)
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ private class ProduceMacCall extends ProduceCryptoCall {
|
||||
/** A method call that produces a signature. */
|
||||
private class ProduceSignatureCall extends ProduceCryptoCall {
|
||||
ProduceSignatureCall() {
|
||||
getMethod().getDeclaringType().hasQualifiedName("java.security", "Signature") and
|
||||
this.getMethod().getDeclaringType().hasQualifiedName("java.security", "Signature") and
|
||||
(
|
||||
getMethod().hasStringSignature("sign()") and this = output
|
||||
this.getMethod().hasStringSignature("sign()") and this = output
|
||||
or
|
||||
getMethod().hasStringSignature("sign(byte[], int, int)") and getArgument(0) = output
|
||||
this.getMethod().hasStringSignature("sign(byte[], int, int)") and this.getArgument(0) = output
|
||||
)
|
||||
}
|
||||
|
||||
@@ -79,15 +79,15 @@ private class ProduceCiphertextCall extends ProduceCryptoCall {
|
||||
m.hasStringSignature(["doFinal()", "doFinal(byte[])", "doFinal(byte[], int, int)"]) and
|
||||
this = output
|
||||
or
|
||||
m.hasStringSignature("doFinal(byte[], int)") and getArgument(0) = output
|
||||
m.hasStringSignature("doFinal(byte[], int)") and this.getArgument(0) = output
|
||||
or
|
||||
m.hasStringSignature([
|
||||
"doFinal(byte[], int, int, byte[])", "doFinal(byte[], int, int, byte[], int)"
|
||||
]) and
|
||||
getArgument(3) = output
|
||||
this.getArgument(3) = output
|
||||
or
|
||||
m.hasStringSignature("doFinal(ByteBuffer, ByteBuffer)") and
|
||||
getArgument(1) = output
|
||||
this.getArgument(1) = output
|
||||
)
|
||||
) and
|
||||
exists(InitializeEncryptorConfig config |
|
||||
@@ -193,18 +193,18 @@ class CryptoOperationSource extends DataFlow::Node {
|
||||
/** Methods that use a non-constant-time algorithm for comparing inputs. */
|
||||
private class NonConstantTimeEqualsCall extends MethodAccess {
|
||||
NonConstantTimeEqualsCall() {
|
||||
getMethod()
|
||||
this.getMethod()
|
||||
.hasQualifiedName("java.lang", "String", ["equals", "contentEquals", "equalsIgnoreCase"]) or
|
||||
getMethod().hasQualifiedName("java.nio", "ByteBuffer", ["equals", "compareTo"])
|
||||
this.getMethod().hasQualifiedName("java.nio", "ByteBuffer", ["equals", "compareTo"])
|
||||
}
|
||||
}
|
||||
|
||||
/** A static method that uses a non-constant-time algorithm for comparing inputs. */
|
||||
private class NonConstantTimeComparisonCall extends StaticMethodAccess {
|
||||
NonConstantTimeComparisonCall() {
|
||||
getMethod().hasQualifiedName("java.util", "Arrays", ["equals", "deepEquals"]) or
|
||||
getMethod().hasQualifiedName("java.util", "Objects", "deepEquals") or
|
||||
getMethod()
|
||||
this.getMethod().hasQualifiedName("java.util", "Arrays", ["equals", "deepEquals"]) or
|
||||
this.getMethod().hasQualifiedName("java.util", "Objects", "deepEquals") or
|
||||
this.getMethod()
|
||||
.hasQualifiedName("org.apache.commons.lang3", "StringUtils",
|
||||
["equals", "equalsAny", "equalsAnyIgnoreCase", "equalsIgnoreCase"])
|
||||
}
|
||||
|
||||
@@ -21,16 +21,16 @@ class ECGenParameterSpec extends RefType {
|
||||
/** The `init` method declared in `javax.crypto.KeyGenerator`. */
|
||||
class KeyGeneratorInitMethod extends Method {
|
||||
KeyGeneratorInitMethod() {
|
||||
getDeclaringType() instanceof KeyGenerator and
|
||||
hasName("init")
|
||||
this.getDeclaringType() instanceof KeyGenerator and
|
||||
this.hasName("init")
|
||||
}
|
||||
}
|
||||
|
||||
/** The `initialize` method declared in `java.security.KeyPairGenerator`. */
|
||||
class KeyPairGeneratorInitMethod extends Method {
|
||||
KeyPairGeneratorInitMethod() {
|
||||
getDeclaringType() instanceof KeyPairGenerator and
|
||||
hasName("initialize")
|
||||
this.getDeclaringType() instanceof KeyPairGenerator and
|
||||
this.hasName("initialize")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@ class SpringControllerRequestMappingGetMethod extends SpringControllerGetMethod
|
||||
*/
|
||||
class JsonpBuilderExpr extends AddExpr {
|
||||
JsonpBuilderExpr() {
|
||||
getRightOperand().(CompileTimeConstantExpr).getStringValue().regexpMatch("\\);?") and
|
||||
getLeftOperand()
|
||||
this.getRightOperand().(CompileTimeConstantExpr).getStringValue().regexpMatch("\\);?") and
|
||||
this.getLeftOperand()
|
||||
.(AddExpr)
|
||||
.getLeftOperand()
|
||||
.(AddExpr)
|
||||
@@ -73,11 +73,11 @@ class JsonpBuilderExpr extends AddExpr {
|
||||
|
||||
/** Get the jsonp function name of this expression. */
|
||||
Expr getFunctionName() {
|
||||
result = getLeftOperand().(AddExpr).getLeftOperand().(AddExpr).getLeftOperand()
|
||||
result = this.getLeftOperand().(AddExpr).getLeftOperand().(AddExpr).getLeftOperand()
|
||||
}
|
||||
|
||||
/** Get the json data of this expression. */
|
||||
Expr getJsonExpr() { result = getLeftOperand().(AddExpr).getRightOperand() }
|
||||
Expr getJsonExpr() { result = this.getLeftOperand().(AddExpr).getRightOperand() }
|
||||
}
|
||||
|
||||
/** A data flow configuration tracing flow from remote sources to jsonp function name. */
|
||||
|
||||
@@ -29,17 +29,20 @@ private class DefaultTomcatServlet extends WebServletClass {
|
||||
*/
|
||||
class DirectoryListingInitParam extends WebXMLElement {
|
||||
DirectoryListingInitParam() {
|
||||
getName() = "init-param" and
|
||||
getAChild("param-name").getTextValue() = "listings" and
|
||||
this.getName() = "init-param" and
|
||||
this.getAChild("param-name").getTextValue() = "listings" and
|
||||
exists(WebServlet servlet |
|
||||
getParent() = servlet and servlet.getAChild("servlet-class") instanceof DefaultTomcatServlet
|
||||
this.getParent() = servlet and
|
||||
servlet.getAChild("servlet-class") instanceof DefaultTomcatServlet
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the `<param-value>` element (true - enabled, false - disabled)
|
||||
*/
|
||||
predicate isListingEnabled() { getAChild("param-value").getTextValue().toLowerCase() = "true" }
|
||||
predicate isListingEnabled() {
|
||||
this.getAChild("param-value").getTextValue().toLowerCase() = "true"
|
||||
}
|
||||
}
|
||||
|
||||
from DirectoryListingInitParam initp
|
||||
|
||||
@@ -26,8 +26,8 @@ class AndroidRString extends RefType {
|
||||
*/
|
||||
class Uri extends RefType {
|
||||
Uri() {
|
||||
hasQualifiedName("android.net", "Uri") or
|
||||
hasQualifiedName("java.net", "URL")
|
||||
this.hasQualifiedName("android.net", "Uri") or
|
||||
this.hasQualifiedName("java.net", "URL")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ class Uri extends RefType {
|
||||
*/
|
||||
class UriGetHostMethod extends Method {
|
||||
UriGetHostMethod() {
|
||||
getDeclaringType() instanceof Uri and
|
||||
hasName("getHost") and
|
||||
getNumberOfParameters() = 0
|
||||
this.getDeclaringType() instanceof Uri and
|
||||
this.hasName("getHost") and
|
||||
this.getNumberOfParameters() = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class StrutsXMLElement extends XMLElement {
|
||||
/**
|
||||
* Gets the value for this element, with leading and trailing whitespace trimmed.
|
||||
*/
|
||||
string getValue() { result = allCharactersString().trim() }
|
||||
string getValue() { result = this.allCharactersString().trim() }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,10 +31,10 @@ class ConstantParameter extends StrutsXMLElement {
|
||||
/**
|
||||
* Gets the value of the `name` attribute of this `<constant>`.
|
||||
*/
|
||||
string getNameValue() { result = getAttributeValue("name") }
|
||||
string getNameValue() { result = this.getAttributeValue("name") }
|
||||
|
||||
/**
|
||||
* Gets the value of the `value` attribute of this `<constant>`.
|
||||
*/
|
||||
string getValueValue() { result = getAttributeValue("value") }
|
||||
string getValueValue() { result = this.getAttributeValue("value") }
|
||||
}
|
||||
|
||||
48
java/ql/src/external/Clover.qll
vendored
48
java/ql/src/external/Clover.qll
vendored
@@ -46,64 +46,66 @@ class CloverMetrics extends XMLElement {
|
||||
|
||||
private int attr(string name) { result = this.getAttribute(name).getValue().toInt() }
|
||||
|
||||
private float ratio(string name) { result = attr("covered" + name) / attr(name).(float) }
|
||||
private float ratio(string name) {
|
||||
result = this.attr("covered" + name) / this.attr(name).(float)
|
||||
}
|
||||
|
||||
/** Gets the value of the `conditionals` attribute. */
|
||||
int getNumConditionals() { result = attr("conditionals") }
|
||||
int getNumConditionals() { result = this.attr("conditionals") }
|
||||
|
||||
/** Gets the value of the `coveredconditionals` attribute. */
|
||||
int getNumCoveredConditionals() { result = attr("coveredconditionals") }
|
||||
int getNumCoveredConditionals() { result = this.attr("coveredconditionals") }
|
||||
|
||||
/** Gets the value of the `statements` attribute. */
|
||||
int getNumStatements() { result = attr("statements") }
|
||||
int getNumStatements() { result = this.attr("statements") }
|
||||
|
||||
/** Gets the value of the `coveredstatements` attribute. */
|
||||
int getNumCoveredStatements() { result = attr("coveredstatements") }
|
||||
int getNumCoveredStatements() { result = this.attr("coveredstatements") }
|
||||
|
||||
/** Gets the value of the `elements` attribute. */
|
||||
int getNumElements() { result = attr("elements") }
|
||||
int getNumElements() { result = this.attr("elements") }
|
||||
|
||||
/** Gets the value of the `coveredelements` attribute. */
|
||||
int getNumCoveredElements() { result = attr("coveredelements") }
|
||||
int getNumCoveredElements() { result = this.attr("coveredelements") }
|
||||
|
||||
/** Gets the value of the `methods` attribute. */
|
||||
int getNumMethods() { result = attr("methods") }
|
||||
int getNumMethods() { result = this.attr("methods") }
|
||||
|
||||
/** Gets the value of the `coveredmethods` attribute. */
|
||||
int getNumCoveredMethods() { result = attr("coveredmethods") }
|
||||
int getNumCoveredMethods() { result = this.attr("coveredmethods") }
|
||||
|
||||
/** Gets the value of the `loc` attribute. */
|
||||
int getNumLoC() { result = attr("loc") }
|
||||
int getNumLoC() { result = this.attr("loc") }
|
||||
|
||||
/** Gets the value of the `ncloc` attribute. */
|
||||
int getNumNonCommentedLoC() { result = attr("ncloc") }
|
||||
int getNumNonCommentedLoC() { result = this.attr("ncloc") }
|
||||
|
||||
/** Gets the value of the `packages` attribute. */
|
||||
int getNumPackages() { result = attr("packages") }
|
||||
int getNumPackages() { result = this.attr("packages") }
|
||||
|
||||
/** Gets the value of the `files` attribute. */
|
||||
int getNumFiles() { result = attr("files") }
|
||||
int getNumFiles() { result = this.attr("files") }
|
||||
|
||||
/** Gets the value of the `classes` attribute. */
|
||||
int getNumClasses() { result = attr("classes") }
|
||||
int getNumClasses() { result = this.attr("classes") }
|
||||
|
||||
/** Gets the value of the `complexity` attribute. */
|
||||
int getCloverComplexity() { result = attr("complexity") }
|
||||
int getCloverComplexity() { result = this.attr("complexity") }
|
||||
|
||||
/** Gets the ratio of the `coveredconditionals` attribute over the `conditionals` attribute. */
|
||||
float getConditionalCoverage() { result = ratio("conditionals") }
|
||||
float getConditionalCoverage() { result = this.ratio("conditionals") }
|
||||
|
||||
/** Gets the ratio of the `coveredstatements` attribute over the `statements` attribute. */
|
||||
float getStatementCoverage() { result = ratio("statements") }
|
||||
float getStatementCoverage() { result = this.ratio("statements") }
|
||||
|
||||
/** Gets the ratio of the `coveredelements` attribute over the `elements` attribute. */
|
||||
float getElementCoverage() { result = ratio("elements") }
|
||||
float getElementCoverage() { result = this.ratio("elements") }
|
||||
|
||||
/** Gets the ratio of the `coveredmethods` attribute over the `methods` attribute. */
|
||||
float getMethodCoverage() { result = ratio("methods") }
|
||||
float getMethodCoverage() { result = this.ratio("methods") }
|
||||
|
||||
/** Gets the ratio of the `ncloc` attribute over the `loc` attribute. */
|
||||
float getNonCommentedLoCRatio() { result = attr("ncloc") / attr("loc") }
|
||||
float getNonCommentedLoCRatio() { result = this.attr("ncloc") / this.attr("loc") }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +126,7 @@ class CloverPackage extends CloverMetricsContainer {
|
||||
}
|
||||
|
||||
/** Gets the Java package for this Clover package. */
|
||||
Package getRealPackage() { result.hasName(getAttribute("name").getValue()) }
|
||||
Package getRealPackage() { result.hasName(this.getAttribute("name").getValue()) }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,13 +149,13 @@ class CloverClass extends CloverMetricsContainer {
|
||||
}
|
||||
|
||||
/** Gets the Clover package for this Clover class. */
|
||||
CloverPackage getPackage() { result = getParent().(CloverFile).getParent() }
|
||||
CloverPackage getPackage() { result = this.getParent().(CloverFile).getParent() }
|
||||
|
||||
/** Gets the Java type for this Clover class. */
|
||||
RefType getRealClass() {
|
||||
result
|
||||
.hasQualifiedName(this.getPackage().getAttribute("name").getValue(),
|
||||
getAttribute("name").getValue())
|
||||
this.getAttribute("name").getValue())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ abstract private class GeneratedType extends ClassOrInterface {
|
||||
result =
|
||||
this.stubAbstractModifier() + this.stubStaticModifier() + this.stubAccessibilityModifier() +
|
||||
this.stubKeyword() + " " + this.getName() + stubGenericArguments(this, true) +
|
||||
stubBaseTypesString() + "\n{\n" + stubMembers() + "}"
|
||||
this.stubBaseTypesString() + "\n{\n" + this.stubMembers() + "}"
|
||||
}
|
||||
|
||||
private RefType getAnInterestingBaseType() {
|
||||
@@ -51,19 +51,19 @@ abstract private class GeneratedType extends ClassOrInterface {
|
||||
}
|
||||
|
||||
private string stubBaseTypesString() {
|
||||
if exists(getAnInterestingBaseType())
|
||||
if exists(this.getAnInterestingBaseType())
|
||||
then
|
||||
exists(string cls, string interface, string int_kw | result = cls + int_kw + interface |
|
||||
(
|
||||
if exists(getAnInterestingBaseType().(Class))
|
||||
then cls = " extends " + stubTypeName(getAnInterestingBaseType().(Class))
|
||||
if exists(this.getAnInterestingBaseType().(Class))
|
||||
then cls = " extends " + stubTypeName(this.getAnInterestingBaseType().(Class))
|
||||
else cls = ""
|
||||
) and
|
||||
(
|
||||
if exists(getAnInterestingBaseType().(Interface))
|
||||
if exists(this.getAnInterestingBaseType().(Interface))
|
||||
then (
|
||||
(if this instanceof Class then int_kw = " implements " else int_kw = " extends ") and
|
||||
interface = concat(stubTypeName(getAnInterestingBaseType().(Interface)), ", ")
|
||||
interface = concat(stubTypeName(this.getAnInterestingBaseType().(Interface)), ", ")
|
||||
) else (
|
||||
int_kw = "" and interface = ""
|
||||
)
|
||||
@@ -96,15 +96,15 @@ abstract private class GeneratedType extends ClassOrInterface {
|
||||
}
|
||||
|
||||
final Type getAGeneratedType() {
|
||||
result = getAnInterestingBaseType()
|
||||
result = this.getAnInterestingBaseType()
|
||||
or
|
||||
result = getAGeneratedMember().(Callable).getReturnType()
|
||||
result = this.getAGeneratedMember().(Callable).getReturnType()
|
||||
or
|
||||
result = getAGeneratedMember().(Callable).getAParameter().getType()
|
||||
result = this.getAGeneratedMember().(Callable).getAParameter().getType()
|
||||
or
|
||||
result = getAGeneratedMember().(Field).getType()
|
||||
result = this.getAGeneratedMember().(Field).getType()
|
||||
or
|
||||
result = getAGeneratedMember().(NestedType)
|
||||
result = this.getAGeneratedMember().(NestedType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ class GeneratedTopLevel extends TopLevelType {
|
||||
|
||||
private string stubAnImport() {
|
||||
exists(RefType t, string pkg, string name |
|
||||
t = getAnImportedType() and
|
||||
t = this.getAnImportedType() and
|
||||
(t instanceof Class or t instanceof Interface) and
|
||||
t.hasQualifiedName(pkg, name) and
|
||||
t != this and
|
||||
@@ -459,7 +459,7 @@ class GeneratedTopLevel extends TopLevelType {
|
||||
)
|
||||
}
|
||||
|
||||
private string stubImports() { result = concat(stubAnImport()) + "\n" }
|
||||
private string stubImports() { result = concat(this.stubAnImport()) + "\n" }
|
||||
|
||||
private string stubPackage() {
|
||||
if this.getPackage().getName() != ""
|
||||
@@ -474,6 +474,8 @@ class GeneratedTopLevel extends TopLevelType {
|
||||
|
||||
/** Creates a full stub for the file containing this type. */
|
||||
string stubFile() {
|
||||
result = stubComment() + stubPackage() + stubImports() + this.(GeneratedType).getStub() + "\n"
|
||||
result =
|
||||
this.stubComment() + this.stubPackage() + this.stubImports() + this.(GeneratedType).getStub() +
|
||||
"\n"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,9 +140,9 @@ class RegExpRoot extends RegExpTerm {
|
||||
// there is at least one repetition
|
||||
getRoot(any(InfiniteRepetitionQuantifier q)) = this and
|
||||
// is actually used as a RegExp
|
||||
isUsedAsRegExp() and
|
||||
this.isUsedAsRegExp() and
|
||||
// not excluded for library specific reasons
|
||||
not isExcluded(getRootTerm().getParent())
|
||||
not isExcluded(this.getRootTerm().getParent())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ abstract class CharacterClass extends InputSymbol {
|
||||
/**
|
||||
* Gets a character matched by this character class.
|
||||
*/
|
||||
string choose() { result = getARelevantChar() and matches(result) }
|
||||
string choose() { result = this.getARelevantChar() and this.matches(result) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,7 +76,7 @@ class PrintAstNode extends TPrintAstNode {
|
||||
/**
|
||||
* Gets a child of this node.
|
||||
*/
|
||||
final PrintAstNode getAChild() { result = getChild(_) }
|
||||
final PrintAstNode getAChild() { result = this.getChild(_) }
|
||||
|
||||
/**
|
||||
* Gets the parent of this node, if any.
|
||||
@@ -94,7 +94,7 @@ class PrintAstNode extends TPrintAstNode {
|
||||
*/
|
||||
string getProperty(string key) {
|
||||
key = "semmle.label" and
|
||||
result = toString()
|
||||
result = this.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +103,7 @@ class PrintAstNode extends TPrintAstNode {
|
||||
* this.
|
||||
*/
|
||||
string getChildEdgeLabel(int childIndex) {
|
||||
exists(getChild(childIndex)) and
|
||||
exists(this.getChild(childIndex)) and
|
||||
result = childIndex.toString()
|
||||
}
|
||||
}
|
||||
@@ -157,13 +157,13 @@ class AstElementNode extends PrintAstNode, TElementNode {
|
||||
|
||||
override PrintAstNode getChild(int childIndex) {
|
||||
exists(AstNode el | result.(AstElementNode).getAstNode() = el |
|
||||
el = this.getChildNode(childIndex) and not el = getStmtList(_, _).getAnItem()
|
||||
el = this.getChildNode(childIndex) and not el = this.getStmtList(_, _).getAnItem()
|
||||
)
|
||||
or
|
||||
// displaying all `StmtList` after the other children.
|
||||
exists(int offset | offset = 1 + max([0, any(int index | exists(this.getChildNode(index)))]) |
|
||||
exists(int index | childIndex = index + offset |
|
||||
result.(StmtListNode).getList() = getStmtList(index, _)
|
||||
result.(StmtListNode).getList() = this.getStmtList(index, _)
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -299,7 +299,7 @@ class StmtListNode extends PrintAstNode, TStmtListNode {
|
||||
|
||||
private string getLabel() { this.getList() = any(AstElementNode node).getStmtList(_, result) }
|
||||
|
||||
override string toString() { result = "(StmtList) " + getLabel() }
|
||||
override string toString() { result = "(StmtList) " + this.getLabel() }
|
||||
|
||||
override PrintAstNode getChild(int childIndex) {
|
||||
exists(AstNode el | result.(AstElementNode).getAstNode() = el | el = list.getItem(childIndex))
|
||||
|
||||
@@ -86,7 +86,7 @@ class SsaVariable extends @py_ssa_var {
|
||||
|
||||
/** Gets the incoming edges for a Phi node. */
|
||||
private BasicBlock getAPredecessorBlockForPhi() {
|
||||
exists(getAPhiInput()) and
|
||||
exists(this.getAPhiInput()) and
|
||||
result.getASuccessor() = this.getDefinition().getBasicBlock()
|
||||
}
|
||||
|
||||
|
||||
@@ -503,7 +503,7 @@ class TaintTrackingImplementation extends string {
|
||||
TaintKind kind, string edgeLabel
|
||||
) {
|
||||
exists(PythonFunctionValue init, EssaVariable self, TaintTrackingContext callee |
|
||||
instantiationCall(node.asCfgNode(), src, init, context, callee) and
|
||||
this.instantiationCall(node.asCfgNode(), src, init, context, callee) and
|
||||
this.(EssaTaintTracking).taintedDefinition(_, self.getDefinition(), callee, path, kind) and
|
||||
self.getSourceVariable().(Variable).isSelf() and
|
||||
BaseFlow::reaches_exit(self) and
|
||||
@@ -789,9 +789,9 @@ private class EssaTaintTracking extends string {
|
||||
TaintTrackingNode src, PyEdgeRefinement defn, TaintTrackingContext context, AttributePath path,
|
||||
TaintKind kind
|
||||
) {
|
||||
taintedPiNodeOneway(src, defn, context, path, kind)
|
||||
this.taintedPiNodeOneway(src, defn, context, path, kind)
|
||||
or
|
||||
taintedPiNodeBothways(src, defn, context, path, kind)
|
||||
this.taintedPiNodeBothways(src, defn, context, path, kind)
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
@@ -802,7 +802,7 @@ private class EssaTaintTracking extends string {
|
||||
exists(DataFlow::Node srcnode, ControlFlowNode use |
|
||||
src = TTaintTrackingNode_(srcnode, context, path, kind, this) and
|
||||
not this.(TaintTracking::Configuration).isBarrierTest(defn.getTest(), defn.getSense()) and
|
||||
defn.getSense() = testEvaluates(defn, defn.getTest(), use, src)
|
||||
defn.getSense() = this.testEvaluates(defn, defn.getTest(), use, src)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -898,7 +898,7 @@ private class EssaTaintTracking extends string {
|
||||
)
|
||||
)
|
||||
or
|
||||
result = testEvaluates(defn, not_operand(test), use, src).booleanNot()
|
||||
result = this.testEvaluates(defn, not_operand(test), use, src).booleanNot()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -911,7 +911,7 @@ private class EssaTaintTracking extends string {
|
||||
use = test
|
||||
or
|
||||
exists(ControlFlowNode notuse |
|
||||
boolean_filter(test, notuse) and
|
||||
this.boolean_filter(test, notuse) and
|
||||
use = not_operand(notuse)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -89,7 +89,7 @@ class PythonFunctionObjectInternal extends CallableObjectInternal, TPythonFuncti
|
||||
origin = CfgOrigin::fromCfgNode(forigin)
|
||||
)
|
||||
or
|
||||
procedureReturnsNone(callee, obj, origin)
|
||||
this.procedureReturnsNone(callee, obj, origin)
|
||||
}
|
||||
|
||||
private predicate procedureReturnsNone(
|
||||
|
||||
@@ -27,7 +27,8 @@ class PropertyInternal extends ObjectInternal, TProperty {
|
||||
or
|
||||
// x = property(getter, setter, deleter)
|
||||
exists(ControlFlowNode setter_arg |
|
||||
setter_arg = getCallNode().getArg(1) or setter_arg = getCallNode().getArgByName("fset")
|
||||
setter_arg = this.getCallNode().getArg(1) or
|
||||
setter_arg = this.getCallNode().getArgByName("fset")
|
||||
|
|
||||
PointsToInternal::pointsTo(setter_arg, this.getContext(), result, _)
|
||||
)
|
||||
@@ -43,7 +44,8 @@ class PropertyInternal extends ObjectInternal, TProperty {
|
||||
or
|
||||
// x = property(getter, setter, deleter)
|
||||
exists(ControlFlowNode deleter_arg |
|
||||
deleter_arg = getCallNode().getArg(2) or deleter_arg = getCallNode().getArgByName("fdel")
|
||||
deleter_arg = this.getCallNode().getArg(2) or
|
||||
deleter_arg = this.getCallNode().getArgByName("fdel")
|
||||
|
|
||||
PointsToInternal::pointsTo(deleter_arg, this.getContext(), result, _)
|
||||
)
|
||||
|
||||
@@ -138,8 +138,8 @@ class Value extends TObject {
|
||||
* The result can be `none()`, but never both `true` and `false`.
|
||||
*/
|
||||
boolean getDefiniteBooleanValue() {
|
||||
result = getABooleanValue() and
|
||||
not (getABooleanValue() = true and getABooleanValue() = false)
|
||||
result = this.getABooleanValue() and
|
||||
not (this.getABooleanValue() = true and this.getABooleanValue() = false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class ModuleValue extends Value instanceof ModuleObjectInternal {
|
||||
|
||||
/** When used (exclusively) as a script (will not include normal modules that can also be run as a script) */
|
||||
predicate isUsedAsScript() {
|
||||
not isUsedAsModule() and
|
||||
not this.isUsedAsModule() and
|
||||
(
|
||||
not this.getPath().getExtension() = "py"
|
||||
or
|
||||
|
||||
@@ -75,9 +75,9 @@ class ClassList extends TClassList {
|
||||
this = Empty() and result = ""
|
||||
or
|
||||
exists(ClassObjectInternal head | head = this.getHead() |
|
||||
this.getTail() = Empty() and result = className(head)
|
||||
this.getTail() = Empty() and result = this.className(head)
|
||||
or
|
||||
this.getTail() != Empty() and result = className(head) + ", " + this.getTail().contents()
|
||||
this.getTail() != Empty() and result = this.className(head) + ", " + this.getTail().contents()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -331,9 +331,9 @@ private class ClassListList extends TClassListList {
|
||||
|
||||
ClassObjectInternal bestMergeCandidate(int n) {
|
||||
exists(ClassObjectInternal head | head = this.getItem(n).getHead() |
|
||||
legalMergeCandidate(head) and result = head
|
||||
this.legalMergeCandidate(head) and result = head
|
||||
or
|
||||
illegalMergeCandidate(head) and result = this.bestMergeCandidate(n + 1)
|
||||
this.illegalMergeCandidate(head) and result = this.bestMergeCandidate(n + 1)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ abstract class RegexString extends Expr {
|
||||
// 32-bit hex value \Uhhhhhhhh
|
||||
this.getChar(start + 1) = "U" and end = start + 10
|
||||
or
|
||||
escapedName(start, end)
|
||||
this.escapedName(start, end)
|
||||
or
|
||||
// escape not handled above, update when adding a new case
|
||||
not this.getChar(start + 1) in ["x", "u", "U", "N"] and
|
||||
|
||||
@@ -140,9 +140,9 @@ class RegExpRoot extends RegExpTerm {
|
||||
// there is at least one repetition
|
||||
getRoot(any(InfiniteRepetitionQuantifier q)) = this and
|
||||
// is actually used as a RegExp
|
||||
isUsedAsRegExp() and
|
||||
this.isUsedAsRegExp() and
|
||||
// not excluded for library specific reasons
|
||||
not isExcluded(getRootTerm().getParent())
|
||||
not isExcluded(this.getRootTerm().getParent())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ abstract class CharacterClass extends InputSymbol {
|
||||
/**
|
||||
* Gets a character matched by this character class.
|
||||
*/
|
||||
string choose() { result = getARelevantChar() and matches(result) }
|
||||
string choose() { result = this.getARelevantChar() and this.matches(result) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -281,19 +281,19 @@ class UrlsplitUrlparseTempSanitizer extends Sanitizer {
|
||||
or
|
||||
full_use.(AttrNode).getObject() = test.getInput().getAUse()
|
||||
|
|
||||
clears_taint(full_use, test.getTest(), test.getSense())
|
||||
this.clears_taint(full_use, test.getTest(), test.getSense())
|
||||
)
|
||||
}
|
||||
|
||||
private predicate clears_taint(ControlFlowNode tainted, ControlFlowNode test, boolean sense) {
|
||||
test_equality_with_const(test, tainted, sense)
|
||||
this.test_equality_with_const(test, tainted, sense)
|
||||
or
|
||||
test_in_const_seq(test, tainted, sense)
|
||||
this.test_in_const_seq(test, tainted, sense)
|
||||
or
|
||||
test.(UnaryExprNode).getNode().getOp() instanceof Not and
|
||||
exists(ControlFlowNode nested_test |
|
||||
nested_test = test.(UnaryExprNode).getOperand() and
|
||||
clears_taint(tainted, nested_test, sense.booleanNot())
|
||||
this.clears_taint(tainted, nested_test, sense.booleanNot())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,30 +33,30 @@ class ClassObject extends Object {
|
||||
}
|
||||
|
||||
/** Gets the short (unqualified) name of this class */
|
||||
string getName() { result = theClass().getName() }
|
||||
string getName() { result = this.theClass().getName() }
|
||||
|
||||
/**
|
||||
* Gets the qualified name for this class.
|
||||
* Should return the same name as the `__qualname__` attribute on classes in Python 3.
|
||||
*/
|
||||
string getQualifiedName() {
|
||||
result = theClass().getBuiltin().getName()
|
||||
result = this.theClass().getBuiltin().getName()
|
||||
or
|
||||
result = theClass().(PythonClassObjectInternal).getScope().getQualifiedName()
|
||||
result = this.theClass().(PythonClassObjectInternal).getScope().getQualifiedName()
|
||||
}
|
||||
|
||||
/** Gets the nth base class of this class */
|
||||
Object getBaseType(int n) { result = Types::getBase(theClass(), n).getSource() }
|
||||
Object getBaseType(int n) { result = Types::getBase(this.theClass(), n).getSource() }
|
||||
|
||||
/** Gets a base class of this class */
|
||||
Object getABaseType() { result = this.getBaseType(_) }
|
||||
|
||||
/** Whether this class has a base class */
|
||||
predicate hasABase() { exists(Types::getBase(theClass(), _)) }
|
||||
predicate hasABase() { exists(Types::getBase(this.theClass(), _)) }
|
||||
|
||||
/** Gets a super class of this class (includes transitive super classes) */
|
||||
ClassObject getASuperType() {
|
||||
result = Types::getMro(theClass()).getTail().getAnItem().getSource()
|
||||
result = Types::getMro(this.theClass()).getTail().getAnItem().getSource()
|
||||
}
|
||||
|
||||
/** Gets a super class of this class (includes transitive super classes) or this class */
|
||||
@@ -66,13 +66,13 @@ class ClassObject extends Object {
|
||||
* Whether this class is a new style class.
|
||||
* A new style class is one that implicitly or explicitly inherits from `object`.
|
||||
*/
|
||||
predicate isNewStyle() { Types::isNewStyle(theClass()) }
|
||||
predicate isNewStyle() { Types::isNewStyle(this.theClass()) }
|
||||
|
||||
/**
|
||||
* Whether this class is an old style class.
|
||||
* An old style class is one that does not inherit from `object`.
|
||||
*/
|
||||
predicate isOldStyle() { Types::isOldStyle(theClass()) }
|
||||
predicate isOldStyle() { Types::isOldStyle(this.theClass()) }
|
||||
|
||||
/**
|
||||
* Whether this class is a legal exception class.
|
||||
@@ -92,14 +92,14 @@ class ClassObject extends Object {
|
||||
/** Returns an attribute declared on this class (not on a super-class) */
|
||||
Object declaredAttribute(string name) {
|
||||
exists(ObjectInternal val |
|
||||
Types::declaredAttribute(theClass(), name, val, _) and
|
||||
Types::declaredAttribute(this.theClass(), name, val, _) and
|
||||
result = val.getSource()
|
||||
)
|
||||
}
|
||||
|
||||
/** Returns an attribute declared on this class (not on a super-class) */
|
||||
predicate declaresAttribute(string name) {
|
||||
theClass().getClassDeclaration().declaresAttribute(name)
|
||||
this.theClass().getClassDeclaration().declaresAttribute(name)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,18 +108,18 @@ class ClassObject extends Object {
|
||||
*/
|
||||
Object lookupAttribute(string name) {
|
||||
exists(ObjectInternal val |
|
||||
theClass().lookup(name, val, _) and
|
||||
this.theClass().lookup(name, val, _) and
|
||||
result = val.getSource()
|
||||
)
|
||||
}
|
||||
|
||||
ClassList getMro() { result = Types::getMro(theClass()) }
|
||||
ClassList getMro() { result = Types::getMro(this.theClass()) }
|
||||
|
||||
/** Looks up an attribute by searching this class' MRO starting at `start` */
|
||||
Object lookupMro(ClassObject start, string name) {
|
||||
exists(ClassObjectInternal other, ClassObjectInternal decl, ObjectInternal val |
|
||||
other.getSource() = start and
|
||||
decl = Types::getMro(theClass()).startingAt(other).findDeclaringClass(name) and
|
||||
decl = Types::getMro(this.theClass()).startingAt(other).findDeclaringClass(name) and
|
||||
Types::declaredAttribute(decl, name, val, _) and
|
||||
result = val.getSource()
|
||||
)
|
||||
@@ -133,7 +133,7 @@ class ClassObject extends Object {
|
||||
/** Whether the named attribute refers to the object, class and origin */
|
||||
predicate attributeRefersTo(string name, Object obj, ClassObject cls, ControlFlowNode origin) {
|
||||
exists(ObjectInternal val, CfgOrigin valorig |
|
||||
theClass().lookup(name, val, valorig) and
|
||||
this.theClass().lookup(name, val, valorig) and
|
||||
obj = val.getSource() and
|
||||
cls = val.getClass().getSource() and
|
||||
origin = valorig.toCfgNode()
|
||||
@@ -141,7 +141,7 @@ class ClassObject extends Object {
|
||||
}
|
||||
|
||||
/** Whether this class has a attribute named `name`, either declared or inherited. */
|
||||
predicate hasAttribute(string name) { theClass().hasAttribute(name) }
|
||||
predicate hasAttribute(string name) { this.theClass().hasAttribute(name) }
|
||||
|
||||
/**
|
||||
* Whether it is impossible to know all the attributes of this class. Usually because it is
|
||||
@@ -162,7 +162,7 @@ class ClassObject extends Object {
|
||||
|
||||
/** Gets the metaclass for this class */
|
||||
ClassObject getMetaClass() {
|
||||
result = theClass().getClass().getSource() and
|
||||
result = this.theClass().getClass().getSource() and
|
||||
not this.failedInference()
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ class ClassObject extends Object {
|
||||
ControlFlowNode declaredMetaClass() { result = this.getPyClass().getMetaClass().getAFlowNode() }
|
||||
|
||||
/** Has type inference failed to compute the full class hierarchy for this class for the reason given. */
|
||||
predicate failedInference(string reason) { Types::failedInference(theClass(), reason) }
|
||||
predicate failedInference(string reason) { Types::failedInference(this.theClass(), reason) }
|
||||
|
||||
/** Has type inference failed to compute the full class hierarchy for this class */
|
||||
predicate failedInference() { this.failedInference(_) }
|
||||
@@ -205,7 +205,7 @@ class ClassObject extends Object {
|
||||
|
||||
/** This class is only instantiated at one place in the code */
|
||||
private predicate hasStaticallyUniqueInstance() {
|
||||
strictcount(SpecificInstanceInternal inst | inst.getClass() = theClass()) = 1
|
||||
strictcount(SpecificInstanceInternal inst | inst.getClass() = this.theClass()) = 1
|
||||
}
|
||||
|
||||
ImportTimeScope getImportTimeScope() { result = this.getPyClass() }
|
||||
@@ -221,7 +221,7 @@ class ClassObject extends Object {
|
||||
ClassObject nextInMro(ClassObject sup) {
|
||||
exists(ClassObjectInternal other |
|
||||
other.getSource() = sup and
|
||||
result = Types::getMro(theClass()).startingAt(other).getTail().getHead().getSource()
|
||||
result = Types::getMro(this.theClass()).startingAt(other).getTail().getHead().getSource()
|
||||
) and
|
||||
not this.failedInference()
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class RaisingNode extends ControlFlowNode {
|
||||
or
|
||||
exists(FunctionObject func | this = func.getACall() | result = func.getARaisedType())
|
||||
or
|
||||
result = systemExitRaise_objectapi()
|
||||
result = this.systemExitRaise_objectapi()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ class RaisingNode extends ControlFlowNode {
|
||||
or
|
||||
exists(FunctionValue func | this = func.getACall() | result = func.getARaisedType())
|
||||
or
|
||||
result = systemExitRaise()
|
||||
result = this.systemExitRaise()
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
|
||||
@@ -137,7 +137,7 @@ class ReModulePointToExtension extends PointsToExtension {
|
||||
sre_constants.attribute("SRE_FLAG_" + flag, value, orig) and
|
||||
origin = orig.asCfgNodeOrHere(this)
|
||||
) and
|
||||
pointsTo_helper(context)
|
||||
this.pointsTo_helper(context)
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
|
||||
@@ -36,22 +36,22 @@ abstract class FunctionObject extends Object {
|
||||
abstract string descriptiveString();
|
||||
|
||||
/** Gets a call-site from where this function is called as a function */
|
||||
CallNode getAFunctionCall() { result.getFunction().inferredValue() = theCallable() }
|
||||
CallNode getAFunctionCall() { result.getFunction().inferredValue() = this.theCallable() }
|
||||
|
||||
/** Gets a call-site from where this function is called as a method */
|
||||
CallNode getAMethodCall() {
|
||||
exists(BoundMethodObjectInternal bm |
|
||||
result.getFunction().inferredValue() = bm and
|
||||
bm.getFunction() = theCallable()
|
||||
bm.getFunction() = this.theCallable()
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets a call-site from where this function is called */
|
||||
ControlFlowNode getACall() { result = theCallable().getACall() }
|
||||
ControlFlowNode getACall() { result = this.theCallable().getACall() }
|
||||
|
||||
/** Gets a call-site from where this function is called, given the `context` */
|
||||
ControlFlowNode getACall(Context caller_context) {
|
||||
result = theCallable().getACall(caller_context)
|
||||
result = this.theCallable().getACall(caller_context)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ abstract class FunctionObject extends Object {
|
||||
* This predicate will correctly handle `x.y()`, treating `x` as the zeroth argument.
|
||||
*/
|
||||
ControlFlowNode getArgumentForCall(CallNode call, int n) {
|
||||
result = theCallable().getArgumentForCall(call, n)
|
||||
result = this.theCallable().getArgumentForCall(call, n)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,11 +67,11 @@ abstract class FunctionObject extends Object {
|
||||
* This predicate will correctly handle `x.y()`, treating `x` as the self argument.
|
||||
*/
|
||||
ControlFlowNode getNamedArgumentForCall(CallNode call, string name) {
|
||||
result = theCallable().getNamedArgumentForCall(call, name)
|
||||
result = this.theCallable().getNamedArgumentForCall(call, name)
|
||||
}
|
||||
|
||||
/** Whether this function never returns. This is an approximation. */
|
||||
predicate neverReturns() { theCallable().neverReturns() }
|
||||
predicate neverReturns() { this.theCallable().neverReturns() }
|
||||
|
||||
/**
|
||||
* Whether this is a "normal" method, that is, it is exists as a class attribute
|
||||
|
||||
@@ -43,11 +43,11 @@ abstract class ModuleObject extends Object {
|
||||
pragma[inline]
|
||||
final Object attr(string name) { result = this.getAttribute(name) }
|
||||
|
||||
predicate hasAttribute(string name) { theModule().hasAttribute(name) }
|
||||
predicate hasAttribute(string name) { this.theModule().hasAttribute(name) }
|
||||
|
||||
predicate attributeRefersTo(string name, Object obj, ControlFlowNode origin) {
|
||||
exists(ObjectInternal val, CfgOrigin valorig |
|
||||
theModule().(ModuleObjectInternal).attribute(name, val, valorig) and
|
||||
this.theModule().(ModuleObjectInternal).attribute(name, val, valorig) and
|
||||
obj = val.getSource() and
|
||||
origin = valorig.toCfgNode()
|
||||
)
|
||||
@@ -55,7 +55,7 @@ abstract class ModuleObject extends Object {
|
||||
|
||||
predicate attributeRefersTo(string name, Object obj, ClassObject cls, ControlFlowNode origin) {
|
||||
exists(ObjectInternal val, CfgOrigin valorig |
|
||||
theModule().(ModuleObjectInternal).attribute(name, val, valorig) and
|
||||
this.theModule().(ModuleObjectInternal).attribute(name, val, valorig) and
|
||||
obj = val.getSource() and
|
||||
cls = val.getClass().getSource() and
|
||||
origin = valorig.toCfgNode()
|
||||
@@ -72,7 +72,7 @@ abstract class ModuleObject extends Object {
|
||||
* Whether this module "exports" `name`. That is, whether using `import *` on this module
|
||||
* will result in `name` being added to the namespace.
|
||||
*/
|
||||
predicate exports(string name) { theModule().exports(name) }
|
||||
predicate exports(string name) { this.theModule().exports(name) }
|
||||
|
||||
/**
|
||||
* Whether the complete set of names "exported" by this module can be accurately determined
|
||||
@@ -92,7 +92,7 @@ abstract class ModuleObject extends Object {
|
||||
* Whether this module is imported by 'import name'. For example on a linux system,
|
||||
* the module 'posixpath' is imported as 'os.path' or as 'posixpath'
|
||||
*/
|
||||
predicate importedAs(string name) { PointsToInternal::module_imported_as(theModule(), name) }
|
||||
predicate importedAs(string name) { PointsToInternal::module_imported_as(this.theModule(), name) }
|
||||
|
||||
ModuleObject getAnImportedModule() {
|
||||
result.importedAs(this.getModule().getAnImportedModuleName())
|
||||
@@ -181,7 +181,7 @@ class PackageObject extends ModuleObject {
|
||||
|
||||
override Object getAttribute(string name) {
|
||||
exists(ObjectInternal val |
|
||||
theModule().(PackageObjectInternal).attribute(name, val, _) and
|
||||
this.theModule().(PackageObjectInternal).attribute(name, val, _) and
|
||||
result = val.getSource()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class Object extends @py_object {
|
||||
* class S, both attributes having the same name, and S is a super class of C.
|
||||
*/
|
||||
predicate overrides(Object o) {
|
||||
exists(string name | declaringClass(name).getASuperType() = o.declaringClass(name))
|
||||
exists(string name | this.declaringClass(name).getASuperType() = o.declaringClass(name))
|
||||
}
|
||||
|
||||
private boolean booleanFromValue() {
|
||||
@@ -148,8 +148,8 @@ class Object extends @py_object {
|
||||
}
|
||||
|
||||
final predicate maybe() {
|
||||
booleanFromValue() = true and
|
||||
booleanFromValue() = false
|
||||
this.booleanFromValue() = true and
|
||||
this.booleanFromValue() = false
|
||||
}
|
||||
|
||||
predicate notClass() { any() }
|
||||
|
||||
@@ -21,7 +21,7 @@ class TurboGearsControllerMethod extends Function {
|
||||
|
||||
private ControlFlowNode templateName() { result = decorator.(CallNode).getArg(0) }
|
||||
|
||||
predicate isTemplated() { exists(templateName()) }
|
||||
predicate isTemplated() { exists(this.templateName()) }
|
||||
|
||||
Dict getValidationDict() {
|
||||
exists(Call call, Value dict |
|
||||
|
||||
@@ -85,7 +85,7 @@ class CheckClass extends ClassObject {
|
||||
|
||||
predicate interestingUndefined(SelfAttributeRead a) {
|
||||
exists(string name | name = a.getName() |
|
||||
interestingContext(a, name) and
|
||||
this.interestingContext(a, name) and
|
||||
not this.definedInBlock(a.getAFlowNode().getBasicBlock(), name)
|
||||
)
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class CheckClass extends ClassObject {
|
||||
not a.guardedByHasattr() and
|
||||
a.getScope().isPublic() and
|
||||
not this.monkeyPatched(name) and
|
||||
not attribute_assigned_in_method(lookupAttribute("setUp"), name)
|
||||
not attribute_assigned_in_method(this.lookupAttribute("setUp"), name)
|
||||
}
|
||||
|
||||
private predicate probablyAbstract() {
|
||||
@@ -127,7 +127,7 @@ class CheckClass extends ClassObject {
|
||||
// so we can push the context in from there, which must apply to a
|
||||
// SelfAttributeRead in the same scope
|
||||
exists(SelfAttributeRead a | a.getScope() = b.getScope() and name = a.getName() |
|
||||
interestingContext(a, name)
|
||||
this.interestingContext(a, name)
|
||||
) and
|
||||
this.definitionInBlock(b, name)
|
||||
or
|
||||
|
||||
@@ -96,12 +96,12 @@ abstract class TlsLibrary extends string {
|
||||
|
||||
/** Gets an API node representing a specific protocol version. */
|
||||
API::Node specific_version(ProtocolVersion version) {
|
||||
result = version_constants().getMember(specific_version_name(version))
|
||||
result = this.version_constants().getMember(this.specific_version_name(version))
|
||||
}
|
||||
|
||||
/** Gets an API node representing the protocol family `family`. */
|
||||
API::Node unspecific_version(ProtocolFamily family) {
|
||||
result = version_constants().getMember(unspecific_version_name(family))
|
||||
result = this.version_constants().getMember(this.unspecific_version_name(family))
|
||||
}
|
||||
|
||||
/** Gets a creation of a context with a default protocol. */
|
||||
@@ -112,14 +112,14 @@ abstract class TlsLibrary extends string {
|
||||
|
||||
/** Gets a creation of a context with a specific protocol version, known to be insecure. */
|
||||
ContextCreation insecure_context_creation(ProtocolVersion version) {
|
||||
result in [specific_context_creation(), default_context_creation()] and
|
||||
result in [this.specific_context_creation(), this.default_context_creation()] and
|
||||
result.getProtocol() = version and
|
||||
version.isInsecure()
|
||||
}
|
||||
|
||||
/** Gets a context that was created using `family`, known to have insecure instances. */
|
||||
ContextCreation unspecific_context_creation(ProtocolFamily family) {
|
||||
result in [specific_context_creation(), default_context_creation()] and
|
||||
result in [this.specific_context_creation(), this.default_context_creation()] and
|
||||
result.getProtocol() = family
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ private module Authlib {
|
||||
|
||||
override string getAlgorithmString() {
|
||||
exists(StrConst str |
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(getAlgorithm()) and
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getAlgorithm()) and
|
||||
result = str.getText()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ private module PyJWT {
|
||||
|
||||
override string getAlgorithmString() {
|
||||
exists(StrConst str |
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(getAlgorithm()) and
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getAlgorithm()) and
|
||||
result = str.getText()
|
||||
)
|
||||
}
|
||||
@@ -76,7 +76,7 @@ private module PyJWT {
|
||||
|
||||
override string getAlgorithmString() {
|
||||
exists(StrConst str |
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(getAlgorithm()) and
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getAlgorithm()) and
|
||||
result = str.getText()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ private module PythonJose {
|
||||
|
||||
override string getAlgorithmString() {
|
||||
exists(StrConst str |
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(getAlgorithm()) and
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getAlgorithm()) and
|
||||
result = str.getText()
|
||||
)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ private module PythonJose {
|
||||
|
||||
override string getAlgorithmString() {
|
||||
exists(StrConst str |
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(getAlgorithm()) and
|
||||
DataFlow::exprNode(str).(DataFlow::LocalSourceNode).flowsTo(this.getAlgorithm()) and
|
||||
result = str.getText()
|
||||
)
|
||||
}
|
||||
|
||||
27
python/ql/src/external/ExternalArtifact.qll
vendored
27
python/ql/src/external/ExternalArtifact.qll
vendored
@@ -19,7 +19,9 @@ class ExternalDefect extends @externalDefect {
|
||||
Location getLocation() { externalDefects(this, _, result, _, _) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = getQueryPath() + ": " + getLocation() + " - " + getMessage() }
|
||||
string toString() {
|
||||
result = this.getQueryPath() + ": " + this.getLocation() + " - " + this.getMessage()
|
||||
}
|
||||
}
|
||||
|
||||
class ExternalMetric extends @externalMetric {
|
||||
@@ -30,7 +32,9 @@ class ExternalMetric extends @externalMetric {
|
||||
Location getLocation() { externalMetrics(this, _, result, _) }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = getQueryPath() + ": " + getLocation() + " - " + getValue() }
|
||||
string toString() {
|
||||
result = this.getQueryPath() + ": " + this.getLocation() + " - " + this.getValue()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +48,7 @@ class ExternalData extends @externalDataElement {
|
||||
* Gets the path of the file this data was loaded from, with its
|
||||
* extension replaced by `.ql`.
|
||||
*/
|
||||
string getQueryPath() { result = getDataPath().regexpReplaceAll("\\.[^.]*$", ".ql") }
|
||||
string getQueryPath() { result = this.getDataPath().regexpReplaceAll("\\.[^.]*$", ".ql") }
|
||||
|
||||
/** Gets the number of fields in this data item. */
|
||||
int getNumFields() { result = 1 + max(int i | externalData(this, _, i, _) | i) }
|
||||
@@ -53,22 +57,23 @@ class ExternalData extends @externalDataElement {
|
||||
string getField(int index) { externalData(this, _, index, result) }
|
||||
|
||||
/** Gets the integer value of the field at position `index` of this data item. */
|
||||
int getFieldAsInt(int index) { result = getField(index).toInt() }
|
||||
int getFieldAsInt(int index) { result = this.getField(index).toInt() }
|
||||
|
||||
/** Gets the floating-point value of the field at position `index` of this data item. */
|
||||
float getFieldAsFloat(int index) { result = getField(index).toFloat() }
|
||||
float getFieldAsFloat(int index) { result = this.getField(index).toFloat() }
|
||||
|
||||
/** Gets the value of the field at position `index` of this data item, interpreted as a date. */
|
||||
date getFieldAsDate(int index) { result = getField(index).toDate() }
|
||||
date getFieldAsDate(int index) { result = this.getField(index).toDate() }
|
||||
|
||||
/** Gets a textual representation of this data item. */
|
||||
string toString() { result = getQueryPath() + ": " + buildTupleString(0) }
|
||||
string toString() { result = this.getQueryPath() + ": " + this.buildTupleString(0) }
|
||||
|
||||
/** Gets a textual representation of this data item, starting with the field at position `start`. */
|
||||
private string buildTupleString(int start) {
|
||||
start = getNumFields() - 1 and result = getField(start)
|
||||
start = this.getNumFields() - 1 and result = this.getField(start)
|
||||
or
|
||||
start < getNumFields() - 1 and result = getField(start) + "," + buildTupleString(start + 1)
|
||||
start < this.getNumFields() - 1 and
|
||||
result = this.getField(start) + "," + this.buildTupleString(start + 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +86,7 @@ class DefectExternalData extends ExternalData {
|
||||
this.getNumFields() = 2
|
||||
}
|
||||
|
||||
string getURL() { result = getField(0) }
|
||||
string getURL() { result = this.getField(0) }
|
||||
|
||||
string getMessage() { result = getField(1) }
|
||||
string getMessage() { result = this.getField(1) }
|
||||
}
|
||||
|
||||
4
python/ql/src/external/Thrift.qll
vendored
4
python/ql/src/external/Thrift.qll
vendored
@@ -13,9 +13,9 @@ class ThriftElement extends ExternalData {
|
||||
|
||||
string getKind() { result = kind }
|
||||
|
||||
string getId() { result = getField(0) }
|
||||
string getId() { result = this.getField(0) }
|
||||
|
||||
int getIndex() { result = getFieldAsInt(1) }
|
||||
int getIndex() { result = this.getFieldAsInt(1) }
|
||||
|
||||
ThriftElement getParent() { result.getId() = this.getField(2) }
|
||||
|
||||
|
||||
6
python/ql/src/external/VCS.qll
vendored
6
python/ql/src/external/VCS.qll
vendored
@@ -29,7 +29,7 @@ class Commit extends @svnentry {
|
||||
)
|
||||
}
|
||||
|
||||
string getAnAffectedFilePath() { result = getAnAffectedFilePath(_) }
|
||||
string getAnAffectedFilePath() { result = this.getAnAffectedFilePath(_) }
|
||||
|
||||
File getAnAffectedFile(string action) { svnaffectedfiles(this, result, action) }
|
||||
|
||||
@@ -38,7 +38,7 @@ class Commit extends @svnentry {
|
||||
predicate isRecent() { recentCommit(this) }
|
||||
|
||||
int daysToNow() {
|
||||
exists(date now | snapshotDate(now) | result = getDate().daysTo(now) and result >= 0)
|
||||
exists(date now | snapshotDate(now) | result = this.getDate().daysTo(now) and result >= 0)
|
||||
}
|
||||
|
||||
int getRecentAdditionsForFile(File f) { svnchurn(this, f, result, _) }
|
||||
@@ -46,7 +46,7 @@ class Commit extends @svnentry {
|
||||
int getRecentDeletionsForFile(File f) { svnchurn(this, f, _, result) }
|
||||
|
||||
int getRecentChurnForFile(File f) {
|
||||
result = getRecentAdditionsForFile(f) + getRecentDeletionsForFile(f)
|
||||
result = this.getRecentAdditionsForFile(f) + this.getRecentDeletionsForFile(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user