Skip to content

Commit 32f41de

Browse files
authored
Merge branch 'main' into amammad-go-fastHttp
2 parents bb30689 + 56f8d5d commit 32f41de

591 files changed

Lines changed: 87092 additions & 89820 deletions

File tree

Some content is hidden

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

.github/labeler.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ documentation:
4545

4646
# Since these are all shared files that need to be synced, just pick _one_ copy of each.
4747
"DataFlow Library":
48-
- "java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll"
49-
- "java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplCommon.qll"
50-
- "java/ql/lib/semmle/code/java/dataflow/internal/tainttracking1/TaintTrackingImpl.qll"
51-
- "java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplConsistency.qll"
52-
- "java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll"
48+
- "shared/dataflow/**/*"
5349

5450
"ATM":
5551
- javascript/ql/experimental/adaptivethreatmodeling/**/*

.github/workflows/csharp-qltest.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
slice: ["1/2", "2/2"]
5454
steps:
5555
- uses: actions/checkout@v4
56-
- uses: ./.github/actions/fetch-codeql
5756
- uses: ./csharp/actions/create-extractor-pack
5857
- name: Cache compilation cache
5958
id: query-cache
@@ -62,12 +61,7 @@ jobs:
6261
key: csharp-qltest-${{ matrix.slice }}
6362
- name: Run QL tests
6463
run: |
65-
CODEQL_PATH=$(gh codeql version --format=json | jq -r .unpackedLocation)
66-
# The legacy ASP extractor is not in this repo, so take the one from the nightly build
67-
mv "$CODEQL_PATH/csharp/tools/extractor-asp.jar" "${{ github.workspace }}/csharp/extractor-pack/tools"
68-
# Safe guard against using the bundled extractor
69-
rm -rf "$CODEQL_PATH/csharp"
70-
codeql test run --threads=0 --ram 50000 --slice ${{ matrix.slice }} --search-path "${{ github.workspace }}/csharp/extractor-pack" --check-databases --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
64+
codeql test run --threads=0 --ram 50000 --slice ${{ matrix.slice }} --search-path extractor-pack --check-databases --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
7165
env:
7266
GITHUB_TOKEN: ${{ github.token }}
7367
unit-tests:
@@ -80,7 +74,24 @@ jobs:
8074
dotnet-version: 7.0.102
8175
- name: Extractor unit tests
8276
run: |
83-
dotnet test -p:RuntimeFrameworkVersion=7.0.2 "${{ github.workspace }}/csharp/extractor/Semmle.Util.Tests"
84-
dotnet test -p:RuntimeFrameworkVersion=7.0.2 "${{ github.workspace }}/csharp/extractor/Semmle.Extraction.Tests"
85-
dotnet test -p:RuntimeFrameworkVersion=7.0.2 "${{ github.workspace }}/csharp/autobuilder/Semmle.Autobuild.CSharp.Tests"
77+
dotnet test -p:RuntimeFrameworkVersion=7.0.2 extractor/Semmle.Util.Tests
78+
dotnet test -p:RuntimeFrameworkVersion=7.0.2 extractor/Semmle.Extraction.Tests
79+
dotnet test -p:RuntimeFrameworkVersion=7.0.2 autobuilder/Semmle.Autobuild.CSharp.Tests
8680
dotnet test -p:RuntimeFrameworkVersion=7.0.2 "${{ github.workspace }}/cpp/autobuilder/Semmle.Autobuild.Cpp.Tests"
81+
stubgentest:
82+
runs-on: ubuntu-latest
83+
steps:
84+
- uses: actions/checkout@v4
85+
- uses: ./csharp/actions/create-extractor-pack
86+
- name: Run stub generator tests
87+
run: |
88+
# Generate (Asp)NetCore stubs
89+
STUBS_PATH=stubs_output
90+
python3 ql/src/Stubs/make_stubs_nuget.py webapp Swashbuckle.AspNetCore.Swagger latest "$STUBS_PATH"
91+
rm -rf ql/test/resources/stubs/_frameworks
92+
# Update existing stubs in the repo with the freshly generated ones
93+
mv "$STUBS_PATH/output/stubs/_frameworks" ql/test/resources/stubs/
94+
git status
95+
codeql test run --threads=0 --search-path extractor-pack --check-databases --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries -- ql/test/library-tests/dataflow/flowsources/aspremote
96+
env:
97+
GITHUB_TOKEN: ${{ github.token }}

config/identical-files.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl4.qll",
2929
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImpl1.qll",
3030
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImpl2.qll",
31-
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplForHttpClientLibraries.qll",
32-
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplForPathname.qll",
3331
"swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImpl1.qll"
3432
],
3533
"TaintTracking Legacy Configuration Java/C++/C#/Go/Python/Ruby/Swift": [
@@ -552,4 +550,4 @@
552550
"python/ql/test/experimental/dataflow/model-summaries/InlineTaintTest.ext.yml",
553551
"python/ql/test/experimental/dataflow/model-summaries/NormalDataflowTest.ext.yml"
554552
]
555-
}
553+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private class GuardConditionFromIR extends GuardCondition {
240240
*/
241241
private predicate controlsBlock(BasicBlock controlled, boolean testIsTrue) {
242242
exists(IRBlock irb |
243-
forex(IRGuardCondition inst | inst = ir | inst.controls(irb, testIsTrue)) and
243+
ir.controls(irb, testIsTrue) and
244244
irb.getAnInstruction().getAst().(ControlFlowNode).getBasicBlock() = controlled and
245245
not isUnreachedBlock(irb)
246246
)

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,3 @@ class ArgumentPosition extends int {
7979
/** Holds if arguments at position `apos` match parameters at position `ppos`. */
8080
pragma[inline]
8181
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos = apos }
82-
83-
/**
84-
* Holds if flow from `call`'s argument `arg` to parameter `p` is permissible.
85-
*
86-
* This is a temporary hook to support technical debt in the Go language; do not use.
87-
*/
88-
pragma[inline]
89-
predicate golangSpecificParamArgFilter(DataFlowCall call, ParameterNode p, ArgumentNode arg) {
90-
any()
91-
}

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ predicate expectsContent(Node n, ContentSet c) { none() }
208208

209209
predicate typeStrongerThan(DataFlowType t1, DataFlowType t2) { none() }
210210

211+
predicate localMustFlowStep(Node node1, Node node2) { none() }
212+
211213
/** Gets the type of `n` used for type pruning. */
212214
Type getNodeType(Node n) {
213215
suppressUnusedNode(n) and
@@ -295,12 +297,3 @@ class ContentApprox = Unit;
295297
/** Gets an approximated value for content `c`. */
296298
pragma[inline]
297299
ContentApprox getContentApprox(Content c) { any() }
298-
299-
/**
300-
* Gets an additional term that is added to the `join` and `branch` computations to reflect
301-
* an additional forward or backwards branching factor that is not taken into account
302-
* when calculating the (virtual) dispatch cost.
303-
*
304-
* Argument `arg` is part of a path from a source to a sink, and `p` is the target parameter.
305-
*/
306-
int getAdditionalFlowIntoCallNodeTerm(ArgumentNode arg, ParameterNode p) { none() }

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,3 @@ DataFlowCallable viableImplInCallContext(DataFlowCall call, DataFlowCall ctx) {
271271
/** Holds if arguments at position `apos` match parameters at position `ppos`. */
272272
pragma[inline]
273273
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos = apos }
274-
275-
/**
276-
* Holds if flow from `call`'s argument `arg` to parameter `p` is permissible.
277-
*
278-
* This is a temporary hook to support technical debt in the Go language; do not use.
279-
*/
280-
pragma[inline]
281-
predicate golangSpecificParamArgFilter(DataFlowCall call, ParameterNode p, ArgumentNode arg) {
282-
any()
283-
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ module CppDataFlow implements InputSig {
1818
import Public
1919

2020
Node exprNode(DataFlowExpr e) { result = Public::exprNode(e) }
21+
22+
predicate getAdditionalFlowIntoCallNodeTerm = Private::getAdditionalFlowIntoCallNodeTerm/2;
2123
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,8 @@ predicate expectsContent(Node n, ContentSet c) { none() }
804804

805805
predicate typeStrongerThan(DataFlowType t1, DataFlowType t2) { none() }
806806

807+
predicate localMustFlowStep(Node node1, Node node2) { none() }
808+
807809
/** Gets the type of `n` used for type pruning. */
808810
DataFlowType getNodeType(Node n) {
809811
suppressUnusedNode(n) and

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,15 +1066,28 @@ private module GetConvertedResultExpression {
10661066
private import semmle.code.cpp.ir.implementation.raw.internal.TranslatedExpr
10671067
private import semmle.code.cpp.ir.implementation.raw.internal.InstructionTag
10681068

1069+
private Operand getAnInitializeDynamicAllocationInstructionAddress() {
1070+
result = any(InitializeDynamicAllocationInstruction init).getAllocationAddressOperand()
1071+
}
1072+
10691073
/**
10701074
* Gets the expression that should be returned as the result expression from `instr`.
10711075
*
1072-
* Note that this predicate may return multiple results in cases where a conversion belond to a
1076+
* Note that this predicate may return multiple results in cases where a conversion belongs to a
10731077
* different AST element than its operand.
10741078
*/
10751079
Expr getConvertedResultExpression(Instruction instr, int n) {
1076-
// Only fully converted instructions has a result for `asConvertedExpr`
1077-
not conversionFlow(unique( | | getAUse(instr)), _, false, false) and
1080+
// Only fully converted instructions have a result for `asConvertedExpr`
1081+
not conversionFlow(unique(Operand op |
1082+
// The address operand of a `InitializeDynamicAllocationInstruction` is
1083+
// special: we need to handle it during dataflow (since it's
1084+
// effectively a store to an indirection), but it doesn't appear in
1085+
// source syntax, so dataflow node <-> expression conversion shouldn't
1086+
// care about it.
1087+
op = getAUse(instr) and not op = getAnInitializeDynamicAllocationInstructionAddress()
1088+
|
1089+
op
1090+
), _, false, false) and
10781091
result = getConvertedResultExpressionImpl(instr) and
10791092
n = 0
10801093
or
@@ -1341,6 +1354,9 @@ class ParameterNode extends Node {
13411354
* pointer-indirection parameters are at further negative positions.
13421355
*/
13431356
predicate isParameterOf(Function f, ParameterPosition pos) { none() } // overridden by subclasses
1357+
1358+
/** Gets the `Parameter` associated with this node, if it exists. */
1359+
Parameter getParameter() { none() } // overridden by subclasses
13441360
}
13451361

13461362
/** An explicit positional parameter, including `this`, but not `...`. */
@@ -1363,10 +1379,9 @@ private class ExplicitParameterNode extends ParameterNode, DirectParameterNode {
13631379
f.getParameter(pos.(DirectPosition).getIndex()) = instr.getParameter()
13641380
}
13651381

1366-
/** Gets the `Parameter` associated with this node. */
1367-
Parameter getParameter() { result = instr.getParameter() }
1368-
13691382
override string toStringImpl() { result = instr.getParameter().toString() }
1383+
1384+
override Parameter getParameter() { result = instr.getParameter() }
13701385
}
13711386

13721387
/** An implicit `this` parameter. */

0 commit comments

Comments
 (0)