Skip to content

Commit bfab513

Browse files
authored
Merge branch 'main' into dependabot/pip/scripts/release/gitpython-3.1.37
2 parents 1d3abe8 + 8f8f48f commit bfab513

15 files changed

+135
-54
lines changed

.github/workflows/prepare-release.yml

+18-8
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ on:
1313
required: true
1414
hotfix:
1515
description: |
16-
Whether this is a hotfix release.
16+
Hotfix release.
1717
required: false
1818
default: false
19+
type: boolean
1920

2021
permissions:
2122
contents: write
@@ -29,10 +30,7 @@ env:
2930

3031
jobs:
3132
prepare-release:
32-
outputs:
33-
pull-request-head-sha: ${{ steps.determine-pr-head-sha.outputs.pull-request-head-sha }}
3433
name: "Prepare release"
35-
if: github.event_name == 'workflow_dispatch'
3634
runs-on: ubuntu-22.04
3735
steps:
3836
- name: Checkout
@@ -60,7 +58,7 @@ jobs:
6058
env:
6159
GITHUB_TOKEN: ${{ github.token }}
6260
run: |
63-
release=$(gh release view v$RELEASE_VERSION --json name,isDraft)
61+
release=$( { gh release view "v$RELEASE_VERSION" --json name,isDraft; } || echo "" )
6462
if [[ -z "$release" ]]; then
6563
echo "Release v$RELEASE_VERSION does not exist. Proceeding"
6664
echo "create_draft_release=true" >> "$GITHUB_ENV"
@@ -79,7 +77,7 @@ jobs:
7977
env:
8078
GITHUB_TOKEN: ${{ github.token }}
8179
run: |
82-
release_pr=$(gh pr view rc/$RELEASE_VERSION --json title,state,number)
80+
release_pr=$( { gh pr view "rc/$RELEASE_VERSION" --json title,state,number; } || echo "")
8381
if [[ ! -z "$release_pr" ]]; then
8482
pr_title=$(echo "$release_pr" | jq -r '.title')
8583
pr_state=$(echo "$release_pr" | jq -r '.state')
@@ -143,14 +141,26 @@ jobs:
143141
git commit -m "Update version"
144142
git push
145143
144+
- name: Generate token
145+
id: generate-token
146+
uses: actions/create-github-app-token@eaddb9eb7e4226c68cf4b39f167c83e5bd132b3e
147+
with:
148+
app-id: ${{ vars.AUTOMATION_APP_ID }}
149+
private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}
150+
owner: ${{ github.repository_owner }}
151+
repositories: "codeql-coding-standards"
152+
146153
- name: Create release PR
147154
env:
148-
GITHUB_TOKEN: ${{ secrets.ACTION_DISPATCH_TOKEN }}
155+
# Use the token from the `generate-token` step because we can't use the default workflow token
156+
# to create a PR and generate PR events to trigger the next workflow because of recursive workflow
157+
# trigger protection.
158+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
149159
run: |
150160
gh pr create \
151161
-R $GITHUB_REPOSITORY \
152162
--title "Release v$RELEASE_VERSION" \
153163
--body "This PR releases codeql-coding-standards version $RELEASE_VERSION." \
154164
--base rc/$RELEASE_VERSION \
155165
--head feature/update-user-manual-for-$RELEASE_VERSION \
156-
--draft
166+
--draft

.github/workflows/update-release-status.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@ jobs:
139139
if: needs.validate-check-runs.outputs.status == 'completed'
140140
uses: ./.github/workflows/update-release.yml
141141
with:
142-
head-sha: ${{ needs.validate-check-runs.outputs.check-run-head-sha }}
142+
head-sha: ${{ needs.validate-check-runs.outputs.check-run-head-sha }}
143143
secrets:
144-
RELEASE_ENGINEERING_TOKEN: ${{ secrets.RELEASE_ENGINEERING_TOKEN }}
144+
AUTOMATION_PRIVATE_KEY: ${{ secrets.AUTOMATION_PRIVATE_KEY }}

.github/workflows/update-release.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ on:
1515
The head SHA of the release PR to use for finalizing the release.
1616
required: true
1717
secrets:
18-
RELEASE_ENGINEERING_TOKEN:
18+
AUTOMATION_PRIVATE_KEY:
1919
description: |
20-
The token to use for accessing the release engineering repository.
20+
The private key to use to generate a token for accessing the release engineering repository.
2121
required: true
2222
env:
2323
HEAD_SHA: ${{ inputs.head-sha }}
@@ -40,10 +40,19 @@ jobs:
4040
- name: Install dependencies
4141
run: pip install -r scripts/release/requirements.txt
4242

43+
- name: Generate token
44+
id: generate-token
45+
uses: actions/create-github-app-token@eaddb9eb7e4226c68cf4b39f167c83e5bd132b3e
46+
with:
47+
app-id: ${{ vars.AUTOMATION_APP_ID }}
48+
private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}
49+
owner: ${{ github.repository_owner }}
50+
repositories: "codeql-coding-standards-release-engineering"
51+
4352
- name: Update release assets
4453
env:
4554
GITHUB_TOKEN: ${{ github.token }}
46-
RELEASE_ENGINEERING_TOKEN: ${{ secrets.RELEASE_ENGINEERING_TOKEN }}
55+
RELEASE_ENGINEERING_TOKEN: ${{ steps.generate-token.outputs.token }}
4756
run: |
4857
python scripts/release/update-release-assets.py \
4958
--head-sha $HEAD_SHA \

.github/workflows/validate-release.yml

+26-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ env:
1414
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
1515

1616
jobs:
17-
1817
pre-validate-performance:
1918
outputs:
2019
check-run-id: ${{ steps.create-check-run.outputs.check-run-id }}
@@ -39,10 +38,18 @@ jobs:
3938
needs: pre-validate-performance
4039
runs-on: ubuntu-22.04
4140
steps:
41+
- name: Generate token
42+
id: generate-token
43+
uses: actions/create-github-app-token@eaddb9eb7e4226c68cf4b39f167c83e5bd132b3e
44+
with:
45+
app-id: ${{ vars.AUTOMATION_APP_ID }}
46+
private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}
47+
owner: ${{ github.repository_owner }}
48+
repositories: "codeql-coding-standards-release-engineering"
4249
- name: Invoke performance test
4350
env:
4451
CHECK_RUN_ID: ${{ needs.pre-validate-performance.outputs.check-run-id }}
45-
GH_TOKEN: ${{ secrets.RELEASE_ENGINEERING_TOKEN }}
52+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
4653
run: |
4754
jq -n \
4855
--arg ref "$HEAD_SHA" \
@@ -51,8 +58,7 @@ jobs:
5158
| \
5259
gh workflow run release-performance-testing.yml \
5360
--json \
54-
-R github/codeql-coding-standards-release-engineering \
55-
--ref rvermeulen/release-process
61+
-R github/codeql-coding-standards-release-engineering
5662
5763
on-failure-validate-performance-dispatch:
5864
needs: [pre-validate-performance, validate-performance]
@@ -61,8 +67,8 @@ jobs:
6167
steps:
6268
- name: Fail check run status
6369
env:
64-
CHECK_RUN_ID: ${{ needs.pre-validate-performance.outputs.check-run-id }}
65-
GITHUB_TOKEN: ${{ github.token }}
70+
CHECK_RUN_ID: ${{ needs.pre-validate-performance.outputs.check-run-id }}
71+
GITHUB_TOKEN: ${{ github.token }}
6672
run: |
6773
jq -n \
6874
--arg status "completed" \
@@ -100,10 +106,18 @@ jobs:
100106
needs: pre-validate-compiler-compatibility
101107
runs-on: ubuntu-22.04
102108
steps:
109+
- name: Generate token
110+
id: generate-token
111+
uses: actions/create-github-app-token@eaddb9eb7e4226c68cf4b39f167c83e5bd132b3e
112+
with:
113+
app-id: ${{ vars.AUTOMATION_APP_ID }}
114+
private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}
115+
owner: ${{ github.repository_owner }}
116+
repositories: "codeql-coding-standards-release-engineering"
103117
- name: Invoke compiler compatibility test
104118
env:
105119
CHECK_RUN_ID: ${{ needs.pre-validate-compiler-compatibility.outputs.check-run-id }}
106-
GITHUB_TOKEN: ${{ secrets.RELEASE_ENGINEERING_TOKEN }}
120+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
107121
run: |
108122
jq -n \
109123
--arg ref "$HEAD_SHA" \
@@ -112,18 +126,18 @@ jobs:
112126
| \
113127
gh workflow run release-compiler-validation.yml \
114128
--json \
115-
-R github/codeql-coding-standards-release-engineering \
116-
--ref rvermeulen/release-process
129+
-R github/codeql-coding-standards-release-engineering
117130
118131
on-failure-validate-compiler-compatibility-dispatch:
119-
needs: [pre-validate-compiler-compatibility, validate-compiler-compatibility]
132+
needs:
133+
[pre-validate-compiler-compatibility, validate-compiler-compatibility]
120134
if: failure()
121135
runs-on: ubuntu-22.04
122136
steps:
123137
- name: Fail check run status
124138
env:
125-
CHECK_RUN_ID: ${{ needs.pre-validate-compiler-compatibility.outputs.check-run-id }}
126-
GITHUB_TOKEN: ${{ github.token }}
139+
CHECK_RUN_ID: ${{ needs.pre-validate-compiler-compatibility.outputs.check-run-id }}
140+
GITHUB_TOKEN: ${{ github.token }}
127141
run: |
128142
jq -n \
129143
--arg status "completed" \

c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import cpp
1515
import codingstandards.c.misra
1616
import codingstandards.c.misra.EssentialTypes
17+
import codingstandards.cpp.Bitwise
1718

1819
/**
1920
* Holds if the operator `operator` has an operand `child` that is of an inappropriate essential type
@@ -177,7 +178,7 @@ predicate isInappropriateEssentialType(
177178
child =
178179
[
179180
operator.(BinaryBitwiseOperation).getAnOperand(),
180-
operator.(AssignBitwiseOperation).getAnOperand()
181+
operator.(Bitwise::AssignBitwiseOperation).getAnOperand()
181182
] and
182183
not operator instanceof LShiftExpr and
183184
not operator instanceof RShiftExpr and

c/misra/test/rules/RULE-10-1/test.c

+2
Original file line numberDiff line numberDiff line change
@@ -492,4 +492,6 @@ void pointerType() {
492492
b || b; // COMPLIANT
493493
p || b; // NON_COMPLIANT
494494
b || p; // NON_COMPLIANT
495+
p += 1; // COMPLIANT
496+
p -= 1; // COMPLIANT
495497
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* `M5-0-20`, `M5-0-21`, `RULE-10-1` - exclude pointer assignment operators as bitwise operators.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `M5-0-20` - `BitwiseOperatorOperandsHaveDifferentUnderlyingType.ql`:
2+
- Use the Misra definition of underlying type.

cpp/autosar/src/rules/M5-0-20/BitwiseOperatorOperandsHaveDifferentUnderlyingType.ql

+16-5
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,30 @@
1616

1717
import cpp
1818
import codingstandards.cpp.autosar
19+
import codingstandards.cpp.Bitwise
20+
import codingstandards.cpp.Conversion
1921

2022
predicate isBinaryBitwiseOperation(Operation o, VariableAccess l, VariableAccess r) {
2123
exists(BinaryBitwiseOperation bbo | bbo = o |
2224
l = bbo.getLeftOperand() and r = bbo.getRightOperand()
2325
)
2426
or
25-
exists(AssignBitwiseOperation abo | abo = o | l = abo.getLValue() and r = abo.getRValue())
27+
exists(Bitwise::AssignBitwiseOperation abo | abo = o |
28+
l = abo.getLValue() and
29+
r = abo.getRValue()
30+
)
2631
}
2732

28-
from Operation o, Variable left, Variable right
33+
from
34+
Operation o, VariableAccess left, VariableAccess right, Type leftUnderlyingType,
35+
Type rightUnderlyingType
2936
where
3037
not isExcluded(o, ExpressionsPackage::bitwiseOperatorOperandsHaveDifferentUnderlyingTypeQuery()) and
3138
not o.isFromUninstantiatedTemplate(_) and
32-
isBinaryBitwiseOperation(o, left.getAnAccess(), right.getAnAccess()) and
33-
left.getUnderlyingType() != right.getUnderlyingType()
34-
select o, "Operands of the '" + o.getOperator() + "' operation have different underlying types."
39+
isBinaryBitwiseOperation(o, left, right) and
40+
leftUnderlyingType = MisraConversion::getUnderlyingType(left) and
41+
rightUnderlyingType = MisraConversion::getUnderlyingType(right) and
42+
leftUnderlyingType != rightUnderlyingType
43+
select o,
44+
"Operands of the '" + o.getOperator() + "' operation have different underlying types '" +
45+
leftUnderlyingType.getName() + "' and '" + rightUnderlyingType.getName() + "'."

cpp/autosar/src/rules/M5-0-21/BitwiseOperatorAppliedToSignedTypes.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717

1818
import cpp
1919
import codingstandards.cpp.autosar
20+
import codingstandards.cpp.Bitwise
2021

2122
from Operation o, VariableAccess va
2223
where
2324
not isExcluded(o, ExpressionsPackage::bitwiseOperatorAppliedToSignedTypesQuery()) and
2425
(
2526
o instanceof UnaryBitwiseOperation or
2627
o instanceof BinaryBitwiseOperation or
27-
o instanceof AssignBitwiseOperation
28+
o instanceof Bitwise::AssignBitwiseOperation
2829
) and
2930
o.getAnOperand() = va and
3031
va.getTarget().getUnderlyingType().(IntegralType).isSigned()

cpp/autosar/src/rules/M5-8-1/RightBitShiftOperandIsNegativeOrTooWide.ql

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import cpp
1919
import codingstandards.cpp.autosar
20+
import codingstandards.cpp.Bitwise
2021

2122
class ShiftOperation extends Operation {
2223
Expr leftOperand;
@@ -33,7 +34,7 @@ class ShiftOperation extends Operation {
3334
rightOperand = o.getRightOperand()
3435
)
3536
or
36-
exists(AssignBitwiseOperation o | this = o |
37+
exists(Bitwise::AssignBitwiseOperation o | this = o |
3738
(
3839
o instanceof AssignLShiftExpr
3940
or
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
| test.cpp:18:3:18:6 | ... & ... | Operands of the '&' operation have different underlying types. |
2-
| test.cpp:19:3:19:7 | ... \| ... | Operands of the '\|' operation have different underlying types. |
3-
| test.cpp:20:3:20:7 | ... ^ ... | Operands of the '^' operation have different underlying types. |
4-
| test.cpp:21:3:21:8 | ... << ... | Operands of the '<<' operation have different underlying types. |
5-
| test.cpp:22:3:22:8 | ... >> ... | Operands of the '>>' operation have different underlying types. |
6-
| test.cpp:23:3:23:8 | ... &= ... | Operands of the '&=' operation have different underlying types. |
7-
| test.cpp:24:3:24:8 | ... \|= ... | Operands of the '\|=' operation have different underlying types. |
8-
| test.cpp:25:3:25:8 | ... ^= ... | Operands of the '^=' operation have different underlying types. |
9-
| test.cpp:26:3:26:9 | ... <<= ... | Operands of the '<<=' operation have different underlying types. |
10-
| test.cpp:27:3:27:9 | ... >>= ... | Operands of the '>>=' operation have different underlying types. |
11-
| test.cpp:45:3:45:6 | ... & ... | Operands of the '&' operation have different underlying types. |
12-
| test.cpp:46:3:46:7 | ... \| ... | Operands of the '\|' operation have different underlying types. |
13-
| test.cpp:47:3:47:7 | ... ^ ... | Operands of the '^' operation have different underlying types. |
14-
| test.cpp:48:3:48:8 | ... << ... | Operands of the '<<' operation have different underlying types. |
15-
| test.cpp:49:3:49:8 | ... >> ... | Operands of the '>>' operation have different underlying types. |
16-
| test.cpp:50:3:50:8 | ... &= ... | Operands of the '&=' operation have different underlying types. |
17-
| test.cpp:51:3:51:8 | ... \|= ... | Operands of the '\|=' operation have different underlying types. |
18-
| test.cpp:52:3:52:8 | ... ^= ... | Operands of the '^=' operation have different underlying types. |
19-
| test.cpp:53:3:53:9 | ... <<= ... | Operands of the '<<=' operation have different underlying types. |
20-
| test.cpp:54:3:54:9 | ... >>= ... | Operands of the '>>=' operation have different underlying types. |
21-
| test.cpp:67:3:67:14 | ... << ... | Operands of the '<<' operation have different underlying types. |
1+
| test.cpp:18:3:18:6 | ... & ... | Operands of the '&' operation have different underlying types 'unsigned int' and 'unsigned short'. |
2+
| test.cpp:19:3:19:7 | ... \| ... | Operands of the '\|' operation have different underlying types 'unsigned int' and 'unsigned short'. |
3+
| test.cpp:20:3:20:7 | ... ^ ... | Operands of the '^' operation have different underlying types 'unsigned int' and 'unsigned short'. |
4+
| test.cpp:21:3:21:8 | ... << ... | Operands of the '<<' operation have different underlying types 'unsigned int' and 'unsigned short'. |
5+
| test.cpp:22:3:22:8 | ... >> ... | Operands of the '>>' operation have different underlying types 'unsigned int' and 'unsigned short'. |
6+
| test.cpp:23:3:23:8 | ... &= ... | Operands of the '&=' operation have different underlying types 'unsigned int' and 'unsigned short'. |
7+
| test.cpp:24:3:24:8 | ... \|= ... | Operands of the '\|=' operation have different underlying types 'unsigned int' and 'unsigned short'. |
8+
| test.cpp:25:3:25:8 | ... ^= ... | Operands of the '^=' operation have different underlying types 'unsigned int' and 'unsigned short'. |
9+
| test.cpp:26:3:26:9 | ... <<= ... | Operands of the '<<=' operation have different underlying types 'unsigned int' and 'unsigned short'. |
10+
| test.cpp:27:3:27:9 | ... >>= ... | Operands of the '>>=' operation have different underlying types 'unsigned int' and 'unsigned short'. |
11+
| test.cpp:45:3:45:6 | ... & ... | Operands of the '&' operation have different underlying types 'unsigned char' and 'unsigned short'. |
12+
| test.cpp:46:3:46:7 | ... \| ... | Operands of the '\|' operation have different underlying types 'unsigned char' and 'unsigned short'. |
13+
| test.cpp:47:3:47:7 | ... ^ ... | Operands of the '^' operation have different underlying types 'unsigned char' and 'unsigned short'. |
14+
| test.cpp:48:3:48:8 | ... << ... | Operands of the '<<' operation have different underlying types 'unsigned char' and 'unsigned short'. |
15+
| test.cpp:49:3:49:8 | ... >> ... | Operands of the '>>' operation have different underlying types 'unsigned char' and 'unsigned short'. |
16+
| test.cpp:50:3:50:8 | ... &= ... | Operands of the '&=' operation have different underlying types 'unsigned char' and 'unsigned short'. |
17+
| test.cpp:51:3:51:8 | ... \|= ... | Operands of the '\|=' operation have different underlying types 'unsigned char' and 'unsigned short'. |
18+
| test.cpp:52:3:52:8 | ... ^= ... | Operands of the '^=' operation have different underlying types 'unsigned char' and 'unsigned short'. |
19+
| test.cpp:53:3:53:9 | ... <<= ... | Operands of the '<<=' operation have different underlying types 'unsigned char' and 'unsigned short'. |
20+
| test.cpp:54:3:54:9 | ... >>= ... | Operands of the '>>=' operation have different underlying types 'unsigned char' and 'unsigned short'. |
21+
| test.cpp:67:3:67:14 | ... << ... | Operands of the '<<' operation have different underlying types 'int &' and 'char &'. |

cpp/autosar/test/rules/M5-0-20/test.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,8 @@ void test463_2_instantiations() {
7171
char shift2 = 2;
7272
test463_2(val, shift2);
7373
}
74+
75+
void test_add(char *val) {
76+
int add = 2;
77+
val += add; // COMPLIANT
78+
}

cpp/autosar/test/rules/M5-0-21/test.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ void test() {
4545
u ^= u; // COMPLIANT
4646
u | 0; // COMPLIANT
4747
u |= 0; // COMPLIANT
48+
49+
int *p = 0;
50+
p += 1; // COMPLIANT
51+
p -= 1; // COMPLIANT
4852
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* A library for addressing issues in bitwise operator modelling in our database schema.
3+
*/
4+
5+
private import cpp as cpp
6+
7+
module Bitwise {
8+
/**
9+
* A binary bitwise assign operation, excluding += and -= on pointers, which seem to be erroneously
10+
* included.
11+
*/
12+
class AssignBitwiseOperation extends cpp::AssignBitwiseOperation {
13+
AssignBitwiseOperation() {
14+
// exclude += and -= on pointers, which seem to be erroneously included
15+
// in the database schema
16+
not this instanceof cpp::AssignPointerAddExpr and
17+
not this instanceof cpp::AssignPointerSubExpr
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)