Skip to content

Commit 98fdcb4

Browse files
committed
Merge branch 'main' into next
2 parents 40ab697 + a03c176 commit 98fdcb4

34 files changed

+74
-40
lines changed

.codeqlmanifest.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
{ "provide": [ "cpp/*/src/qlpack.yml", "cpp/*/test/qlpack.yml", "c/*/src/qlpack.yml", "c/*/test/qlpack.yml", "scripts/generate_modules/queries/qlpack.yml" ] }
1+
{
2+
"provide": [
3+
"cpp/*/src/qlpack.yml",
4+
"cpp/*/test/qlpack.yml",
5+
"c/*/src/qlpack.yml",
6+
"c/*/test/qlpack.yml",
7+
"scripts/generate_modules/queries/qlpack.yml"
8+
]
9+
}

c/cert/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-c-coding-standards
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
description: CERT C 2016
44
suites: codeql-suites
55
license: MIT

c/cert/test/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-c-coding-standards-tests
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

c/common/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-c-coding-standards
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
license: MIT
44
dependencies:
55
codeql/common-cpp-coding-standards: '*'

c/common/test/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-c-coding-standards-tests
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

c/misra/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-c-coding-standards
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
description: MISRA C 2012
44
suites: codeql-suites
55
license: MIT

c/misra/src/rules/DIR-4-12/StdLibDynamicMemoryAllocationUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import semmle.code.cpp.models.interfaces.Deallocation
2323

2424
from Expr e, string type
2525
where
26-
not isExcluded(e, BannedPackage::memoryAllocDeallocFunctionsOfStdlibhUsedQuery()) and
26+
not isExcluded(e, BannedPackage::stdLibDynamicMemoryAllocationUsedQuery()) and
2727
(
2828
e.(FunctionCall).getTarget().(AllocationFunction).requiresDealloc() and
2929
type = "allocation"

c/misra/src/rules/RULE-11-4/ConversionBetweenPointerToObjectAndIntegerType.ql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ import codingstandards.c.Pointers
1717

1818
from CStyleCast cast, Type typeFrom, Type typeTo
1919
where
20-
not isExcluded(cast, Pointers1Package::castBetweenObjectPointerAndDifferentObjectTypeQuery()) and
20+
not isExcluded(cast, Pointers1Package::conversionBetweenPointerToObjectAndIntegerTypeQuery()) and
2121
typeFrom = cast.getExpr().getUnderlyingType() and
2222
typeTo = cast.getUnderlyingType() and
2323
[typeFrom, typeTo] instanceof IntegralType and
2424
[typeFrom, typeTo] instanceof PointerToObjectType and
2525
not isNullPointerConstant(cast.getExpr())
26-
select cast,
27-
"Cast performed between a pointer to object type and a pointer to an integer type."
26+
select cast, "Cast performed between a pointer to object type and a pointer to an integer type."

c/misra/src/rules/RULE-21-6/StandardLibraryInputoutputFunctionsUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private string wcharInputOutput() {
4040

4141
from FunctionCall fc, Function f
4242
where
43-
not isExcluded(fc, BannedPackage::standardHeaderFileUsedSignalhQuery()) and
43+
not isExcluded(fc, BannedPackage::standardLibraryInputoutputFunctionsUsedQuery()) and
4444
fc.getTarget() = f and
4545
(
4646
f.getName() = stdInputOutput() and

c/misra/src/rules/RULE-21-9/BsearchAndQsortOfStdlibhUsed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import codingstandards.c.misra
1717

1818
from FunctionCall fc, Function f
1919
where
20-
not isExcluded(fc, BannedPackage::terminationFunctionsOfStdlibhUsedQuery()) and
20+
not isExcluded(fc, BannedPackage::bsearchAndQsortOfStdlibhUsedQuery()) and
2121
f = fc.getTarget() and
2222
f.getName() = ["qsort", "bsearch"] and
2323
f.getFile().getBaseName() = "stdlib.h"

c/misra/test/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-c-coding-standards-tests
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* `A7-1-5` - exclude compiler generated variables, such as those generated by for loops.
2+
* `M8-0-1` - exclude compiler generated variables, such as those generated by for loops.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Updated the supported CodeQL version to `2.11.6`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* A number of rules had the wrong query ids attached for deviation purposes. This means they could not be deviated against using the correct ID, but could be incidentally suppressed when deviating a different rule. We have fixed this behavior for the following rules:
2+
- `RULE-11-4`
3+
- `DIR-4-12`
4+
- `RULE-21-6`
5+
- `RULE-21-9`
6+
- `MEM51-CPP`

cpp/autosar/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/autosar-cpp-coding-standards
2-
version: 2.19.0-dev
2+
version: 2.21.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/src/rules/A7-1-5/AutoSpecifierNotUsedAppropriatelyInVariableDefinition.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ where
3434
v.getInitializer().getExpr() instanceof LambdaExpression
3535
or
3636
v.getInitializer().getExpr() instanceof ClassAggregateLiteral
37-
)
37+
) and
38+
// Exclude compiler generated variables
39+
not v.isCompilerGenerated()
3840
select v,
3941
"Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer."

cpp/autosar/src/rules/M8-0-1/MultipleLocalDeclarators.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ import codingstandards.cpp.autosar
2020
from DeclStmt ds
2121
where
2222
not isExcluded(ds, InitializationPackage::multipleLocalDeclaratorsQuery()) and
23-
count(ds.getADeclaration()) > 1
23+
count(Declaration d | d = ds.getADeclaration()) > 1 and
24+
// Not a compiler generated `DeclStmt`, such as in the range-based for loop
25+
not ds.isCompilerGenerated()
2426
select ds, "Declaration list contains more than one declaration."

cpp/autosar/test/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/autosar-cpp-coding-standards-tests
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

cpp/autosar/test/rules/A7-1-5/AutoSpecifierNotUsedAppropriatelyInVariableDefinition.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
| test.cpp:27:8:27:8 | a | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
55
| test.cpp:28:8:28:8 | b | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
66
| test.cpp:81:10:81:10 | a | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |
7+
| test.cpp:111:19:111:19 | a | Use of auto in variable definition is not the result of a function call, lambda expression, or non-fundamental type initializer. |

cpp/autosar/test/rules/A7-1-5/test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,10 @@ void instantiate() {
105105
Test_381<int> t381;
106106
t381.test_381_1();
107107
t381.test_381_2();
108+
}
109+
110+
void test_loop() {
111+
for (const auto a : {8, 9, 10}) {
112+
a;
113+
}
108114
}

cpp/autosar/test/rules/M8-0-1/test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ class ClassA {
1515
int m1, m2; // NON_COMPLIANT
1616
int m3; // COMPLIANT
1717
};
18+
19+
#include <vector>
20+
void test_loop(std::vector<ClassA> v) {
21+
for (const auto b : v) { // COMPLIANT - DeclStmt is compiler generated
22+
b;
23+
}
24+
}

cpp/cert/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-cpp-coding-standards
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
description: CERT C++ 2016
44
suites: codeql-suites
55
license: MIT

cpp/cert/src/rules/MEM51-CPP/ProperlyDeallocateDynamicallyAllocatedResources.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ predicate matching(string allocKind, string deleteKind) {
2626

2727
from Expr alloc, Expr free, Expr freed, string allocKind, string deleteKind
2828
where
29-
not isExcluded(freed, FreedPackage::newDeleteArrayMismatchQuery()) and
29+
not isExcluded(freed, AllocationsPackage::properlyDeallocateDynamicallyAllocatedResourcesQuery()) and
3030
allocReaches(freed, alloc, allocKind) and
3131
freeExprOrIndirect(free, freed, deleteKind) and
3232
not matching(allocKind, deleteKind)

cpp/cert/test/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-cpp-coding-standards-tests
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

cpp/common/src/codingstandards/cpp/lifetimes/lifetimeprofile/LifetimeProfile.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ newtype TPSetEntry =
198198
PSetNull(NullReason nr) or
199199
/** An invalid pointer, for the given reason. */
200200
PSetInvalid(InvalidReason ir) or
201-
/** An unkown pointer. */
201+
/** An unknown pointer. */
202202
PSetUnknown()
203203

204204
/**

cpp/common/src/qlpack.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-cpp-coding-standards
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
license: MIT
44
dependencies:
5-
codeql/cpp-all: 0.4.6
5+
codeql/cpp-all: 0.4.6

cpp/common/test/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-cpp-coding-standards-tests
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

cpp/misra/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-cpp-coding-standards
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
description: MISRA C++ 2008
44
suites: codeql-suites
55
license: MIT

cpp/misra/test/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-cpp-coding-standards-tests
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

cpp/report/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/report-cpp-coding-standards
2-
version: 2.19.0-dev
2+
version: 2.21.0-dev
33
license: MIT
44
dependencies:
55
codeql/cpp-all: 0.4.6

docs/user_manual.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424

2525
## Release information
2626

27-
This user manual documents release `2.19.0-dev` of the coding standards located at [https://github.com/github/codeql-coding-standards](https://github.com/github/codeql-coding-standards).
27+
This user manual documents release `2.21.0-dev` of the coding standards located at [https://github.com/github/codeql-coding-standards](https://github.com/github/codeql-coding-standards).
2828
The release page documents the release notes and contains the following artifacts part of the release:
2929

30-
- `code-scanning-cpp-query-pack-anon-2.19.0-dev.zip`: coding standard queries and scripts to be used with GitHub Code Scanning or the CodeQL CLI as documented in the section _Operating manual_.
31-
- `supported_rules_list_2.19.0-dev.csv`: A Comma Separated File (CSV) containing the supported rules per standard and the queries that implement the rule.
30+
- `code-scanning-cpp-query-pack-anon-2.21.0-dev.zip`: coding standard queries and scripts to be used with GitHub Code Scanning or the CodeQL CLI as documented in the section _Operating manual_.
31+
- `supported_rules_list_2.21.0-dev.csv`: A Comma Separated File (CSV) containing the supported rules per standard and the queries that implement the rule.
3232
- `upported_rules_list_2.18.0-dev.md`: A Markdown formatted file with a table containing the supported rules per standard and the queries that implement the rule.
33-
- `user_manual_2.19.0-dev.md`: This user manual.
33+
- `user_manual_2.21.0-dev.md`: This user manual.
3434
- `Source Code (zip)`: A zip archive containing the contents of https://github.com/github/codeql-coding-standards
3535
- `Source Code (tar.gz)`: A GZip compressed tar archive containing the contents of https://github.com/github/codeql-coding-standards
3636
- `checksums.txt`: A text file containing sha256 checksums for the aforementioned artifacts.
@@ -460,7 +460,7 @@ This section describes known failure modes for "CodeQL Coding Standards" and des
460460
| | Ouf 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). |
461461
| | 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). |
462462
| | 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). |
463-
| | 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.19.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. |
463+
| | 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.21.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. |
464464
| | 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. |
465465
| | 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. |
466466
| | 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. |

scripts/install-packs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
for pack in packs:
1919
pack_path = os.path.join(root, pack)
2020
# Run `codeql pack install` to install dependencies.
21-
command = [args.codeql, 'pack', 'install', '--mode', args.mode, pack_path]
21+
command = [args.codeql, 'pack', 'install', '--allow-prerelease', '--mode', args.mode, pack_path]
2222
print(f'Running `{" ".join(command)}`')
2323
subprocess.check_call(command)

scripts/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
beautifulsoup4==4.9.3
2-
certifi==2022.12.7
2+
certifi==2023.7.22
33
chardet==3.0.4
44
gitdb==4.0.5
55
GitPython==3.1.30
66
idna==2.10
77
Jinja2==2.11.3
88
MarkupSafe==1.1.1
9-
requests==2.25.0
9+
requests==2.31.0
1010
smmap==3.0.5
1111
soupsieve==2.0.1
1212
urllib3==1.26.5

supported_codeql_configs.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"codeql_standard_library": "codeql-cli/v2.11.6",
66
"codeql_cli_bundle": "codeql-bundle-20221211"
77
}
8-
],
9-
"supported_language" : [
8+
],
9+
"supported_language": [
1010
{
11-
"language" : "cpp"
11+
"language": "cpp"
1212
},
1313
{
14-
"language" : "c"
14+
"language": "c"
1515
}
1616
]
17-
}
17+
}

0 commit comments

Comments
 (0)