Skip to content

Commit 3e61d1d

Browse files
committed
Merge branch 'main' into next
2 parents 20c1f72 + 1658a17 commit 3e61d1d

File tree

66 files changed

+618
-545
lines changed

Some content is hidden

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

66 files changed

+618
-545
lines changed
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 }}

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

c/cert/src/rules/EXP36-C/DoNotCastPointerToMoreStrictlyAlignedPointerType.ql

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ import cpp
1515
import codingstandards.c.cert
1616
import codingstandards.cpp.Alignment
1717
import codingstandards.cpp.dataflow.DataFlow
18-
import codingstandards.cpp.dataflow.DataFlow2
1918
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
20-
import DataFlow::PathGraph
19+
import ExprWithAlignmentToCStyleCastFlow::PathGraph
2120

2221
/**
2322
* An expression with a type that has defined alignment requirements
@@ -96,8 +95,7 @@ class UnconvertedCastFromNonVoidPointerExpr extends Expr {
9695
*/
9796
class DefaultAlignedPointerExpr extends UnconvertedCastFromNonVoidPointerExpr, ExprWithAlignment {
9897
DefaultAlignedPointerExpr() {
99-
not any(AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprConfig config)
100-
.hasFlowTo(DataFlow::exprNode(this))
98+
not AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprFlow::flowTo(DataFlow::exprNode(this))
10199
}
102100

103101
override int getAlignment() { result = this.getType().(PointerType).getBaseType().getAlignment() }
@@ -118,43 +116,37 @@ class DefaultAlignedPointerExpr extends UnconvertedCastFromNonVoidPointerExpr, E
118116
* to exclude an `DefaultAlignedPointerAccessExpr` as a source if a preceding source
119117
* defined by this configuration provides more accurate alignment information.
120118
*/
121-
class AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprConfig extends DataFlow2::Configuration
119+
module AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprConfig implements
120+
DataFlow::ConfigSig
122121
{
123-
AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprConfig() {
124-
this = "AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprConfig"
125-
}
126-
127-
override predicate isSource(DataFlow::Node source) {
122+
predicate isSource(DataFlow::Node source) {
128123
source.asExpr() instanceof AddressOfAlignedVariableExpr or
129124
source.asExpr() instanceof DefinedAlignmentAllocationExpr
130125
}
131126

132-
override predicate isSink(DataFlow::Node sink) {
127+
predicate isSink(DataFlow::Node sink) {
133128
sink.asExpr() instanceof UnconvertedCastFromNonVoidPointerExpr
134129
}
135130
}
136131

132+
module AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprFlow =
133+
DataFlow::Global<AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprConfig>;
134+
137135
/**
138136
* A data-flow configuration for analysing the flow of `ExprWithAlignment` pointer expressions
139137
* to casts which perform pointer type conversions and potentially create pointer alignment issues.
140138
*/
141-
class ExprWithAlignmentToCStyleCastConfiguration extends DataFlow::Configuration {
142-
ExprWithAlignmentToCStyleCastConfiguration() {
143-
this = "ExprWithAlignmentToCStyleCastConfiguration"
144-
}
139+
module ExprWithAlignmentToCStyleCastConfig implements DataFlow::ConfigSig {
140+
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof ExprWithAlignment }
145141

146-
override predicate isSource(DataFlow::Node source) {
147-
source.asExpr() instanceof ExprWithAlignment
148-
}
149-
150-
override predicate isSink(DataFlow::Node sink) {
142+
predicate isSink(DataFlow::Node sink) {
151143
exists(CStyleCast cast |
152144
cast.getUnderlyingType() instanceof PointerType and
153145
cast.getUnconverted() = sink.asExpr()
154146
)
155147
}
156148

157-
override predicate isBarrierOut(DataFlow::Node node) {
149+
predicate isBarrierOut(DataFlow::Node node) {
158150
// the default interprocedural data-flow model flows through any array assignment expressions
159151
// to the qualifier (array base or pointer dereferenced) instead of the individual element
160152
// that the assignment modifies. this default behaviour causes false positives for any future
@@ -169,12 +161,15 @@ class ExprWithAlignmentToCStyleCastConfiguration extends DataFlow::Configuration
169161
}
170162
}
171163

164+
module ExprWithAlignmentToCStyleCastFlow = DataFlow::Global<ExprWithAlignmentToCStyleCastConfig>;
165+
172166
from
173-
DataFlow::PathNode source, DataFlow::PathNode sink, ExprWithAlignment expr, CStyleCast cast,
167+
ExprWithAlignmentToCStyleCastFlow::PathNode source,
168+
ExprWithAlignmentToCStyleCastFlow::PathNode sink, ExprWithAlignment expr, CStyleCast cast,
174169
Type toBaseType, int alignmentFrom, int alignmentTo
175170
where
176171
not isExcluded(cast, Pointers3Package::doNotCastPointerToMoreStrictlyAlignedPointerTypeQuery()) and
177-
any(ExprWithAlignmentToCStyleCastConfiguration config).hasFlowPath(source, sink) and
172+
ExprWithAlignmentToCStyleCastFlow::flowPath(source, sink) and
178173
source.getNode().asExpr() = expr and
179174
sink.getNode().asExpr() = cast.getUnconverted() and
180175
toBaseType = cast.getActualType().(PointerType).getBaseType() and

0 commit comments

Comments
 (0)