Michaelrfairhurst/package undefined behavior ptr to member#1086
Open
MichaelRFairhurst wants to merge 1 commit intomichaelrfairhurst/package-undefined-behaviorfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds MISRA C++:2023 RULE-4-1-3 coverage for undefined behavior involving pointer-to-member expressions by importing/shared-implementing the relevant analyses and wiring them into the Undefined package.
Changes:
- Added three new MISRA queries for pointer-to-member UB cases: null pointer-to-member, uninitialized static pointer-to-member, and non-existent member access via pointer-to-member.
- Updated the
Undefinedrule package definition and corresponding exclusions/metadata wiring to include the new queries. - Added MISRA test references pointing to existing shared common tests for each shared implementation.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| rule_packages/cpp/Undefined.json | Registers 3 new RULE-4-1-3 queries under the Undefined package. |
| cpp/misra/src/rules/RULE-4-1-3/NullPointerToMemberAccessUndefinedBehavior.ql | MISRA wrapper query for the shared null pointer-to-member UB implementation. |
| cpp/misra/src/rules/RULE-4-1-3/UninitializedStaticPointerToMemberUndefinedBehavior.ql | MISRA wrapper query for the shared uninitialized-static pointer-to-member UB implementation. |
| cpp/misra/src/rules/RULE-4-1-3/NonExistentMemberAccessUndefinedBehavior.ql | MISRA wrapper query for the shared “non-existing member via pointer-to-member” UB implementation. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Undefined.qll | Adds the new queries to the Undefined package query set and metadata mapping. |
| cpp/misra/test/rules/RULE-4-1-3/NullPointerToMemberAccessUndefinedBehavior.testref | Points MISRA tests at the shared common test for the null pointer-to-member implementation. |
| cpp/misra/test/rules/RULE-4-1-3/UninitializedStaticPointerToMemberUndefinedBehavior.testref | Points MISRA tests at the shared common test for the uninitialized-static pointer-to-member implementation. |
| cpp/misra/test/rules/RULE-4-1-3/NonExistentMemberAccessUndefinedBehavior.testref | Points MISRA tests at the shared common test for the non-existing member via pointer-to-member implementation. |
Comments suppressed due to low confidence (3)
cpp/misra/test/rules/RULE-4-1-3/NullPointerToMemberAccessUndefinedBehavior.testref:2
- These
.testreffiles are expected to contain a single path line (as generated byscripts/generate_rules/generate_package_files.py). The trailing blank line adds an extra, empty entry and may cause the test runner to mis-handle the reference; remove the blank line so the file contains exactly one line with the referenced.qlpath.
cpp/common/test/rules/accessofundefinedmemberthroughnullpointer/AccessOfUndefinedMemberThroughNullPointer.ql
cpp/misra/test/rules/RULE-4-1-3/UninitializedStaticPointerToMemberUndefinedBehavior.testref:2
- These
.testreffiles are expected to contain a single path line (as generated byscripts/generate_rules/generate_package_files.py). The trailing blank line adds an extra, empty entry and may cause the test runner to mis-handle the reference; remove the blank line so the file contains exactly one line with the referenced.qlpath.
cpp/common/test/rules/accessofundefinedmemberthroughuninitializedstaticpointer/AccessOfUndefinedMemberThroughUninitializedStaticPointer.ql
cpp/misra/test/rules/RULE-4-1-3/NonExistentMemberAccessUndefinedBehavior.testref:2
- These
.testreffiles are expected to contain a single path line (as generated byscripts/generate_rules/generate_package_files.py). The trailing blank line adds an extra, empty entry and may cause the test runner to mis-handle the reference; remove the blank line so the file contains exactly one line with the referenced.qlpath.
cpp/common/test/rules/accessofnonexistingmemberthroughpointertomember/AccessOfNonExistingMemberThroughPointerToMember.ql
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
Import OOP55-CPP which catch cases of UB related involving pointer-to-members
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
RULE-4-1-3Release 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.