Skip to content

Commit 5a9b562

Browse files
committed
Merge branch 'main' into source-bounded-fast-tc-in-typetracking
2 parents f8bdf92 + 046d0d4 commit 5a9b562

File tree

125 files changed

+6931
-1236
lines changed

Some content is hidden

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

125 files changed

+6931
-1236
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Setup dotnet
3535
uses: actions/setup-dotnet@v4
3636
with:
37-
dotnet-version: 9.0.100
37+
dotnet-version: 9.0.300
3838

3939
- name: Checkout repository
4040
uses: actions/checkout@v5

.github/workflows/csharp-qltest.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ jobs:
4343
- name: Setup dotnet
4444
uses: actions/setup-dotnet@v4
4545
with:
46-
dotnet-version: 9.0.100
46+
dotnet-version: 9.0.300
4747
- name: Extractor unit tests
4848
run: |
4949
dotnet tool restore
50-
dotnet test -p:RuntimeFrameworkVersion=9.0.0 extractor/Semmle.Util.Tests
51-
dotnet test -p:RuntimeFrameworkVersion=9.0.0 extractor/Semmle.Extraction.Tests
52-
dotnet test -p:RuntimeFrameworkVersion=9.0.0 autobuilder/Semmle.Autobuild.CSharp.Tests
53-
dotnet test -p:RuntimeFrameworkVersion=9.0.0 autobuilder/Semmle.Autobuild.Cpp.Tests
50+
dotnet test -p:RuntimeFrameworkVersion=9.0.5 extractor/Semmle.Util.Tests
51+
dotnet test -p:RuntimeFrameworkVersion=9.0.5 extractor/Semmle.Extraction.Tests
52+
dotnet test -p:RuntimeFrameworkVersion=9.0.5 autobuilder/Semmle.Autobuild.CSharp.Tests
53+
dotnet test -p:RuntimeFrameworkVersion=9.0.5 autobuilder/Semmle.Autobuild.Cpp.Tests
5454
shell: bash
5555
stubgentest:
5656
runs-on: ubuntu-latest

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
2626
bazel_dep(name = "fmt", version = "10.0.0")
2727
bazel_dep(name = "rules_kotlin", version = "2.1.3-codeql.1")
2828
bazel_dep(name = "gazelle", version = "0.40.0")
29-
bazel_dep(name = "rules_dotnet", version = "0.17.4")
29+
bazel_dep(name = "rules_dotnet", version = "0.19.2-codeql.1")
3030
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
3131
bazel_dep(name = "rules_rust", version = "0.63.0")
3232
bazel_dep(name = "zstd", version = "1.5.5.bcr.1")
@@ -172,7 +172,7 @@ http_archive(
172172
)
173173

174174
dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
175-
dotnet.toolchain(dotnet_version = "9.0.100")
175+
dotnet.toolchain(dotnet_version = "9.0.300")
176176
use_repo(dotnet, "dotnet_toolchains")
177177

178178
register_toolchains("@dotnet_toolchains//:all")

cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ abstract private class GuardConditionImpl extends Expr {
7272
*/
7373
abstract predicate valueControls(BasicBlock controlled, AbstractValue v);
7474

75+
/**
76+
* Holds if the control-flow edge `(pred, succ)` may be taken only if
77+
* the value of this condition is `v`.
78+
*/
79+
abstract predicate valueControlsEdge(BasicBlock pred, BasicBlock succ, AbstractValue v);
80+
81+
/**
82+
* Holds if the control-flow edge `(pred, succ)` may be taken only if
83+
* this the value of this condition is `testIsTrue`.
84+
*/
85+
final predicate controlsEdge(BasicBlock pred, BasicBlock succ, boolean testIsTrue) {
86+
this.valueControlsEdge(pred, succ, any(BooleanValue bv | bv.getValue() = testIsTrue))
87+
}
88+
7589
/**
7690
* Holds if this condition controls `controlled`, meaning that `controlled` is only
7791
* entered if the value of this condition is `testIsTrue`.
@@ -175,6 +189,58 @@ abstract private class GuardConditionImpl extends Expr {
175189
*/
176190
pragma[inline]
177191
abstract predicate ensuresEq(Expr e, int k, BasicBlock block, boolean areEqual);
192+
193+
/**
194+
* Holds if (determined by this guard) `left == right + k` must be `areEqual` on the edge from
195+
* `pred` to `succ`. If `areEqual = false` then this implies `left != right + k`.
196+
*/
197+
pragma[inline]
198+
final predicate ensuresEqEdge(
199+
Expr left, Expr right, int k, BasicBlock pred, BasicBlock succ, boolean areEqual
200+
) {
201+
exists(boolean testIsTrue |
202+
this.comparesEq(left, right, k, areEqual, testIsTrue) and
203+
this.controlsEdge(pred, succ, testIsTrue)
204+
)
205+
}
206+
207+
/**
208+
* Holds if (determined by this guard) `e == k` must be `areEqual` on the edge from
209+
* `pred` to `succ`. If `areEqual = false` then this implies `e != k`.
210+
*/
211+
pragma[inline]
212+
final predicate ensuresEqEdge(Expr e, int k, BasicBlock pred, BasicBlock succ, boolean areEqual) {
213+
exists(AbstractValue v |
214+
this.comparesEq(e, k, areEqual, v) and
215+
this.valueControlsEdge(pred, succ, v)
216+
)
217+
}
218+
219+
/**
220+
* Holds if (determined by this guard) `left < right + k` must be `isLessThan` on the edge from
221+
* `pred` to `succ`. If `isLessThan = false` then this implies `left >= right + k`.
222+
*/
223+
pragma[inline]
224+
final predicate ensuresLtEdge(
225+
Expr left, Expr right, int k, BasicBlock pred, BasicBlock succ, boolean isLessThan
226+
) {
227+
exists(boolean testIsTrue |
228+
this.comparesLt(left, right, k, isLessThan, testIsTrue) and
229+
this.controlsEdge(pred, succ, testIsTrue)
230+
)
231+
}
232+
233+
/**
234+
* Holds if (determined by this guard) `e < k` must be `isLessThan` on the edge from
235+
* `pred` to `succ`. If `isLessThan = false` then this implies `e >= k`.
236+
*/
237+
pragma[inline]
238+
final predicate ensuresLtEdge(Expr e, int k, BasicBlock pred, BasicBlock succ, boolean isLessThan) {
239+
exists(AbstractValue v |
240+
this.comparesLt(e, k, isLessThan, v) and
241+
this.valueControlsEdge(pred, succ, v)
242+
)
243+
}
178244
}
179245

180246
final class GuardCondition = GuardConditionImpl;
@@ -187,6 +253,16 @@ private class GuardConditionFromBinaryLogicalOperator extends GuardConditionImpl
187253
this.(BinaryLogicalOperation).getAnOperand() instanceof GuardCondition
188254
}
189255

256+
override predicate valueControlsEdge(BasicBlock pred, BasicBlock succ, AbstractValue v) {
257+
exists(BinaryLogicalOperation binop, GuardCondition lhs, GuardCondition rhs |
258+
this = binop and
259+
lhs = binop.getLeftOperand() and
260+
rhs = binop.getRightOperand() and
261+
lhs.valueControlsEdge(pred, succ, v) and
262+
rhs.valueControlsEdge(pred, succ, v)
263+
)
264+
}
265+
190266
override predicate valueControls(BasicBlock controlled, AbstractValue v) {
191267
exists(BinaryLogicalOperation binop, GuardCondition lhs, GuardCondition rhs |
192268
this = binop and
@@ -274,6 +350,25 @@ private predicate controlsBlock(IRGuardCondition ir, BasicBlock controlled, Abst
274350
)
275351
}
276352

353+
/**
354+
* Holds if `ir` controls the `(pred, succ)` edge, meaning that the edge
355+
* `(pred, succ)` is only taken if the value of this condition is `v`. This
356+
* helper predicate does not necessarily hold for binary logical operations
357+
* like `&&` and `||`.
358+
* See the detailed explanation on predicate `controlsEdge`.
359+
*/
360+
private predicate controlsEdge(
361+
IRGuardCondition ir, BasicBlock pred, BasicBlock succ, AbstractValue v
362+
) {
363+
exists(IRBlock irPred, IRBlock irSucc |
364+
ir.valueControlsEdge(irPred, irSucc, v) and
365+
nonExcludedIRAndBasicBlock(irPred, pred) and
366+
nonExcludedIRAndBasicBlock(irSucc, succ) and
367+
not isUnreachedBlock(irPred) and
368+
not isUnreachedBlock(irSucc)
369+
)
370+
}
371+
277372
private class GuardConditionFromNotExpr extends GuardConditionImpl {
278373
IRGuardCondition ir;
279374

@@ -295,6 +390,10 @@ private class GuardConditionFromNotExpr extends GuardConditionImpl {
295390
controlsBlock(ir, controlled, v.getDualValue())
296391
}
297392

393+
override predicate valueControlsEdge(BasicBlock pred, BasicBlock succ, AbstractValue v) {
394+
controlsEdge(ir, pred, succ, v.getDualValue())
395+
}
396+
298397
pragma[inline]
299398
override predicate comparesLt(Expr left, Expr right, int k, boolean isLessThan, boolean testIsTrue) {
300399
exists(Instruction li, Instruction ri |
@@ -383,6 +482,10 @@ private class GuardConditionFromIR extends GuardConditionImpl {
383482
controlsBlock(ir, controlled, v)
384483
}
385484

485+
override predicate valueControlsEdge(BasicBlock pred, BasicBlock succ, AbstractValue v) {
486+
controlsEdge(ir, pred, succ, v)
487+
}
488+
386489
pragma[inline]
387490
override predicate comparesLt(Expr left, Expr right, int k, boolean isLessThan, boolean testIsTrue) {
388491
exists(Instruction li, Instruction ri |

cpp/ql/src/Security/CWE/CWE-295/SSLResultNotChecked.ql

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,9 @@ predicate resultIsChecked(SslGetPeerCertificateCall getCertCall, ControlFlowNode
5555
predicate certIsZero(
5656
SslGetPeerCertificateCall getCertCall, ControlFlowNode node1, ControlFlowNode node2
5757
) {
58-
exists(Expr cert | cert = globalValueNumber(getCertCall).getAnExpr() |
59-
exists(GuardCondition guard, Expr zero |
60-
zero.getValue().toInt() = 0 and
61-
node1 = guard and
62-
(
63-
// if (cert == zero) {
64-
guard.comparesEq(cert, zero, 0, true, true) and
65-
node2 = guard.getATrueSuccessor()
66-
or
67-
// if (cert != zero) { }
68-
guard.comparesEq(cert, zero, 0, false, true) and
69-
node2 = guard.getAFalseSuccessor()
70-
)
71-
)
72-
or
73-
(
74-
// if (cert) { }
75-
node1 = cert
76-
or
77-
// if (!cert) {
78-
node1.(NotExpr).getAChild() = cert
79-
) and
80-
node2 = node1.getASuccessor() and
81-
not cert.(GuardCondition).controls(node2, true) // cert may be false
58+
exists(Expr cert |
59+
cert = globalValueNumber(getCertCall).getAnExpr() and
60+
node1.(GuardCondition).ensuresEqEdge(cert, 0, _, node2.getBasicBlock(), true)
8261
)
8362
}
8463

csharp/actions/create-extractor-pack/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runs:
77
- name: Setup dotnet
88
uses: actions/setup-dotnet@v4
99
with:
10-
dotnet-version: 9.0.100
10+
dotnet-version: 9.0.300
1111
- name: Build Extractor
1212
shell: bash
1313
run: scripts/create-extractor-pack.sh

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public IList<string> GetNugetFeedsFromFolder(string folderPath)
138138
}
139139

140140
// The version number should be kept in sync with the version .NET version used for building the application.
141-
public const string LatestDotNetSdkVersion = "9.0.100";
141+
public const string LatestDotNetSdkVersion = "9.0.300";
142142

143143
/// <summary>
144144
/// Returns a script for downloading relevant versions of the

csharp/paket.main_extension.bzl

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "9.0.100"
3+
"version": "9.0.304"
44
}
5-
}
5+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "9.0.100"
3+
"version": "9.0.304"
44
}
55
}

0 commit comments

Comments
 (0)