Skip to content

Commit 64dd8b9

Browse files
authored
Merge branch 'main' into java/refactor-dataflow-queries-1
2 parents e7f8567 + 8356991 commit 64dd8b9

File tree

777 files changed

+15848
-10918
lines changed

Some content is hidden

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

777 files changed

+15848
-10918
lines changed

cpp/autobuilder/Semmle.Autobuild.Cpp.Tests/BuildScripts.cs

+20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Xunit;
22
using Semmle.Autobuild.Shared;
3+
using Semmle.Util;
34
using System.Collections.Generic;
45
using System;
56
using System.Linq;
@@ -75,6 +76,15 @@ int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory,
7576
throw new ArgumentException("Missing RunProcess " + pattern);
7677
}
7778

79+
int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory, IDictionary<string, string>? env, BuildOutputHandler onOutput, BuildOutputHandler onError)
80+
{
81+
var ret = (this as IBuildActions).RunProcess(cmd, args, workingDirectory, env, out var stdout);
82+
83+
stdout.ForEach(line => onOutput(line));
84+
85+
return ret;
86+
}
87+
7888
public IList<string> DirectoryDeleteIn = new List<string>();
7989

8090
void IBuildActions.DirectoryDelete(string dir, bool recursive)
@@ -184,6 +194,15 @@ public void DownloadFile(string address, string fileName)
184194
if (!DownloadFiles.Contains((address, fileName)))
185195
throw new ArgumentException($"Missing DownloadFile, {address}, {fileName}");
186196
}
197+
198+
public IDiagnosticsWriter CreateDiagnosticsWriter(string filename) => new TestDiagnosticWriter();
199+
}
200+
201+
internal class TestDiagnosticWriter : IDiagnosticsWriter
202+
{
203+
public IList<DiagnosticMessage> Diagnostics { get; } = new List<DiagnosticMessage>();
204+
205+
public void AddEntry(DiagnosticMessage message) => this.Diagnostics.Add(message);
187206
}
188207

189208
/// <summary>
@@ -243,6 +262,7 @@ CppAutobuilder CreateAutoBuilder(bool isWindows,
243262
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_TRAP_DIR"] = "";
244263
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_SOURCE_ARCHIVE_DIR"] = "";
245264
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_ROOT"] = $@"C:\codeql\{codeqlUpperLanguage.ToLowerInvariant()}";
265+
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_DIAGNOSTIC_DIR"] = "";
246266
Actions.GetEnvironmentVariable["CODEQL_JAVA_HOME"] = @"C:\codeql\tools\java";
247267
Actions.GetEnvironmentVariable["CODEQL_PLATFORM"] = "win64";
248268
Actions.GetEnvironmentVariable["SEMMLE_DIST"] = @"C:\odasa";

cpp/autobuilder/Semmle.Autobuild.Cpp/CppAutobuilder.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Semmle.Autobuild.Shared;
2+
using Semmle.Util;
23

34
namespace Semmle.Autobuild.Cpp
45
{
@@ -21,7 +22,7 @@ public CppAutobuildOptions(IBuildActions actions) : base(actions)
2122

2223
public class CppAutobuilder : Autobuilder<CppAutobuildOptions>
2324
{
24-
public CppAutobuilder(IBuildActions actions, CppAutobuildOptions options) : base(actions, options) { }
25+
public CppAutobuilder(IBuildActions actions, CppAutobuildOptions options) : base(actions, options, new DiagnosticClassifier()) { }
2526

2627
public override BuildScript GetBuildScript()
2728
{

cpp/ql/lib/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.4
2+
3+
No user-facing changes.
4+
15
## 0.5.3
26

37
No user-facing changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.5.4
2+
3+
No user-facing changes.

cpp/ql/lib/codeql-pack.release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
lastReleaseVersion: 0.5.3
2+
lastReleaseVersion: 0.5.4

cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

+1
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ module Impl<FullStateConfigSig Config> {
456456
* The Boolean `cc` records whether the node is reached through an
457457
* argument in a call.
458458
*/
459+
pragma[assume_small_delta]
459460
private predicate fwdFlow(NodeEx node, Cc cc) {
460461
sourceNode(node, _) and
461462
if hasSourceCallCtx() then cc = true else cc = false

cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/tainttracking1/TaintTracking.qll

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import TaintTrackingParameter::Public
77
private import TaintTrackingParameter::Private
88

99
private module AddTaintDefaults<DataFlowInternal::FullStateConfigSig Config> implements
10-
DataFlowInternal::FullStateConfigSig {
10+
DataFlowInternal::FullStateConfigSig
11+
{
1112
import Config
1213

1314
predicate isBarrier(DataFlow::Node node) {

cpp/ql/lib/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cpp-all
2-
version: 0.5.4-dev
2+
version: 0.5.5-dev
33
groups: cpp
44
dbscheme: semmlecode.cpp.dbscheme
55
extractor: cpp

cpp/ql/lib/semmle/code/cpp/Declaration.qll

+7-6
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Declaration extends Locatable, @declaration {
186186
predicate hasDefinition() { exists(this.getDefinition()) }
187187

188188
/** DEPRECATED: Use `hasDefinition` instead. */
189-
predicate isDefined() { this.hasDefinition() }
189+
deprecated predicate isDefined() { this.hasDefinition() }
190190

191191
/** Gets the preferred location of this declaration, if any. */
192192
override Location getLocation() { none() }
@@ -619,11 +619,10 @@ private class DirectAccessHolder extends Element {
619619
/**
620620
* Like `couldAccessMember` but only contains derivations in which either
621621
* (5.2), (5.3) or (5.4) must be invoked. In other words, the `this`
622-
* parameter is not ignored. This restriction makes it feasible to fully
623-
* enumerate this predicate even on large code bases. We check for 11.4 as
624-
* part of (5.3), since this further limits the number of tuples produced by
625-
* this predicate.
622+
* parameter is not ignored. We check for 11.4 as part of (5.3), since
623+
* this further limits the number of tuples produced by this predicate.
626624
*/
625+
pragma[inline]
627626
predicate thisCouldAccessMember(Class memberClass, AccessSpecifier memberAccess, Class derived) {
628627
// Only (5.4) is recursive, and chains of invocations of (5.4) can always
629628
// be collapsed to one invocation by the transitivity of 11.2/4.
@@ -665,7 +664,9 @@ private class DirectAccessHolder extends Element {
665664
// bypasses `p`. Then that path must be public, or we are in case 2.
666665
exists(AccessSpecifier public | public.hasName("public") |
667666
exists(Class between, Class p |
668-
between.accessOfBaseMember(memberClass, memberAccess).hasName("protected") and
667+
between
668+
.accessOfBaseMember(pragma[only_bind_into](memberClass), memberAccess)
669+
.hasName("protected") and
669670
this.isFriendOfOrEqualTo(p) and
670671
(
671672
// This is case 1 from above. If `p` derives privately from `between`

cpp/ql/lib/semmle/code/cpp/Function.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
4141
* `min<int>(int, int) -> int`, and the full signature of the uninstantiated
4242
* template on the first line would be `min<T>(T, T) -> T`.
4343
*/
44-
string getFullSignature() {
44+
deprecated string getFullSignature() {
4545
exists(string name, string templateArgs, string args |
4646
result = name + templateArgs + args + " -> " + this.getType().toString() and
4747
name = this.getQualifiedName() and

cpp/ql/lib/semmle/code/cpp/NameQualifiers.qll

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ class NameQualifyingElement extends Element, @namequalifyingelement {
159159
* A special name-qualifying element. For example: `__super`.
160160
*/
161161
library class SpecialNameQualifyingElement extends NameQualifyingElement,
162-
@specialnamequalifyingelement {
162+
@specialnamequalifyingelement
163+
{
163164
/** Gets the name of this special qualifying element. */
164165
override string getName() { specialnamequalifyingelements(underlyingElement(this), result) }
165166

cpp/ql/lib/semmle/code/cpp/commons/Alloc.qll

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ predicate freeFunction(Function f, int argNum) { argNum = f.(DeallocationFunctio
1212
*
1313
* DEPRECATED: Use `DeallocationExpr` instead (this also includes `delete` expressions).
1414
*/
15-
predicate freeCall(FunctionCall fc, Expr arg) { arg = fc.(DeallocationExpr).getFreedExpr() }
15+
deprecated predicate freeCall(FunctionCall fc, Expr arg) {
16+
arg = fc.(DeallocationExpr).getFreedExpr()
17+
}
1618

1719
/**
1820
* Is e some kind of allocation or deallocation (`new`, `alloc`, `realloc`, `delete`, `free` etc)?

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

+1
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ module Impl<FullStateConfigSig Config> {
456456
* The Boolean `cc` records whether the node is reached through an
457457
* argument in a call.
458458
*/
459+
pragma[assume_small_delta]
459460
private predicate fwdFlow(NodeEx node, Cc cc) {
460461
sourceNode(node, _) and
461462
if hasSourceCallCtx() then cc = true else cc = false

cpp/ql/lib/semmle/code/cpp/dataflow/internal/tainttracking1/TaintTracking.qll

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import TaintTrackingParameter::Public
77
private import TaintTrackingParameter::Private
88

99
private module AddTaintDefaults<DataFlowInternal::FullStateConfigSig Config> implements
10-
DataFlowInternal::FullStateConfigSig {
10+
DataFlowInternal::FullStateConfigSig
11+
{
1112
import Config
1213

1314
predicate isBarrier(DataFlow::Node node) {

cpp/ql/lib/semmle/code/cpp/exprs/BuiltInOperations.qll

+10-5
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ class BuiltInOperationBuiltInAddressOf extends UnaryOperation, BuiltInOperation,
569569
* ```
570570
*/
571571
class BuiltInOperationIsTriviallyConstructible extends BuiltInOperation,
572-
@istriviallyconstructibleexpr {
572+
@istriviallyconstructibleexpr
573+
{
573574
override string toString() { result = "__is_trivially_constructible" }
574575

575576
override string getAPrimaryQlClass() { result = "BuiltInOperationIsTriviallyConstructible" }
@@ -619,7 +620,8 @@ class BuiltInOperationIsNothrowDestructible extends BuiltInOperation, @isnothrow
619620
* bool v = __is_trivially_destructible(MyType);
620621
* ```
621622
*/
622-
class BuiltInOperationIsTriviallyDestructible extends BuiltInOperation, @istriviallydestructibleexpr {
623+
class BuiltInOperationIsTriviallyDestructible extends BuiltInOperation, @istriviallydestructibleexpr
624+
{
623625
override string toString() { result = "__is_trivially_destructible" }
624626

625627
override string getAPrimaryQlClass() { result = "BuiltInOperationIsTriviallyDestructible" }
@@ -738,7 +740,8 @@ class BuiltInOperationIsLiteralType extends BuiltInOperation, @isliteraltypeexpr
738740
* ```
739741
*/
740742
class BuiltInOperationHasTrivialMoveConstructor extends BuiltInOperation,
741-
@hastrivialmoveconstructorexpr {
743+
@hastrivialmoveconstructorexpr
744+
{
742745
override string toString() { result = "__has_trivial_move_constructor" }
743746

744747
override string getAPrimaryQlClass() { result = "BuiltInOperationHasTrivialMoveConstructor" }
@@ -1034,7 +1037,8 @@ class BuiltInOperationIsAggregate extends BuiltInOperation, @isaggregate {
10341037
* ```
10351038
*/
10361039
class BuiltInOperationHasUniqueObjectRepresentations extends BuiltInOperation,
1037-
@hasuniqueobjectrepresentations {
1040+
@hasuniqueobjectrepresentations
1041+
{
10381042
override string toString() { result = "__has_unique_object_representations" }
10391043

10401044
override string getAPrimaryQlClass() { result = "BuiltInOperationHasUniqueObjectRepresentations" }
@@ -1107,7 +1111,8 @@ class BuiltInOperationIsLayoutCompatible extends BuiltInOperation, @islayoutcomp
11071111
* ```
11081112
*/
11091113
class BuiltInOperationIsPointerInterconvertibleBaseOf extends BuiltInOperation,
1110-
@ispointerinterconvertiblebaseof {
1114+
@ispointerinterconvertiblebaseof
1115+
{
11111116
override string toString() { result = "__is_pointer_interconvertible_base_of" }
11121117

11131118
override string getAPrimaryQlClass() {

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

+1
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ module Impl<FullStateConfigSig Config> {
456456
* The Boolean `cc` records whether the node is reached through an
457457
* argument in a call.
458458
*/
459+
pragma[assume_small_delta]
459460
private predicate fwdFlow(NodeEx node, Cc cc) {
460461
sourceNode(node, _) and
461462
if hasSourceCallCtx() then cc = true else cc = false

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/tainttracking1/TaintTracking.qll

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import TaintTrackingParameter::Public
77
private import TaintTrackingParameter::Private
88

99
private module AddTaintDefaults<DataFlowInternal::FullStateConfigSig Config> implements
10-
DataFlowInternal::FullStateConfigSig {
10+
DataFlowInternal::FullStateConfigSig
11+
{
1112
import Config
1213

1314
predicate isBarrier(DataFlow::Node node) {

cpp/ql/lib/semmle/code/cpp/ir/implementation/Opcode.qll

+26-13
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,8 @@ module Opcode {
10821082
* See the `CallSideEffectInstruction` documentation for more details.
10831083
*/
10841084
class CallSideEffect extends WriteSideEffectOpcode, EscapedWriteOpcode, MayWriteOpcode,
1085-
ReadSideEffectOpcode, EscapedReadOpcode, MayReadOpcode, TCallSideEffect {
1085+
ReadSideEffectOpcode, EscapedReadOpcode, MayReadOpcode, TCallSideEffect
1086+
{
10861087
final override string toString() { result = "CallSideEffect" }
10871088
}
10881089

@@ -1092,7 +1093,8 @@ module Opcode {
10921093
* See the `CallReadSideEffectInstruction` documentation for more details.
10931094
*/
10941095
class CallReadSideEffect extends ReadSideEffectOpcode, EscapedReadOpcode, MayReadOpcode,
1095-
TCallReadSideEffect {
1096+
TCallReadSideEffect
1097+
{
10961098
final override string toString() { result = "CallReadSideEffect" }
10971099
}
10981100

@@ -1102,7 +1104,8 @@ module Opcode {
11021104
* See the `IndirectReadSideEffectInstruction` documentation for more details.
11031105
*/
11041106
class IndirectReadSideEffect extends ReadSideEffectOpcode, IndirectReadOpcode,
1105-
TIndirectReadSideEffect {
1107+
TIndirectReadSideEffect
1108+
{
11061109
final override string toString() { result = "IndirectReadSideEffect" }
11071110
}
11081111

@@ -1112,7 +1115,8 @@ module Opcode {
11121115
* See the `IndirectMustWriteSideEffectInstruction` documentation for more details.
11131116
*/
11141117
class IndirectMustWriteSideEffect extends WriteSideEffectOpcode, IndirectWriteOpcode,
1115-
TIndirectMustWriteSideEffect {
1118+
TIndirectMustWriteSideEffect
1119+
{
11161120
final override string toString() { result = "IndirectMustWriteSideEffect" }
11171121
}
11181122

@@ -1122,7 +1126,8 @@ module Opcode {
11221126
* See the `IndirectMayWriteSideEffectInstruction` documentation for more details.
11231127
*/
11241128
class IndirectMayWriteSideEffect extends WriteSideEffectOpcode, IndirectWriteOpcode,
1125-
MayWriteOpcode, TIndirectMayWriteSideEffect {
1129+
MayWriteOpcode, TIndirectMayWriteSideEffect
1130+
{
11261131
final override string toString() { result = "IndirectMayWriteSideEffect" }
11271132
}
11281133

@@ -1132,7 +1137,8 @@ module Opcode {
11321137
* See the `BufferReadSideEffectInstruction` documentation for more details.
11331138
*/
11341139
class BufferReadSideEffect extends ReadSideEffectOpcode, UnsizedBufferReadOpcode,
1135-
TBufferReadSideEffect {
1140+
TBufferReadSideEffect
1141+
{
11361142
final override string toString() { result = "BufferReadSideEffect" }
11371143
}
11381144

@@ -1142,7 +1148,8 @@ module Opcode {
11421148
* See the `BufferMustWriteSideEffectInstruction` documentation for more details.
11431149
*/
11441150
class BufferMustWriteSideEffect extends WriteSideEffectOpcode, UnsizedBufferWriteOpcode,
1145-
TBufferMustWriteSideEffect {
1151+
TBufferMustWriteSideEffect
1152+
{
11461153
final override string toString() { result = "BufferMustWriteSideEffect" }
11471154
}
11481155

@@ -1152,7 +1159,8 @@ module Opcode {
11521159
* See the `BufferMayWriteSideEffectInstruction` documentation for more details.
11531160
*/
11541161
class BufferMayWriteSideEffect extends WriteSideEffectOpcode, UnsizedBufferWriteOpcode,
1155-
MayWriteOpcode, TBufferMayWriteSideEffect {
1162+
MayWriteOpcode, TBufferMayWriteSideEffect
1163+
{
11561164
final override string toString() { result = "BufferMayWriteSideEffect" }
11571165
}
11581166

@@ -1162,7 +1170,8 @@ module Opcode {
11621170
* See the `SizedBufferReadSideEffectInstruction` documentation for more details.
11631171
*/
11641172
class SizedBufferReadSideEffect extends ReadSideEffectOpcode, SizedBufferReadOpcode,
1165-
TSizedBufferReadSideEffect {
1173+
TSizedBufferReadSideEffect
1174+
{
11661175
final override string toString() { result = "SizedBufferReadSideEffect" }
11671176
}
11681177

@@ -1172,7 +1181,8 @@ module Opcode {
11721181
* See the `SizedBufferMustWriteSideEffectInstruction` documentation for more details.
11731182
*/
11741183
class SizedBufferMustWriteSideEffect extends WriteSideEffectOpcode, SizedBufferWriteOpcode,
1175-
TSizedBufferMustWriteSideEffect {
1184+
TSizedBufferMustWriteSideEffect
1185+
{
11761186
final override string toString() { result = "SizedBufferMustWriteSideEffect" }
11771187
}
11781188

@@ -1182,7 +1192,8 @@ module Opcode {
11821192
* See the `SizedBufferMayWriteSideEffectInstruction` documentation for more details.
11831193
*/
11841194
class SizedBufferMayWriteSideEffect extends WriteSideEffectOpcode, SizedBufferWriteOpcode,
1185-
MayWriteOpcode, TSizedBufferMayWriteSideEffect {
1195+
MayWriteOpcode, TSizedBufferMayWriteSideEffect
1196+
{
11861197
final override string toString() { result = "SizedBufferMayWriteSideEffect" }
11871198
}
11881199

@@ -1192,7 +1203,8 @@ module Opcode {
11921203
* See the `InitializeDynamicAllocationInstruction` documentation for more details.
11931204
*/
11941205
class InitializeDynamicAllocation extends SideEffectOpcode, EntireAllocationWriteOpcode,
1195-
TInitializeDynamicAllocation {
1206+
TInitializeDynamicAllocation
1207+
{
11961208
final override string toString() { result = "InitializeDynamicAllocation" }
11971209
}
11981210

@@ -1221,7 +1233,8 @@ module Opcode {
12211233
* See the `InlineAsmInstruction` documentation for more details.
12221234
*/
12231235
class InlineAsm extends Opcode, EscapedWriteOpcode, MayWriteOpcode, EscapedReadOpcode,
1224-
MayReadOpcode, TInlineAsm {
1236+
MayReadOpcode, TInlineAsm
1237+
{
12251238
final override string toString() { result = "InlineAsm" }
12261239

12271240
final override predicate hasOperandInternal(OperandTag tag) {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ class VariableMemoryLocation extends TVariableMemoryLocation, AllocationMemoryLo
246246
}
247247

248248
class EntireAllocationMemoryLocation extends TEntireAllocationMemoryLocation,
249-
AllocationMemoryLocation {
249+
AllocationMemoryLocation
250+
{
250251
EntireAllocationMemoryLocation() { this = TEntireAllocationMemoryLocation(var, isMayAccess) }
251252

252253
final override string toStringInternal() { result = var.toString() }

0 commit comments

Comments
 (0)