Michaelrfairhurst/package undefined behavior mismatched list delete#1084
Open
MichaelRFairhurst wants to merge 7 commits intomainfrom
Open
Michaelrfairhurst/package undefined behavior mismatched list delete#1084MichaelRFairhurst wants to merge 7 commits intomainfrom
MichaelRFairhurst wants to merge 7 commits intomainfrom
Conversation
* Detect data races * Commit missing files * Regenenate metadata
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new MISRA C++:2023 RULE-4-1-3 “Undefined / critical unspecified behavior” package and wires in shared query implementations so existing logic can be reused across C, CERT C++, and MISRA C++ rule sets.
Changes:
- Introduces a new
rule_packages/cpp/Undefined.jsonpackage plus MISRA C++RULE-4-1-3query stubs and test scaffolding. - Refactors/centralizes two existing rule implementations into shared libraries (
PossibleDataRaceBetweenThreadsShared.qll,DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared.qll) and reuses them from C and C++ rule queries. - Updates CI workflows and adds change notes describing the refactors.
Reviewed changes
Copilot reviewed 42 out of 48 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| rule_packages/cpp/Undefined.json | New C++ rule package definition for MISRA C++:2023 RULE-4-1-3 (undefined / critical unspecified behavior). |
| rule_packages/cpp/Freed.json | Adds shared_implementation_short_name metadata for reuse of the array-delete mismatch query. |
| rule_packages/c/Concurrency9.json | Adds shared_implementation_short_name metadata for reuse of the data-race query. |
| cpp/misra/test/rules/RULE-4-1-3/UndefinedBehaviorAudit.qlref | Adds test reference for the MISRA C++ audit query wrapper. |
| cpp/misra/test/rules/RULE-4-1-3/UndefinedBehaviorAudit.expected | Adds expected output file (currently empty) for the audit wrapper query. |
| cpp/misra/test/rules/RULE-4-1-3/UndefinedBehavior.qlref | Adds test reference for the MISRA C++ query wrapper. |
| cpp/misra/test/rules/RULE-4-1-3/UndefinedBehavior.expected | Adds expected output file (currently empty) for the wrapper query. |
| cpp/misra/test/rules/RULE-4-1-3/PossibleDataRaceBetweenThreads.testref | Points MISRA C++ rule testing to the shared data-race implementation test. |
| cpp/misra/test/rules/RULE-4-1-3/CriticalUnspecifiedBehaviorAudit.qlref | Adds test reference for the MISRA C++ audit query wrapper. |
| cpp/misra/test/rules/RULE-4-1-3/CriticalUnspecifiedBehaviorAudit.expected | Adds expected output file (currently empty) for the audit wrapper query. |
| cpp/misra/test/rules/RULE-4-1-3/CriticalUnspecifiedBehavior.qlref | Adds test reference for the MISRA C++ query wrapper. |
| cpp/misra/test/rules/RULE-4-1-3/CriticalUnspecifiedBehavior.expected | Adds expected output file (currently empty) for the wrapper query. |
| cpp/misra/test/rules/RULE-4-1-3/ArrayDeletedThroughPointerOfIncorrectType.testref | Points MISRA C++ rule testing to the shared array-delete mismatch implementation test. |
| cpp/misra/src/rules/RULE-4-1-3/UndefinedBehaviorAudit.ql | Adds MISRA C++ audit wrapper query stub (no implementation). |
| cpp/misra/src/rules/RULE-4-1-3/UndefinedBehavior.ql | Adds MISRA C++ wrapper query stub (no implementation). |
| cpp/misra/src/rules/RULE-4-1-3/PossibleDataRaceBetweenThreads.ql | Adds MISRA C++ query that instantiates the shared data-race implementation. |
| cpp/misra/src/rules/RULE-4-1-3/CriticalUnspecifiedBehaviorAudit.ql | Adds MISRA C++ audit wrapper query stub (no implementation). |
| cpp/misra/src/rules/RULE-4-1-3/CriticalUnspecifiedBehavior.ql | Adds MISRA C++ wrapper query stub (no implementation). |
| cpp/misra/src/rules/RULE-4-1-3/ArrayDeletedThroughPointerOfIncorrectType.ql | Adds MISRA C++ query that instantiates the shared array-delete mismatch implementation. |
| cpp/common/test/rules/possibledataracebetweenthreadsshared/test.cpp | Adds a C++ shared-implementation test case for the data-race query. |
| cpp/common/test/rules/possibledataracebetweenthreadsshared/PossibleDataRaceBetweenThreadsShared.ql | Adds generated test driver query to instantiate the shared data-race implementation. |
| cpp/common/test/rules/possibledataracebetweenthreadsshared/PossibleDataRaceBetweenThreadsShared.expected | Adds expected results for the shared C++ data-race test. |
| cpp/common/test/rules/donotdeleteanarraythroughapointeroftheincorrecttypeshared/test.cpp | Minor formatting adjustment in the shared array-delete mismatch test source. |
| cpp/common/test/rules/donotdeleteanarraythroughapointeroftheincorrecttypeshared/DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared.ql | Adds generated test driver query to instantiate the shared array-delete mismatch implementation. |
| cpp/common/test/rules/donotdeleteanarraythroughapointeroftheincorrecttypeshared/DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared.expected | Adds expected results for the shared array-delete mismatch test. |
| cpp/common/src/codingstandards/cpp/rules/possibledataracebetweenthreadsshared/PossibleDataRaceBetweenThreadsShared.qll | New shared library implementing the possible data-race detection logic. |
| cpp/common/src/codingstandards/cpp/rules/donotdeleteanarraythroughapointeroftheincorrecttypeshared/DoNotDeleteAnArrayThroughAPointerOfTheIncorrectTypeShared.qll | New shared library implementing the array-delete type mismatch path-problem logic. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Undefined.qll | New autogenerated exclusions/metadata wiring for the new Undefined package. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll | Registers the new Undefined package in global metadata wiring. |
| cpp/cert/test/rules/EXP51-CPP/DoNotDeleteAnArrayThroughAPointerOfTheIncorrectType.testref | Redirects CERT EXP51-CPP testing to the shared implementation test. |
| cpp/cert/test/rules/EXP51-CPP/DoNotDeleteAnArrayThroughAPointerOfTheIncorrectType.qlref | Removes direct test reference to the production EXP51-CPP query. |
| cpp/cert/test/rules/EXP51-CPP/DoNotDeleteAnArrayThroughAPointerOfTheIncorrectType.expected | Removes the old expected output (now covered by shared implementation tests). |
| cpp/cert/src/rules/EXP51-CPP/DoNotDeleteAnArrayThroughAPointerOfTheIncorrectType.ql | Refactors the CERT query to instantiate the shared array-delete mismatch implementation. |
| change_notes/2026-03-13-share-array-delete-type-mismatch-query.md | Change note for the shared refactor of EXP51-CPP array-delete mismatch logic. |
| change_notes/2026-03-09-possible-data-race-between-threads-shared.md | Change note for the shared refactor of DIR-5-1 possible data-race logic. |
| c/misra/test/rules/DIR-5-1/PossibleDataRaceBetweenThreads.testref | Redirects MISRA C DIR-5-1 testing to the shared implementation test. |
| c/misra/test/rules/DIR-5-1/PossibleDataRaceBetweenThreads.qlref | Removes direct test reference to the production DIR-5-1 query. |
| c/misra/src/rules/DIR-5-1/PossibleDataRaceBetweenThreads.ql | Refactors the MISRA C query to instantiate the shared data-race implementation. |
| c/common/test/rules/possibledataracebetweenthreadsshared/test.c | Adds a C shared-implementation test case for the data-race query. |
| c/common/test/rules/possibledataracebetweenthreadsshared/PossibleDataRaceBetweenThreadsShared.ql | Adds generated test driver query to instantiate the shared data-race implementation (C config). |
| c/common/test/rules/possibledataracebetweenthreadsshared/PossibleDataRaceBetweenThreadsShared.expected | Adds expected results for the shared C data-race test. |
| .github/workflows/validate-query-test-case-formatting.yml | Adds an explicit branch name to the workflow trigger list. |
| .github/workflows/validate-query-help.yml | Adds an explicit branch name to the workflow trigger list. |
| .github/workflows/validate-query-formatting.yml | Adds an explicit branch name to the workflow trigger list. |
| .github/workflows/validate-package-files.yml | Adds an explicit branch name to the workflow trigger list. |
| .github/workflows/tooling-unit-tests.yml | Adds an explicit branch name to the workflow trigger list. |
| .github/workflows/extra-rule-validation.yml | Adds an explicit branch name to the workflow trigger list. |
| .github/workflows/codeql_unit_tests.yml | Adds an explicit branch name to the workflow trigger list. |
| TStdFunctionCall(FunctionCall call) { | ||
| call.getTarget() | ||
| .hasName([ | ||
| "setlocale", "tmpnam", "rand", "srand", "getenv", "getenv_s", "strok", "strerror", |
| srand(0); // NON-COMPLIANT | ||
| getenv("PATH"); // NON-COMPLIANT | ||
| getenv_s(NULL, NULL, 0, NULL); // NON-COMPLIANT | ||
| strtok("a", "b"); // NON-COMPLIANT |
| // Not all are defined in std:: in our stubs. | ||
| std::setlocale(LC_ALL, "C"); // NON-COMPLIANT | ||
| setlocale(LC_ALL, "C"); // NON-COMPLIANT | ||
| std::tmpnam(""); // NON-COMPLIANT |
Comment on lines
+12
to
13
| - michaelrfairhurst/package-undefined-behavior | ||
|
|
Comment on lines
+12
to
13
| - michaelrfairhurst/package-undefined-behavior | ||
|
|
| - main | ||
| - next | ||
| - "rc/**" | ||
| - michaelrfairhurst/package-undefined-behavior |
Comment on lines
+12
to
13
| - michaelrfairhurst/package-undefined-behavior | ||
|
|
| - main | ||
| - "rc/**" | ||
| - next | ||
| - michaelrfairhurst/package-undefined-behavior |
Comment on lines
+18
to
20
| - michaelrfairhurst/package-undefined-behavior | ||
|
|
||
|
|
| - main | ||
| - next | ||
| - "rc/**" | ||
| - michaelrfairhurst/package-undefined-behavior |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
please enter the description of your change here
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
RULE-4-1-3EXP51-CPPRelease change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.