Skip to content

Commit 5518a97

Browse files
authored
Merge branch 'main' into rp/fix-796
2 parents 5ab9f13 + f97ec0f commit 5518a97

File tree

21 files changed

+79
-25
lines changed

21 files changed

+79
-25
lines changed

c/cert/src/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-c-coding-standards
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
description: CERT C 2016
44
suites: codeql-suites
55
license: MIT

c/cert/test/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-c-coding-standards-tests
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

c/common/src/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-c-coding-standards
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
license: MIT
44
dependencies:
55
codeql/common-cpp-coding-standards: '*'

c/common/test/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-c-coding-standards-tests
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

c/misra/src/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-c-coding-standards
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
description: MISRA C 2012
44
suites: codeql-suites
55
license: MIT

c/misra/test/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-c-coding-standards-tests
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `M6-5-3` - `Loops.qll`:
2+
- Fixes #755. Specifies that the access to the loop counter must be via non-const address.

cpp/autosar/src/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/autosar-cpp-coding-standards
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
description: AUTOSAR C++14 Guidelines R22-11, R21-11, R20-11, R19-11 and R19-03
44
suites: codeql-suites
55
license: MIT

cpp/autosar/test/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/autosar-cpp-coding-standards-tests
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

cpp/autosar/test/rules/A18-1-1/test.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ int test_c_arrays() {
1111
int x[100]; // NON_COMPLIANT
1212
constexpr int a[]{0, 1, 2}; // NON_COMPLIANT
1313

14-
__func__; // COMPLAINT
14+
__func__; // COMPLIANT
1515
return 0;
16-
}
16+
}

cpp/autosar/test/rules/M6-5-3/LoopCounterModifiedWithinStatement.expected

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
| test.cpp:25:35:25:35 | x | Loop counters should not be modified within a statement in a for loop. |
33
| test.cpp:36:5:36:5 | x | Loop counters should not be modified within a statement in a for loop. |
44
| test.cpp:43:9:43:9 | i | Loop counters should not be modified within a statement in a for loop. |
5+
| test.cpp:93:15:93:15 | i | Loop counters should not be modified within a statement in a for loop. |

cpp/autosar/test/rules/M6-5-3/test.cpp

+51
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,54 @@ void test_loop_counter_mod_in_side_effect() {
4343
inc(i); // NON_COMPLIANT - modifies `i`
4444
}
4545
}
46+
47+
void test_loop_counter_reference_mod_in_condition() {
48+
auto loop = [](int &i) {
49+
for (; (i++ < 10); i++) { // NON_COMPLIANT
50+
}
51+
};
52+
int i = 0;
53+
loop(i);
54+
}
55+
56+
void test_loop_counter_reference_mod() {
57+
auto loop = [](int &i) {
58+
for (; i < 10; i++) { // COMPLIANT
59+
}
60+
};
61+
int i = 0;
62+
loop(i);
63+
}
64+
65+
void test_loop_const_reference() {
66+
auto loop = []([[maybe_unused]] int const &i) {
67+
for (int i = 0; i < 10; i++) { // COMPLIANT
68+
}
69+
};
70+
int i = 0;
71+
loop(i);
72+
}
73+
74+
void test_loop_counter_reference_mod_in_statement() {
75+
auto loop = [](int &i) {
76+
for (; (i < 10); i++) {
77+
i++; // NON_COMPLIANT
78+
}
79+
};
80+
int i = 0;
81+
loop(i);
82+
}
83+
84+
int const_reference(int const &i) { return i; }
85+
86+
int reference(int &i) { return i; }
87+
88+
int copy(int i) { return i; }
89+
90+
void test_pass_argument_by() {
91+
for (int i = 0; i < 10; i++) {
92+
const_reference(i); // COMPLIANT
93+
reference(i); // NON_COMPLIANT
94+
copy(i); // COMPLIANT
95+
}
96+
}

cpp/cert/src/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-cpp-coding-standards
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
description: CERT C++ 2016
44
suites: codeql-suites
55
license: MIT

cpp/cert/test/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-cpp-coding-standards-tests
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

cpp/common/src/codingstandards/cpp/Loops.qll

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ predicate isLoopCounterModifiedInCondition(ForStmt forLoop, VariableAccess loopC
204204
loopCounterAccess = getAnIterationVariable(forLoop).getAnAccess() and
205205
(
206206
loopCounterAccess.isModified() or
207-
loopCounterAccess.isAddressOfAccess()
207+
loopCounterAccess.isAddressOfAccessNonConst()
208208
)
209209
}
210210

@@ -219,7 +219,7 @@ predicate isLoopCounterModifiedInStatement(
219219
loopCounterAccess = loopCounter.getAnAccess() and
220220
(
221221
loopCounterAccess.isModified() or
222-
loopCounterAccess.isAddressOfAccess()
222+
loopCounterAccess.isAddressOfAccessNonConst()
223223
) and
224224
forLoop.getStmt().getChildStmt*() = loopCounterAccess.getEnclosingStmt()
225225
}

cpp/common/src/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-cpp-coding-standards
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
license: MIT
44
dependencies:
55
codeql/cpp-all: 0.12.9

cpp/common/test/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-cpp-coding-standards-tests
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

cpp/misra/src/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-cpp-coding-standards
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
description: MISRA C++ 2023
44
default-suite: codeql-suites/misra-cpp-default.qls
55
license: MIT

cpp/misra/test/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-cpp-coding-standards-tests
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

cpp/report/src/qlpack.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/report-cpp-coding-standards
2-
version: 2.38.0-dev
2+
version: 2.39.0-dev
33
license: MIT
44
dependencies:
55
codeql/cpp-all: 0.12.9

docs/user_manual.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333

3434
## Release information
3535

36-
This user manual documents release `2.38.0-dev` of the coding standards located at [https://github.com/github/codeql-coding-standards](https://github.com/github/codeql-coding-standards).
36+
This user manual documents release `2.39.0-dev` of the coding standards located at [https://github.com/github/codeql-coding-standards](https://github.com/github/codeql-coding-standards).
3737
The release page documents the release notes and contains the following artifacts part of the release:
3838

3939
- `coding-standards-codeql-packs-2.37.0-dev.zip`: CodeQL packs that can be used with GitHub Code Scanning or the CodeQL CLI as documented in the section _Operating manual_.
40-
- `code-scanning-cpp-query-pack-2.38.0-dev.zip`: Legacy packaging for the queries and scripts to be used with GitHub Code Scanning or the CodeQL CLI as documented in the section _Operating manual_.
41-
- `supported_rules_list_2.38.0-dev.csv`: A Comma Separated File (CSV) containing the supported rules per standard and the queries that implement the rule.
42-
- `supported_rules_list_2.38.0-dev.md`: A Markdown formatted file with a table containing the supported rules per standard and the queries that implement the rule.
43-
- `user_manual_2.38.0-dev.md`: This user manual.
40+
- `code-scanning-cpp-query-pack-2.39.0-dev.zip`: Legacy packaging for the queries and scripts to be used with GitHub Code Scanning or the CodeQL CLI as documented in the section _Operating manual_.
41+
- `supported_rules_list_2.39.0-dev.csv`: A Comma Separated File (CSV) containing the supported rules per standard and the queries that implement the rule.
42+
- `supported_rules_list_2.39.0-dev.md`: A Markdown formatted file with a table containing the supported rules per standard and the queries that implement the rule.
43+
- `user_manual_2.39.0-dev.md`: This user manual.
4444
- `Source Code (zip)`: A zip archive containing the contents of https://github.com/github/codeql-coding-standards
4545
- `Source Code (tar.gz)`: A GZip compressed tar archive containing the contents of https://github.com/github/codeql-coding-standards
4646
- `checksums.txt`: A text file containing sha256 checksums for the aforementioned artifacts.
@@ -573,7 +573,7 @@ This section describes known failure modes for "CodeQL Coding Standards" and des
573573
| | Out of space | Less output. Some files may be only be partially analyzed, or not analyzed at all. | Error reported on the command line. | Increase space. If it remains an issue report space consumption issues via the CodeQL Coding Standards [bug tracker](https://github.com/github/codeql-coding-standards/issues). |
574574
| | False positives | More output. Results are reported which are not violations of the guidelines. | All reported results must be reviewed. | Report false positive issues via the CodeQL Coding Standards [bug tracker](https://github.com/github/codeql-coding-standards/issues). |
575575
| | False negatives | Less output. Violations of the guidelines are not reported. | Other validation and verification processes during software development should be used to complement the analysis performed by CodeQL Coding Standards. | Report false negative issues via the CodeQL Coding Standards [bug tracker](https://github.com/github/codeql-coding-standards/issues). |
576-
| | Modifying coding standard suite | More or less output. If queries are added to the query set more result can be reported. If queries are removed less results might be reported. | All queries supported by the CodeQL Coding Standards are listed in the release artifacts `supported_rules_list_2.38.0-dev.csv` where VERSION is replaced with the used release. The rules in the resulting Sarif file must be cross-referenced with the expected rules in this list to determine the validity of the used CodeQL suite. | Ensure that the CodeQL Coding Standards are not modified in ways that are not documented as supported modifications. |
576+
| | Modifying coding standard suite | More or less output. If queries are added to the query set more result can be reported. If queries are removed less results might be reported. | All queries supported by the CodeQL Coding Standards are listed in the release artifacts `supported_rules_list_2.39.0-dev.csv` where VERSION is replaced with the used release. The rules in the resulting Sarif file must be cross-referenced with the expected rules in this list to determine the validity of the used CodeQL suite. | Ensure that the CodeQL Coding Standards are not modified in ways that are not documented as supported modifications. |
577577
| | Incorrect deviation record specification | More output. Results are reported for guidelines for which a deviation is assigned. | Analysis integrity report lists all deviations and incorrectly specified deviation records with a reason. Ensure that all deviation records are correctly specified. | Ensure that the deviation record is specified according to the specification in the user manual. |
578578
| | Incorrect deviation permit specification | More output. Results are reported for guidelines for which a deviation is assigned. | Analysis integrity report lists all deviations and incorrectly specified deviation permits with a reason. Ensure that all deviation permits are correctly specified. | Ensure that the deviation record is specified according to the specification in the user manual. |
579579
| | Unapproved use of a deviation record | Less output. Results for guideline violations are not reported. | Validate that the deviation record use is approved by verifying the approved-by attribute of the deviation record specification. | Ensure that each raised deviation record is approved by an independent approver through an auditable process. |

0 commit comments

Comments
 (0)