Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
32f3d54
First implementation of Rule 22-3-1
MichaelRFairhurst Nov 25, 2025
117afb6
update pack locks
MichaelRFairhurst Nov 25, 2025
4c3f971
Bump actions/checkout from 5 to 6
dependabot[bot] Dec 24, 2025
c29ca80
Add lifetime rule RULE-11-6-2
knewbury01 Feb 3, 2026
5830686
Merge branch 'main' into dependabot/github_actions/actions/checkout-6
MichaelRFairhurst Feb 7, 2026
0d02cef
Merge remote-tracking branch 'origin/main' into michaelrfairhurst/pre…
MichaelRFairhurst Feb 25, 2026
b72d975
Merge remote-tracking branch 'origin/main' into michaelrfairhurst/pre…
MichaelRFairhurst Feb 26, 2026
4eeadb0
Merge branch 'main' into michaelrfairhurst/preconditions-rule-22-3-1-…
MichaelRFairhurst Feb 28, 2026
3d71876
Merge branch 'main' into michaelrfairhurst/preconditions-rule-22-3-1-…
MichaelRFairhurst Mar 4, 2026
cbec99e
Merge branch 'main' into michaelrfairhurst/preconditions-rule-22-3-1-…
MichaelRFairhurst Mar 5, 2026
6fb7d61
Bump version to 2.56.0-dev
knewbury01 Mar 6, 2026
6956667
Merge branch 'main' into knewbury01/Lifetime
knewbury01 Mar 6, 2026
c38d0ee
Merge pull request #1073 from github/release-automation/bump-version-…
knewbury01 Mar 9, 2026
86123fe
Update cpp/common/src/codingstandards/cpp/standardlibrary/Assert.qll
mbaluda Mar 10, 2026
9651122
Add improvements to readofuninitializedmemory and testcase
knewbury01 Mar 10, 2026
d0f2ede
Remove unnecessary import in readofuninitializedmemory
knewbury01 Mar 10, 2026
1c610ee
Add shared query for RULE-6-8-3
knewbury01 Mar 10, 2026
a903b40
Merge branch 'main' into knewbury01/Lifetime
knewbury01 Mar 10, 2026
1704bb8
Format query
knewbury01 Mar 10, 2026
dd5ebd3
Merge branch 'knewbury01/Lifetime' of https://github.com/knewbury01/c…
knewbury01 Mar 10, 2026
ac21481
Add another missing query format
knewbury01 Mar 10, 2026
b2e8f3a
Revert shared rule to class not module since it shares with old style
knewbury01 Mar 10, 2026
1649c21
Improve tests to be more clear on whether certain cases are supported…
knewbury01 Mar 11, 2026
9e62570
Import EXP51-CPP into rule 4-1-3 as it is UB
MichaelRFairhurst Mar 14, 2026
5680bbd
Bump actions/create-github-app-token from 2 to 3
dependabot[bot] Mar 16, 2026
f5501da
Comment fix on aborts+asserts
MichaelRFairhurst Mar 17, 2026
8071ddb
Merge pull request #986 from github/michaelrfairhurst/preconditions-r…
MichaelRFairhurst Mar 17, 2026
af8a42b
Merge pull request #985 from github/dependabot/github_actions/actions…
MichaelRFairhurst Mar 17, 2026
25403fc
Merge pull request #1085 from github/dependabot/github_actions/action…
MichaelRFairhurst Mar 17, 2026
db1a631
Address review comments
knewbury01 Mar 17, 2026
3baadfb
Fix testcase formatting
knewbury01 Mar 17, 2026
242422b
Address review comments
knewbury01 Mar 18, 2026
10f562a
Merge branch 'main' into knewbury01/Lifetime
knewbury01 Mar 18, 2026
1487ba0
Merge pull request #1024 from knewbury01/knewbury01/Lifetime
MichaelRFairhurst Mar 19, 2026
f739b65
Add RULE-13-3-3
knewbury01 Mar 19, 2026
f999e10
Fix testcase labelling RULE-13-3-3
knewbury01 Mar 19, 2026
c6997fd
Address review comment
knewbury01 Mar 19, 2026
a4ca148
Apply a few other review comments
knewbury01 Mar 19, 2026
1371769
Merge branch 'main' into knewbury01/misracpp2023-declarations1
knewbury01 Mar 19, 2026
ad580d3
Merge pull request #1089 from knewbury01/knewbury01/misracpp2023-decl…
MichaelRFairhurst Mar 23, 2026
664a54a
Add query validation guidelines to copilot review instructions
mbaluda Mar 24, 2026
83cf49c
Revise QLDoc style guide and add examples
mbaluda Mar 24, 2026
26402a3
Update .github/copilot-instructions.md
mbaluda Mar 24, 2026
b65b58f
Update .github/copilot-instructions.md
mbaluda Mar 24, 2026
5364072
Update .github/copilot-instructions.md
mbaluda Mar 24, 2026
0c29859
Update .github/copilot-instructions.md
mbaluda Mar 24, 2026
fb0af07
Update CodeQL guidelines and QLDoc requirements
mbaluda Mar 25, 2026
df3074e
Merge pull request #1092 from github/mbaluda-patch-1
mbaluda Mar 25, 2026
c148d75
Merge branch 'main' into michaelrfairhurst/package-undefined-behavior…
mbaluda Mar 25, 2026
8e8feef
Update .github/workflows/validate-query-formatting.yml
mbaluda Mar 25, 2026
9d539a3
Address copilot review
mbaluda Mar 25, 2026
8ba9aff
Fix expected file
mbaluda Mar 25, 2026
e57263b
Merge branch 'michaelrfairhurst/package-undefined-behavior' into mich…
MichaelRFairhurst Mar 27, 2026
614a802
Merge remote-tracking branch 'origin/michaelrfairhurst/package-undefi…
MichaelRFairhurst Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `EXP51-CPP` - `DoNotDeleteAnArrayThroughAPointerOfTheIncorrectType.ql`:
- Refactored query logic into a shared library (`DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared.qll`) to enable reuse by MISRA C++ `RULE-4-1-3`. The query logic is unchanged and no visible changes to results or performance are expected.
- The query now uses a `query predicate problems` instead of a `from/where/select`. In path-problem BQRS output, the results section header changes from `#select` to `problems`. Alert results and their content are otherwise identical.
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,18 @@

import cpp
import codingstandards.cpp.cert
import semmle.code.cpp.dataflow.DataFlow
import AllocationToDeleteFlow::PathGraph
import codingstandards.cpp.rules.donotdeleteanarraythroughapointeroftheincorrecttypeshared.DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared

module AllocationToDeleteConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof NewArrayExpr }

predicate isSink(DataFlow::Node sink) {
exists(DeleteArrayExpr dae | dae.getExpr() = sink.asExpr())
module DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeConfig implements
DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeSharedConfigSig
{
Query getQuery() {
result = FreedPackage::doNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeQuery()
}
}

module AllocationToDeleteFlow = DataFlow::Global<AllocationToDeleteConfig>;
module Shared =
DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared<DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeConfig>;

from
AllocationToDeleteFlow::PathNode source, AllocationToDeleteFlow::PathNode sink,
NewArrayExpr newArray, DeleteArrayExpr deleteArray
where
not isExcluded(deleteArray.getExpr(),
FreedPackage::doNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeQuery()) and
AllocationToDeleteFlow::flowPath(source, sink) and
newArray = source.getNode().asExpr() and
deleteArray.getExpr() = sink.getNode().asExpr() and
not newArray.getType().getUnspecifiedType() = deleteArray.getExpr().getType().getUnspecifiedType()
select sink, source, sink,
"Array of type " + newArray.getType() + " is deleted through a pointer of type " +
deleteArray.getExpr().getType() + "."
import Shared::PathGraph
import Shared

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpp/common/test/rules/donotdeleteanarraythroughapointeroftheincorrecttypeshared/DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared.ql
19 changes: 18 additions & 1 deletion cpp/common/src/codingstandards/cpp/exclusions/cpp/Undefined.qll
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ newtype UndefinedQuery =
TCriticalUnspecifiedBehaviorQuery() or
TUndefinedBehaviorAuditQuery() or
TCriticalUnspecifiedBehaviorAuditQuery() or
TPossibleDataRaceBetweenThreadsQuery()
TPossibleDataRaceBetweenThreadsQuery() or
TArrayDeletedThroughPointerOfIncorrectTypeQuery()

predicate isUndefinedQueryMetadata(Query query, string queryId, string ruleId, string category) {
query =
Expand Down Expand Up @@ -55,6 +56,15 @@ predicate isUndefinedQueryMetadata(Query query, string queryId, string ruleId, s
"cpp/misra/possible-data-race-between-threads" and
ruleId = "RULE-4-1-3" and
category = "required"
or
query =
// `Query` instance for the `arrayDeletedThroughPointerOfIncorrectType` query
UndefinedPackage::arrayDeletedThroughPointerOfIncorrectTypeQuery() and
queryId =
// `@id` for the `arrayDeletedThroughPointerOfIncorrectType` query
"cpp/misra/array-deleted-through-pointer-of-incorrect-type" and
ruleId = "RULE-4-1-3" and
category = "required"
}

module UndefinedPackage {
Expand Down Expand Up @@ -92,4 +102,11 @@ module UndefinedPackage {
// `Query` type for `possibleDataRaceBetweenThreads` query
TQueryCPP(TUndefinedPackageQuery(TPossibleDataRaceBetweenThreadsQuery()))
}

Query arrayDeletedThroughPointerOfIncorrectTypeQuery() {
//autogenerate `Query` type
result =
// `Query` type for `arrayDeletedThroughPointerOfIncorrectType` query
TQueryCPP(TUndefinedPackageQuery(TArrayDeletedThroughPointerOfIncorrectTypeQuery()))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Provides a configurable module DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared
* with a `problems` predicate for the following issue:
* Deleting an array through a pointer of an incorrect type leads to undefined behavior.
*/

import cpp
import codingstandards.cpp.Customizations
import codingstandards.cpp.Exclusions
import semmle.code.cpp.dataflow.DataFlow

signature module DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeSharedConfigSig {
Query getQuery();
}

module DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared<
DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeSharedConfigSig Config>
{
private module AllocationToDeleteConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof NewArrayExpr }

predicate isSink(DataFlow::Node sink) {
exists(DeleteArrayExpr dae | dae.getExpr() = sink.asExpr())
}
}

module AllocationToDeleteFlow = DataFlow::Global<AllocationToDeleteConfig>;

module PathGraph = AllocationToDeleteFlow::PathGraph;

query predicate problems(
Expr deleteExpr, AllocationToDeleteFlow::PathNode source, AllocationToDeleteFlow::PathNode sink,
string message
) {
exists(NewArrayExpr newArray, DeleteArrayExpr deleteArray |
not isExcluded(deleteArray.getExpr(), Config::getQuery()) and
AllocationToDeleteFlow::flowPath(source, sink) and
newArray = source.getNode().asExpr() and
deleteArray.getExpr() = sink.getNode().asExpr() and
not newArray.getType().getUnspecifiedType() =
deleteArray.getExpr().getType().getUnspecifiedType() and
deleteExpr = sink.getNode().asExpr() and
message =
"Array of type " + newArray.getType() + " is deleted through a pointer of type " +
deleteArray.getExpr().getType() + "."
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
problems
| test.cpp:9:12:9:13 | l1 | test.cpp:6:19:6:37 | new[] | test.cpp:9:12:9:13 | l1 | Array of type DerivedClass * is deleted through a pointer of type BaseClass *. |
edges
| test.cpp:6:19:6:37 | new[] | test.cpp:9:12:9:13 | l1 | provenance | |
| test.cpp:7:22:7:40 | new[] | test.cpp:10:12:10:13 | l2 | provenance | |
nodes
| test.cpp:6:19:6:37 | new[] | semmle.label | new[] |
| test.cpp:7:22:7:40 | new[] | semmle.label | new[] |
| test.cpp:9:12:9:13 | l1 | semmle.label | l1 |
| test.cpp:10:12:10:13 | l2 | semmle.label | l2 |
subpaths
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// GENERATED FILE - DO NOT MODIFY
import codingstandards.cpp.rules.donotdeleteanarraythroughapointeroftheincorrecttypeshared.DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared

module TestFileConfig implements DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeSharedConfigSig {
Query getQuery() { result instanceof TestQuery }
}

module Shared = DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared<TestFileConfig>;

import Shared::PathGraph
import Shared
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ void test() {

delete[] l1; // NON_COMPLIANT - pointer to base class
delete[] l2; // COMPLIANT - pointer to derived class
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @id cpp/misra/array-deleted-through-pointer-of-incorrect-type
* @name RULE-4-1-3: Array deleted through pointer of incorrect type leads to undefined behavior
* @description Deleting an array through a pointer of an incorrect type leads to undefined
* behavior.
* @kind path-problem
* @precision high
* @problem.severity error
* @tags external/misra/id/rule-4-1-3
* correctness
* scope/system
* external/misra/enforcement/undecidable
* external/misra/obligation/required
*/

import cpp
import codingstandards.cpp.misra
import codingstandards.cpp.rules.donotdeleteanarraythroughapointeroftheincorrecttypeshared.DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared

module ArrayDeletedThroughPointerOfIncorrectTypeConfig implements
DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeSharedConfigSig
{
Query getQuery() { result = UndefinedPackage::arrayDeletedThroughPointerOfIncorrectTypeQuery() }
}

module Shared =
DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared<ArrayDeletedThroughPointerOfIncorrectTypeConfig>;

import Shared::PathGraph
import Shared
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpp/common/test/rules/donotdeleteanarraythroughapointeroftheincorrecttypeshared/DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared.ql
1 change: 1 addition & 0 deletions rule_packages/cpp/Freed.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"name": "Do not delete an array through a pointer of the incorrect type",
"precision": "high",
"severity": "error",
"shared_implementation_short_name": "DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared",
"short_name": "DoNotDeleteAnArrayThroughAPointerOfTheIncorrectType",
"tags": [
"correctness",
Expand Down
13 changes: 13 additions & 0 deletions rule_packages/cpp/Undefined.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@
"concurrency",
"scope/system"
]
},
{
"description": "Deleting an array through a pointer of an incorrect type leads to undefined behavior.",
"kind": "path-problem",
"name": "Array deleted through pointer of incorrect type leads to undefined behavior",
"precision": "high",
"severity": "error",
"shared_implementation_short_name": "DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared",
"short_name": "ArrayDeletedThroughPointerOfIncorrectType",
"tags": [
"correctness",
"scope/system"
]
}
],
"title": "There shall be no occurrence of undefined or critical unspecified behaviour"
Expand Down
Loading