Skip to content

Commit 03fffb2

Browse files
authored
Merge branch 'main' into lcartey/m8-5-2-aggregate-variadic
2 parents 0526f8a + 4d804eb commit 03fffb2

File tree

125 files changed

+1043
-703
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

+1043
-703
lines changed

.github/workflows/tooling-unit-tests.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,22 @@ jobs:
9696
- name: Run PyTest
9797
run: |
9898
pytest scripts/guideline_recategorization/recategorize_test.py
99+
100+
release-tests:
101+
name: Run release tests
102+
runs-on: ubuntu-22.04
103+
steps:
104+
- name: Checkout
105+
uses: actions/checkout@v2
106+
107+
- name: Install Python
108+
uses: actions/setup-python@v4
109+
with:
110+
python-version: "3.9"
111+
112+
- name: Install Python dependencies
113+
run: pip install -r scripts/release/requirements.txt
114+
115+
- name: Run PyTest
116+
run: |
117+
pytest scripts/release/update_release_assets_test.py
Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
name: "Update Release Status"
22
on:
3-
check_run:
4-
types:
5-
- completed
6-
- rerequested
7-
branches:
8-
- "rc/**"
9-
103
workflow_dispatch:
114
inputs:
125
head-sha:
@@ -20,40 +13,36 @@ permissions:
2013
checks: write
2114
contents: write
2215

16+
env:
17+
HEAD_SHA: ${{ inputs.head-sha }}
18+
2319
jobs:
2420
validate-check-runs:
2521
runs-on: ubuntu-22.04
2622
outputs:
2723
status: ${{ steps.set-output.outputs.status }}
28-
check-run-head-sha: ${{ steps.set-output.outputs.check-run-head-sha }}
24+
conclusion: ${{ steps.set-output.outputs.conclusion }}
2925
steps:
30-
- name: Determine check run head SHA
31-
env:
32-
HEAD_SHA_FROM_EVENT: ${{ github.event.check_run.head_sha }}
33-
HEAD_SHA_FROM_INPUTS: ${{ inputs.head-sha }}
34-
run: |
35-
if [[ $GITHUB_EVENT_NAME == "workflow_dispatch" ]]; then
36-
echo "CHECK_RUN_HEAD_SHA=$HEAD_SHA_FROM_INPUTS" >> "$GITHUB_ENV"
37-
else
38-
echo "CHECK_RUN_HEAD_SHA=$HEAD_SHA_FROM_EVENT" >> "$GITHUB_ENV"
39-
fi
40-
4126
- name: Checkout
4227
uses: actions/checkout@v4
4328
with:
44-
ref: ${{ env.CHECK_RUN_HEAD_SHA }}
29+
ref: ${{ inputs.head-sha }}
4530

4631
- name: Get release status check run
4732
id: get-check-run
48-
if: (github.event_name == 'check_run' && github.event.check_run.conclusion == 'success' && github.event.check_run.name != github.workflow) || github.event_name == 'workflow_dispatch'
4933
env:
5034
GITHUB_TOKEN: ${{ github.token }}
5135
run: |
5236
check_run_info=$(gh api \
5337
--header "Accept: application/vnd.github+json" \
5438
--header "X-GitHub-Api-Version: 2022-11-28" \
5539
--jq '.check_runs[] | select(.name == "release-status") | {id: .id, status: .status, conclusion: .conclusion}' \
56-
/repos/$GITHUB_REPOSITORY/commits/$CHECK_RUN_HEAD_SHA/check-runs)
40+
/repos/$GITHUB_REPOSITORY/commits/$HEAD_SHA/check-runs)
41+
42+
if [[ -z "$check_run_info" ]]; then
43+
echo "No release status check run found"
44+
exit 1
45+
fi
5746
5847
check_run_id=$(echo "$check_run_info" | jq -r '.id')
5948
check_run_status=$(echo "$check_run_info" | jq -r '.status')
@@ -64,19 +53,22 @@ jobs:
6453
echo "CHECK_RUN_CONCLUSION=$check_run_conclusion" >> "$GITHUB_ENV"
6554
6655
- name: Reset release status
67-
if: env.CHECK_RUN_STATUS == 'completed' && ((github.event_name == 'check_run' && github.event.action == 'rerequested') || github.event_name == 'workflow_dispatch')
56+
if: env.CHECK_RUN_STATUS == 'completed'
6857
env:
6958
GITHUB_TOKEN: ${{ github.token }}
7059
run: |
71-
CHECK_RUN_ID=$(gh api \
60+
check_run_id=$(gh api \
7261
--header "Accept: application/vnd.github+json" \
7362
--header "X-GitHub-Api-Version: 2022-11-28" \
7463
--field name="release-status" \
75-
--field head_sha="$CHECK_RUN_HEAD_SHA" \
64+
--field head_sha="$HEAD_SHA" \
7665
--jq ".id" \
7766
/repos/$GITHUB_REPOSITORY/check-runs)
7867
79-
echo "Created release status check run with id $CHECK_RUN_ID"
68+
echo "Created release status check run with id $check_run_id"
69+
# Reset the status to in progress.
70+
echo "CHECK_RUN_STATUS=in_progress" >> "$GITHUB_ENV"
71+
echo "CHECK_RUN_ID=$check_run_id" >> "$GITHUB_ENV"
8072
8173
- name: Check all runs completed
8274
if: env.CHECK_RUN_STATUS != 'completed'
@@ -87,10 +79,12 @@ jobs:
8779
--header "Accept: application/vnd.github+json" \
8880
--header "X-GitHub-Api-Version: 2022-11-28" \
8981
--jq '.check_runs | map(select(.name != "release-status"))' \
90-
/repos/$GITHUB_REPOSITORY/commits/$CHECK_RUN_HEAD_SHA/check-runs)
82+
/repos/$GITHUB_REPOSITORY/commits/$HEAD_SHA/check-runs)
9183
9284
status_stats=$(echo "$check_runs" | jq -r '. | {failed: (map(select(.conclusion == "failure")) | length), pending: (map(select(.status != "completed")) | length) }')
9385
86+
echo "status_stats=$status_stats"
87+
9488
failed=$(echo "$status_stats" | jq -r '.failed')
9589
pending=$(echo "$status_stats" | jq -r '.pending')
9690
@@ -101,7 +95,6 @@ jobs:
10195
if: env.CHECK_RUNS_PENDING == '0' && env.CHECK_RUN_STATUS != 'completed'
10296
env:
10397
GITHUB_TOKEN: ${{ github.token }}
104-
CHECK_RUNS_FAILED: ${{ env.check-runs-failed }}
10598
run: |
10699
if [[ "$CHECK_RUNS_FAILED" == "0" ]]; then
107100
echo "All check runs succeeded"
@@ -123,22 +116,23 @@ jobs:
123116
--input - \
124117
/repos/$GITHUB_REPOSITORY/check-runs/$CHECK_RUN_ID
125118
119+
echo "RELEASE_STATUS_CONCLUSION=$conclusion" >> "$GITHUB_ENV"
120+
126121
- name: Set output
127122
id: set-output
128123
run: |
124+
echo "conclusion=$RELEASE_STATUS_CONCLUSION" >> "$GITHUB_OUTPUT"
129125
if [[ "$CHECK_RUNS_PENDING" == "0" ]]; then
130126
echo "status=completed" >> "$GITHUB_OUTPUT"
131127
else
132128
echo "status=in_progress" >> "$GITHUB_OUTPUT"
133129
fi
134130
135-
echo "check-run-head-sha=$CHECK_RUN_HEAD_SHA" >> "$GITHUB_OUTPUT"
136-
137131
update-release:
138132
needs: validate-check-runs
139-
if: needs.validate-check-runs.outputs.status == 'completed'
133+
if: needs.validate-check-runs.outputs.status == 'completed' && needs.validate-check-runs.outputs.conclusion == 'success'
140134
uses: ./.github/workflows/update-release.yml
141135
with:
142-
head-sha: ${{ needs.validate-check-runs.outputs.check-run-head-sha }}
136+
head-sha: ${{ inputs.head-sha }}
143137
secrets:
144138
AUTOMATION_PRIVATE_KEY: ${{ secrets.AUTOMATION_PRIVATE_KEY }}

.github/workflows/update-release.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Checkout
3131
uses: actions/checkout@v4
3232
with:
33-
ref: ${{ inputs.head-sha }}
33+
fetch-depth: 0 # We need the full history to compute the changelog
3434

3535
- name: Install Python
3636
uses: actions/setup-python@v4
@@ -54,13 +54,12 @@ jobs:
5454
GITHUB_TOKEN: ${{ github.token }}
5555
RELEASE_ENGINEERING_TOKEN: ${{ steps.generate-token.outputs.token }}
5656
run: |
57-
python scripts/release/update-release-assets.py \
57+
python scripts/release/update_release_assets.py \
5858
--head-sha $HEAD_SHA \
5959
--layout scripts/release/release-layout.yml \
6060
--repo "$GITHUB_REPOSITORY" \
6161
--github-token "$GITHUB_REPOSITORY:$GITHUB_TOKEN" "github/codeql-coding-standards-release-engineering:$RELEASE_ENGINEERING_TOKEN" \
62-
--skip-checkrun "release-status" \
63-
--skip-checks
62+
--skip-checkrun "release-status"
6463
6564
- name: Update release notes
6665
env:

c/cert/src/rules/ARR37-C/DoNotUsePointerArithmeticOnNonArrayObjectPointers.ql

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@
1414
import cpp
1515
import codingstandards.c.cert
1616
import codingstandards.cpp.dataflow.DataFlow
17-
import DataFlow::PathGraph
17+
import NonArrayPointerToArrayIndexingExprFlow::PathGraph
1818

1919
/**
2020
* A data-flow configuration that tracks flow from an `AddressOfExpr` of a variable
2121
* of `PointerType` that is not also an `ArrayType` to a `PointerArithmeticOrArrayExpr`
2222
*/
23-
class NonArrayPointerToArrayIndexingExprConfig extends DataFlow::Configuration {
24-
NonArrayPointerToArrayIndexingExprConfig() { this = "ArrayToArrayIndexConfig" }
25-
26-
override predicate isSource(DataFlow::Node source) {
23+
module NonArrayPointerToArrayIndexingExprConfig implements DataFlow::ConfigSig {
24+
predicate isSource(DataFlow::Node source) {
2725
exists(AddressOfExpr ao, Type t |
2826
source.asExpr() = ao and
2927
not ao.getOperand() instanceof ArrayExpr and
@@ -35,15 +33,15 @@ class NonArrayPointerToArrayIndexingExprConfig extends DataFlow::Configuration {
3533
)
3634
}
3735

38-
override predicate isSink(DataFlow::Node sink) {
36+
predicate isSink(DataFlow::Node sink) {
3937
exists(PointerArithmeticOrArrayExpr ae |
4038
sink.asExpr() = ae.getPointerOperand() and
4139
not sink.asExpr() instanceof Literal and
4240
not ae.isNonPointerOperandZero()
4341
)
4442
}
4543

46-
override predicate isBarrierOut(DataFlow::Node node) {
44+
predicate isBarrierOut(DataFlow::Node node) {
4745
// the default interprocedural data-flow model flows through any field or array assignment
4846
// expressions to the qualifier (array base, pointer dereferenced, or qualifier) instead of the
4947
// individual element or field that the assignment modifies. this default behaviour causes
@@ -63,6 +61,9 @@ class NonArrayPointerToArrayIndexingExprConfig extends DataFlow::Configuration {
6361
}
6462
}
6563

64+
module NonArrayPointerToArrayIndexingExprFlow =
65+
DataFlow::Global<NonArrayPointerToArrayIndexingExprConfig>;
66+
6667
class PointerArithmeticOrArrayExpr extends Expr {
6768
Expr operand;
6869

@@ -101,9 +102,11 @@ class PointerArithmeticOrArrayExpr extends Expr {
101102
predicate isNonPointerOperandZero() { operand.(Literal).getValue().toInt() = 0 }
102103
}
103104

104-
from DataFlow::PathNode source, DataFlow::PathNode sink
105+
from
106+
NonArrayPointerToArrayIndexingExprFlow::PathNode source,
107+
NonArrayPointerToArrayIndexingExprFlow::PathNode sink
105108
where
106109
not isExcluded(sink.getNode().asExpr(),
107110
InvalidMemory2Package::doNotUsePointerArithmeticOnNonArrayObjectPointersQuery()) and
108-
any(NonArrayPointerToArrayIndexingExprConfig cfg).hasFlowPath(source, sink)
111+
NonArrayPointerToArrayIndexingExprFlow::flowPath(source, sink)
109112
select sink, source, sink, "Pointer arithmetic on non-array object pointer."

c/cert/src/rules/ARR39-C/DoNotAddOrSubtractAScaledIntegerToAPointer.ql

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import cpp
1515
import codingstandards.c.cert
1616
import codingstandards.c.Pointers
1717
import codingstandards.cpp.dataflow.TaintTracking
18-
import DataFlow::PathGraph
18+
import ScaledIntegerPointerArithmeticFlow::PathGraph
1919

2020
/**
2121
* An expression which invokes the `offsetof` macro or `__builtin_offsetof` operation.
@@ -69,12 +69,10 @@ class ScaledIntegerExpr extends Expr {
6969
* A data-flow configuration modeling data-flow from a `ScaledIntegerExpr` to a
7070
* `PointerArithmeticExpr` where the pointer does not point to a 1-byte type.
7171
*/
72-
class ScaledIntegerPointerArithmeticConfig extends DataFlow::Configuration {
73-
ScaledIntegerPointerArithmeticConfig() { this = "ScaledIntegerPointerArithmeticConfig" }
72+
module ScaledIntegerPointerArithmeticConfig implements DataFlow::ConfigSig {
73+
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof ScaledIntegerExpr }
7474

75-
override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof ScaledIntegerExpr }
76-
77-
override predicate isSink(DataFlow::Node sink) {
75+
predicate isSink(DataFlow::Node sink) {
7876
exists(PointerArithmeticExpr pa |
7977
// exclude pointers to 1-byte types as they do not scale
8078
pa.getPointer().getFullyConverted().getType().(DerivedType).getBaseType().getSize() != 1 and
@@ -83,9 +81,13 @@ class ScaledIntegerPointerArithmeticConfig extends DataFlow::Configuration {
8381
}
8482
}
8583

86-
from ScaledIntegerPointerArithmeticConfig config, DataFlow::PathNode src, DataFlow::PathNode sink
84+
module ScaledIntegerPointerArithmeticFlow = DataFlow::Global<ScaledIntegerPointerArithmeticConfig>;
85+
86+
from
87+
ScaledIntegerPointerArithmeticFlow::PathNode src,
88+
ScaledIntegerPointerArithmeticFlow::PathNode sink
8789
where
8890
not isExcluded(sink.getNode().asExpr(),
8991
Pointers2Package::doNotAddOrSubtractAScaledIntegerToAPointerQuery()) and
90-
config.hasFlowPath(src, sink)
92+
ScaledIntegerPointerArithmeticFlow::flowPath(src, sink)
9193
select sink, src, sink, "Scaled integer used in pointer arithmetic."

c/cert/src/rules/CON30-C/CleanUpThreadSpecificStorage.ql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ import codingstandards.cpp.Concurrency
1818
import codingstandards.cpp.dataflow.TaintTracking
1919
import codingstandards.cpp.dataflow.DataFlow
2020

21-
class TssCreateToTssDeleteDataFlowConfiguration extends DataFlow::Configuration {
22-
TssCreateToTssDeleteDataFlowConfiguration() { this = "TssCreateToTssDeleteDataFlowConfiguration" }
23-
24-
override predicate isSource(DataFlow::Node node) {
21+
module TssCreateToTssDeleteConfig implements DataFlow::ConfigSig {
22+
predicate isSource(DataFlow::Node node) {
2523
exists(TSSCreateFunctionCall tsc, Expr e |
2624
// the only requirement of the source is that at some point
2725
// it refers to the key of a create statement
@@ -30,7 +28,7 @@ class TssCreateToTssDeleteDataFlowConfiguration extends DataFlow::Configuration
3028
)
3129
}
3230

33-
override predicate isSink(DataFlow::Node node) {
31+
predicate isSink(DataFlow::Node node) {
3432
exists(TSSDeleteFunctionCall tsd, Expr e |
3533
// the only requirement of a sink is that at some point
3634
// it references the key of a delete call.
@@ -40,15 +38,17 @@ class TssCreateToTssDeleteDataFlowConfiguration extends DataFlow::Configuration
4038
}
4139
}
4240

41+
module TssCreateToTssDeleteFlow = DataFlow::Global<TssCreateToTssDeleteConfig>;
42+
4343
from TSSCreateFunctionCall tcfc
4444
where
4545
not isExcluded(tcfc, Concurrency4Package::cleanUpThreadSpecificStorageQuery()) and
4646
// all calls to `tss_create` must be bookended by calls to tss_delete
4747
// even if a thread is not created.
48-
not exists(TssCreateToTssDeleteDataFlowConfiguration config |
49-
config.hasFlow(DataFlow::definitionByReferenceNodeFromArgument(tcfc.getKey()), _)
48+
not (
49+
TssCreateToTssDeleteFlow::flow(DataFlow::definitionByReferenceNodeFromArgument(tcfc.getKey()), _)
5050
or
51-
config.hasFlow(DataFlow::exprNode(tcfc.getKey()), _)
51+
TssCreateToTssDeleteFlow::flow(DataFlow::exprNode(tcfc.getKey()), _)
5252
)
5353
or
5454
// if a thread is created, we must check additional items

0 commit comments

Comments
 (0)