Skip to content

Commit c6f1051

Browse files
author
Stephan Brandauer
authored
Merge branch 'main' into java/update-mad-decls-after-triage-2023-06-08T08-51-47
2 parents bda938c + cc45db7 commit c6f1051

File tree

247 files changed

+2297
-2695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+2297
-2695
lines changed

.github/labeler.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Go:
1111
- change-notes/**/*go.*
1212

1313
Java:
14-
- any: [ 'java/**/*', '!java/kotlin-extractor/**/*', '!java/kotlin-explorer/**/*', '!java/ql/test/kotlin/**/*' ]
14+
- any: [ 'java/**/*', '!java/kotlin-extractor/**/*', '!java/ql/test/kotlin/**/*' ]
1515
- change-notes/**/*java.*
1616

1717
JS:
@@ -20,7 +20,6 @@ JS:
2020

2121
Kotlin:
2222
- java/kotlin-extractor/**/*
23-
- java/kotlin-explorer/**/*
2423
- java/ql/test/kotlin/**/*
2524

2625
Python:

CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
/swift/ @github/codeql-swift
99
/misc/codegen/ @github/codeql-swift
1010
/java/kotlin-extractor/ @github/codeql-kotlin
11-
/java/kotlin-explorer/ @github/codeql-kotlin
1211

1312
# ML-powered queries
1413
/javascript/ql/experimental/adaptivethreatmodeling/ @github/codeql-ml-powered-queries-reviewers

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,6 @@ class Instruction extends Construction::TStageInstruction {
210210
*/
211211
final Language::AST getAst() { result = Construction::getInstructionAst(this) }
212212

213-
/** DEPRECATED: Alias for getAst */
214-
deprecated Language::AST getAST() { result = this.getAst() }
215-
216213
/**
217214
* Gets the location of the source code for this instruction.
218215
*/
@@ -463,9 +460,6 @@ class VariableInstruction extends Instruction {
463460
* Gets the AST variable that this instruction's IR variable refers to, if one exists.
464461
*/
465462
final Language::Variable getAstVariable() { result = var.(IRUserVariable).getVariable() }
466-
467-
/** DEPRECATED: Alias for getAstVariable */
468-
deprecated Language::Variable getASTVariable() { result = this.getAstVariable() }
469463
}
470464

471465
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,6 @@ private module Cached {
422422
)
423423
}
424424

425-
/** DEPRECATED: Alias for getInstructionAst */
426-
cached
427-
deprecated Language::AST getInstructionAST(Instruction instr) {
428-
result = getInstructionAst(instr)
429-
}
430-
431425
cached
432426
Language::LanguageType getInstructionResultType(Instruction instr) {
433427
result = instr.(RawIR::Instruction).getResultLanguageType()
@@ -993,9 +987,6 @@ predicate canReuseSsaForMemoryResult(Instruction instruction) {
993987
// We don't support reusing SSA for any location that could create a `Chi` instruction.
994988
}
995989

996-
/** DEPRECATED: Alias for canReuseSsaForMemoryResult */
997-
deprecated predicate canReuseSSAForMemoryResult = canReuseSsaForMemoryResult/1;
998-
999990
/**
1000991
* Expose some of the internal predicates to PrintSSA.qll. We do this by publicly importing those modules in the
1001992
* `DebugSsa` module, which is then imported by PrintSSA.
@@ -1005,9 +996,6 @@ module DebugSsa {
1005996
import DefUse
1006997
}
1007998

1008-
/** DEPRECATED: Alias for DebugSsa */
1009-
deprecated module DebugSSA = DebugSsa;
1010-
1011999
import CachedForDebugging
10121000

10131001
cached

cpp/ql/lib/semmle/code/cpp/ir/implementation/internal/TInstruction.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ module UnaliasedSsaInstructions {
7373
}
7474
}
7575

76-
/** DEPRECATED: Alias for UnaliasedSsaInstructions */
77-
deprecated module UnaliasedSSAInstructions = UnaliasedSsaInstructions;
78-
7976
/**
8077
* Provides wrappers for the constructors of each branch of `TInstruction` that is used by the
8178
* aliased SSA stage.
@@ -107,6 +104,3 @@ module AliasedSsaInstructions {
107104
result = TAliasedSsaUnreachedInstruction(irFunc)
108105
}
109106
}
110-
111-
/** DEPRECATED: Alias for AliasedSsaInstructions */
112-
deprecated module AliasedSSAInstructions = AliasedSsaInstructions;

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,6 @@ class Instruction extends Construction::TStageInstruction {
210210
*/
211211
final Language::AST getAst() { result = Construction::getInstructionAst(this) }
212212

213-
/** DEPRECATED: Alias for getAst */
214-
deprecated Language::AST getAST() { result = this.getAst() }
215-
216213
/**
217214
* Gets the location of the source code for this instruction.
218215
*/
@@ -463,9 +460,6 @@ class VariableInstruction extends Instruction {
463460
* Gets the AST variable that this instruction's IR variable refers to, if one exists.
464461
*/
465462
final Language::Variable getAstVariable() { result = var.(IRUserVariable).getVariable() }
466-
467-
/** DEPRECATED: Alias for getAstVariable */
468-
deprecated Language::Variable getASTVariable() { result = this.getAstVariable() }
469463
}
470464

471465
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,6 @@ class Instruction extends Construction::TStageInstruction {
210210
*/
211211
final Language::AST getAst() { result = Construction::getInstructionAst(this) }
212212

213-
/** DEPRECATED: Alias for getAst */
214-
deprecated Language::AST getAST() { result = this.getAst() }
215-
216213
/**
217214
* Gets the location of the source code for this instruction.
218215
*/
@@ -463,9 +460,6 @@ class VariableInstruction extends Instruction {
463460
* Gets the AST variable that this instruction's IR variable refers to, if one exists.
464461
*/
465462
final Language::Variable getAstVariable() { result = var.(IRUserVariable).getVariable() }
466-
467-
/** DEPRECATED: Alias for getAstVariable */
468-
deprecated Language::Variable getASTVariable() { result = this.getAstVariable() }
469463
}
470464

471465
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,6 @@ private module Cached {
422422
)
423423
}
424424

425-
/** DEPRECATED: Alias for getInstructionAst */
426-
cached
427-
deprecated Language::AST getInstructionAST(Instruction instr) {
428-
result = getInstructionAst(instr)
429-
}
430-
431425
cached
432426
Language::LanguageType getInstructionResultType(Instruction instr) {
433427
result = instr.(RawIR::Instruction).getResultLanguageType()
@@ -993,9 +987,6 @@ predicate canReuseSsaForMemoryResult(Instruction instruction) {
993987
// We don't support reusing SSA for any location that could create a `Chi` instruction.
994988
}
995989

996-
/** DEPRECATED: Alias for canReuseSsaForMemoryResult */
997-
deprecated predicate canReuseSSAForMemoryResult = canReuseSsaForMemoryResult/1;
998-
999990
/**
1000991
* Expose some of the internal predicates to PrintSSA.qll. We do this by publicly importing those modules in the
1001992
* `DebugSsa` module, which is then imported by PrintSSA.
@@ -1005,9 +996,6 @@ module DebugSsa {
1005996
import DefUse
1006997
}
1007998

1008-
/** DEPRECATED: Alias for DebugSsa */
1009-
deprecated module DebugSSA = DebugSsa;
1010-
1011999
import CachedForDebugging
10121000

10131001
cached

cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ predicate canReuseSsaForVariable(IRAutomaticVariable var) {
4646
not allocationEscapes(var)
4747
}
4848

49-
/** DEPRECATED: Alias for canReuseSsaForVariable */
50-
deprecated predicate canReuseSSAForVariable = canReuseSsaForVariable/1;
51-
5249
private newtype TMemoryLocation = MkMemoryLocation(Allocation var) { isVariableModeled(var) }
5350

5451
private MemoryLocation getMemoryLocation(Allocation var) { result.getAllocation() = var }
@@ -80,9 +77,6 @@ class MemoryLocation extends TMemoryLocation {
8077

8178
predicate canReuseSsaForOldResult(Instruction instr) { none() }
8279

83-
/** DEPRECATED: Alias for canReuseSsaForOldResult */
84-
deprecated predicate canReuseSSAForOldResult = canReuseSsaForOldResult/1;
85-
8680
/**
8781
* Represents a set of `MemoryLocation`s that cannot overlap with
8882
* `MemoryLocation`s outside of the set. The `VirtualVariable` will be

cpp/ql/src/experimental/Security/CWE/CWE-193/InvalidPointerDeref.ql

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,34 @@ predicate isSinkImpl(
179179
pointerAddInstructionHasBounds(pai, sink1, sink2, delta)
180180
}
181181

182+
/**
183+
* Yields any instruction that is control-flow reachable from `instr`.
184+
*/
185+
bindingset[instr, result]
186+
pragma[inline_late]
187+
Instruction getASuccessor(Instruction instr) {
188+
exists(IRBlock b, int instrIndex, int resultIndex |
189+
result.getBlock() = b and
190+
instr.getBlock() = b and
191+
b.getInstruction(instrIndex) = instr and
192+
b.getInstruction(resultIndex) = result
193+
|
194+
resultIndex >= instrIndex
195+
)
196+
or
197+
instr.getBlock().getASuccessor+() = result.getBlock()
198+
}
199+
182200
/**
183201
* Holds if `sink` is a sink for `InvalidPointerToDerefConfig` and `i` is a `StoreInstruction` that
184202
* writes to an address that non-strictly upper-bounds `sink`, or `i` is a `LoadInstruction` that
185203
* reads from an address that non-strictly upper-bounds `sink`.
186204
*/
187205
pragma[inline]
188206
predicate isInvalidPointerDerefSink(DataFlow::Node sink, Instruction i, string operation, int delta) {
189-
exists(AddressOperand addr |
190-
bounded1(addr.getDef(), sink.asInstruction(), delta) and
207+
exists(AddressOperand addr, Instruction s |
208+
s = sink.asInstruction() and
209+
bounded1(addr.getDef(), s, delta) and
191210
delta >= 0 and
192211
i.getAnOperand() = addr
193212
|
@@ -247,7 +266,8 @@ newtype TMergedPathNode =
247266
TPathNodeSink(Instruction i) {
248267
exists(DataFlow::Node n |
249268
InvalidPointerToDerefFlow::flowTo(n) and
250-
isInvalidPointerDerefSink(n, i, _, _)
269+
isInvalidPointerDerefSink(n, i, _, _) and
270+
i = getASuccessor(n.asInstruction())
251271
)
252272
}
253273

@@ -377,15 +397,19 @@ predicate hasFlowPath(
377397
}
378398

379399
from
380-
MergedPathNode source, MergedPathNode sink, int k2, int k3, string kstr,
381-
InvalidPointerToDerefFlow::PathNode source3, PointerArithmeticInstruction pai, string operation,
382-
Expr offset, DataFlow::Node n
400+
MergedPathNode source, MergedPathNode sink, int k, string kstr, PointerArithmeticInstruction pai,
401+
string operation, Expr offset, DataFlow::Node n
383402
where
384-
hasFlowPath(source, sink, source3, pai, operation, k3) and
385-
invalidPointerToDerefSource(pai, source3.getNode(), k2) and
403+
k =
404+
min(int k2, int k3, InvalidPointerToDerefFlow::PathNode source3 |
405+
hasFlowPath(source, sink, source3, pai, operation, k3) and
406+
invalidPointerToDerefSource(pai, source3.getNode(), k2)
407+
|
408+
k2 + k3
409+
) and
386410
offset = pai.getRight().getUnconvertedResultExpression() and
387411
n = source.asPathNode1().getNode() and
388-
if (k2 + k3) = 0 then kstr = "" else kstr = " + " + (k2 + k3)
412+
if k = 0 then kstr = "" else kstr = " + " + k
389413
select sink, source, sink,
390414
"This " + operation + " might be out of bounds, as the pointer might be equal to $@ + $@" + kstr +
391415
".", n, n.toString(), offset, offset.toString()

0 commit comments

Comments
 (0)