GeezerVison is showing github.com — Java: Replace getAUse with getARead. · github/codeql@f4b9efc
File treeExpand file treeCollapse file tree Open diff view settings experimental/Security/CWE/CWE-470
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: java/ql/lib/semmle/code/java/dataflow/NullGuards.qll +8-8Lines changed: 8 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,9 +26,9 @@ Expr enumConstEquality(Expr e, boolean polarity, EnumConstant c) { | 26 | 26 | } | 27 | 27 |
| 28 | 28 | /** Gets an instanceof expression of `v` with type `type` */ | 29 | | -InstanceOfExpr instanceofExpr(SsaVariable v, RefType type) { | | 29 | +InstanceOfExpr instanceofExpr(SsaDefinition v, RefType type) { | 30 | 30 | result.getCheckedType() = type and | 31 | | - result.getExpr() = v.getAUse() | | 31 | + result.getExpr() = v.getARead() | 32 | 32 | } | 33 | 33 |
| 34 | 34 | /** | @@ -37,8 +37,8 @@ InstanceOfExpr instanceofExpr(SsaVariable v, RefType type) { | 37 | 37 | * | 38 | 38 | * Note this includes Kotlin's `==` and `!=` operators, which are value-equality tests. | 39 | 39 | */ | 40 | | -EqualityTest varEqualityTestExpr(SsaVariable v1, SsaVariable v2, boolean isEqualExpr) { | 41 | | - result.hasOperands(v1.getAUse(), v2.getAUse()) and | | 40 | +EqualityTest varEqualityTestExpr(SsaDefinition v1, SsaDefinition v2, boolean isEqualExpr) { | | 41 | + result.hasOperands(v1.getARead(), v2.getARead()) and | 42 | 42 | isEqualExpr = result.polarity() | 43 | 43 | } | 44 | 44 |
| @@ -91,18 +91,18 @@ Expr clearlyNotNullExpr(Expr reason) { | 91 | 91 | (reason = r1 or reason = r2) | 92 | 92 | ) | 93 | 93 | or | 94 | | - exists(SsaVariable v, boolean branch, VarRead rval, Guard guard | | | 94 | + exists(SsaDefinition v, boolean branch, VarRead rval, Guard guard | | 95 | 95 | guard = directNullGuard(v, branch, false) and | 96 | 96 | guard.controls(rval.getBasicBlock(), branch) and | 97 | 97 | reason = guard and | 98 | | - rval = v.getAUse() and | | 98 | + rval = v.getARead() and | 99 | 99 | result = rval and | 100 | 100 | not result = baseNotNullExpr() | 101 | 101 | ) | 102 | 102 | or | 103 | | - exists(SsaVariable v | | | 103 | + exists(SsaDefinition v | | 104 | 104 | clearlyNotNull(v, reason) and | 105 | | - result = v.getAUse() and | | 105 | + result = v.getARead() and | 106 | 106 | not result = baseNotNullExpr() | 107 | 107 | ) | 108 | 108 | } | |
Collapse file Copy file name to clipboardExpand all lines: java/ql/lib/semmle/code/java/dataflow/Nullness.qll +7-7Lines changed: 7 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -179,9 +179,9 @@ private Expr nonEmptyExpr() { | 179 | 179 | // An array creation with a known positive size is trivially non-empty. | 180 | 180 | result.(ArrayCreationExpr).getFirstDimensionSize() > 0 | 181 | 181 | or | 182 | | - exists(SsaVariable v | | | 182 | + exists(SsaDefinition v | | 183 | 183 | // A use of an array variable is non-empty if... | 184 | | - result = v.getAUse() and | | 184 | + result = v.getARead() and | 185 | 185 | v.getSourceVariable().getType() instanceof Array | 186 | 186 | | | 187 | 187 | // ...its definition is non-empty... | @@ -192,13 +192,13 @@ private Expr nonEmptyExpr() { | 192 | 192 | cond.controls(result.getBasicBlock(), branch) and | 193 | 193 | cond.getCondition() = nonZeroGuard(length, branch) and | 194 | 194 | length.getField().hasName("length") and | 195 | | - length.getQualifier() = v.getAUse() | | 195 | + length.getQualifier() = v.getARead() | 196 | 196 | ) | 197 | 197 | ) | 198 | 198 | or | 199 | | - exists(SsaVariable v | | | 199 | + exists(SsaDefinition v | | 200 | 200 | // A use of a Collection variable is non-empty if... | 201 | | - result = v.getAUse() and | | 201 | + result = v.getARead() and | 202 | 202 | v.getSourceVariable().getType() instanceof CollectionType and | 203 | 203 | exists(ConditionBlock cond, boolean branch, Expr c | | 204 | 204 | // ...it is guarded by a condition... | @@ -216,13 +216,13 @@ private Expr nonEmptyExpr() { | 216 | 216 | // ...and the condition proves that it is non-empty, either by using the `isEmpty` method... | 217 | 217 | c.(MethodCall).getMethod().hasName("isEmpty") and | 218 | 218 | branch = false and | 219 | | - c.(MethodCall).getQualifier() = v.getAUse() | | 219 | + c.(MethodCall).getQualifier() = v.getARead() | 220 | 220 | or | 221 | 221 | // ...or a check on its `size`. | 222 | 222 | exists(MethodCall size | | 223 | 223 | c = nonZeroGuard(size, branch) and | 224 | 224 | size.getMethod().hasName("size") and | 225 | | - size.getQualifier() = v.getAUse() | | 225 | + size.getQualifier() = v.getARead() | 226 | 226 | ) | 227 | 227 | ) | 228 | 228 | ) | |
Collapse file Copy file name to clipboardExpand all lines: java/ql/lib/semmle/code/java/dataflow/RangeAnalysis.qll +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -242,10 +242,10 @@ module Sem implements Semantic<Location> { | 242 | 242 |
| 243 | 243 | Type getSsaType(SsaVariable var) { result = var.getSourceVariable().getType() } | 244 | 244 |
| 245 | | - final private class FinalSsaVariable = SSA::SsaVariable; | | 245 | + final private class FinalSsaVariable = SSA::SsaDefinition; | 246 | 246 |
| 247 | 247 | class SsaVariable extends FinalSsaVariable { | 248 | | - Expr getAUse() { result = super.getAUse() } | | 248 | + Expr getAUse() { result = super.getARead() } | 249 | 249 | } | 250 | 250 |
| 251 | 251 | class SsaPhiNode extends SsaVariable instanceof SSA::SsaPhiDefinition { | |
Collapse file Copy file name to clipboardExpand all lines: java/ql/lib/semmle/code/java/dataflow/RangeUtils.qll +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -74,9 +74,9 @@ ArrayCreationExpr getArrayDef(SsaVariable v) { | 74 | 74 | * `arrlen` without going through a back edge. | 75 | 75 | */ | 76 | 76 | private predicate arrayLengthDef(FieldRead arrlen, ArrayCreationExpr def) { | 77 | | - exists(SsaVariable arr | | | 77 | + exists(SsaDefinition arr | | 78 | 78 | arrlen.getField() instanceof ArrayLengthField and | 79 | | - arrlen.getQualifier() = arr.getAUse() and | | 79 | + arrlen.getQualifier() = arr.getARead() and | 80 | 80 | def = getArrayDef(arr) | 81 | 81 | ) | 82 | 82 | } | |
Collapse file Copy file name to clipboardExpand all lines: java/ql/lib/semmle/code/java/dataflow/SSA.qll +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -417,8 +417,8 @@ private class RefTypeCastingExpr extends CastingExpr { | 417 | 417 | * | 418 | 418 | * The `VarAccess` represents the access to `v` that `result` has the same value as. | 419 | 419 | */ | 420 | | -Expr sameValue(SsaVariable v, VarAccess va) { | 421 | | - result = v.getAUse() and result = va | | 420 | +Expr sameValue(SsaDefinition v, VarAccess va) { | | 421 | + result = v.getARead() and result = va | 422 | 422 | or | 423 | 423 | result.(AssignExpr).getDest() = va and result = v.(SsaExplicitWrite).getDefiningExpr() | 424 | 424 | or | |
Collapse file Copy file name to clipboardExpand all lines: java/ql/lib/semmle/code/java/dataflow/internal/DataFlowUtil.qll +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -99,7 +99,7 @@ predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2) | 99 | 99 | * updates. | 100 | 100 | */ | 101 | 101 | predicate hasNonlocalValue(FieldRead fr) { | 102 | | - not exists(SsaVariable v | v.getAUse() = fr) | | 102 | + not exists(SsaDefinition v | v.getARead() = fr) | 103 | 103 | or | 104 | 104 | exists(SsaDefinition v, SsaDefinition def | | 105 | 105 | v.getARead() = fr and def = v.getAnUltimateDefinition() | |
Collapse file Copy file name to clipboardExpand all lines: java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/BoundSpecific.qll +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,7 +8,9 @@ private import java as J | 8 | 8 | private import semmle.code.java.dataflow.SSA as Ssa | 9 | 9 | private import semmle.code.java.dataflow.RangeUtils as RU | 10 | 10 |
| 11 | | -class SsaVariable = Ssa::SsaVariable; | | 11 | +class SsaVariable extends Ssa::SsaDefinition { | | 12 | + Expr getAUse() { result = super.getARead() } | | 13 | +} | 12 | 14 |
| 13 | 15 | class Expr = J::Expr; | 14 | 16 |
| |
Collapse file Copy file name to clipboardExpand all lines: java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/ModulusAnalysisSpecific.qll +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,7 +11,9 @@ module Private { | 11 | 11 |
| 12 | 12 | class BasicBlock = BB::BasicBlock; | 13 | 13 |
| 14 | | - class SsaVariable = Ssa::SsaVariable; | | 14 | + class SsaVariable extends Ssa::SsaDefinition { | | 15 | + Expr getAUse() { result = super.getARead() } | | 16 | + } | 15 | 17 |
| 16 | 18 | class SsaPhiNode = Ssa::SsaPhiDefinition; | 17 | 19 |
| |
Collapse file Copy file name to clipboardExpand all lines: java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -324,7 +324,7 @@ private module Impl { | 324 | 324 | result = e.(CastingExpr).getExpr() | 325 | 325 | } | 326 | 326 |
| 327 | | - Expr getARead(SsaVariable v) { result = v.getAUse() } | | 327 | + Expr getARead(SsaDefinition v) { result = v.getARead() } | 328 | 328 |
| 329 | 329 | Field getField(FieldAccess fa) { result = fa.getField() } | 330 | 330 |
| |
Collapse file Copy file name to clipboardExpand all lines: java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SsaReadPositionSpecific.qll +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,14 +8,14 @@ private import semmle.code.java.dataflow.SSA as Ssa | 8 | 8 | private import semmle.code.java.controlflow.BasicBlocks as BB | 9 | 9 | private import SsaReadPositionCommon | 10 | 10 |
| 11 | | -class SsaVariable = Ssa::SsaVariable; | | 11 | +class SsaVariable = Ssa::SsaDefinition; | 12 | 12 |
| 13 | 13 | class SsaPhiNode = Ssa::SsaPhiDefinition; | 14 | 14 |
| 15 | 15 | class BasicBlock = BB::BasicBlock; | 16 | 16 |
| 17 | 17 | /** Gets a basic block in which SSA variable `v` is read. */ | 18 | | -BasicBlock getAReadBasicBlock(SsaVariable v) { result = v.getAUse().getBasicBlock() } | | 18 | +BasicBlock getAReadBasicBlock(SsaVariable v) { result = v.getARead().getBasicBlock() } | 19 | 19 |
| 20 | 20 | private predicate id(BB::ExprParent x, BB::ExprParent y) { x = y } | 21 | 21 |
| |
|