Skip to content

Michaelrfairhurst/package undefined behavior ptr to member#1086

Open
MichaelRFairhurst wants to merge 1 commit intomichaelrfairhurst/package-undefined-behaviorfrom
michaelrfairhurst/package-undefined-behavior-ptr-to-member
Open

Michaelrfairhurst/package undefined behavior ptr to member#1086
MichaelRFairhurst wants to merge 1 commit intomichaelrfairhurst/package-undefined-behaviorfrom
michaelrfairhurst/package-undefined-behavior-ptr-to-member

Conversation

@MichaelRFairhurst
Copy link
Collaborator

Description

Import OOP55-CPP which catch cases of UB related involving pointer-to-members

Change request type

  • Release or process automation (GitHub workflows, internal scripts)
  • Internal documentation
  • External documentation
  • Query files (.ql, .qll, .qls or unit tests)
  • External scripts (analysis report or other code shipped as part of a release)

Rules with added or modified queries

  • No rules added
  • Queries have been added for the following rules:
    • RULE-4-1-3
  • Queries have been modified for the following rules:
    • rule number here

Release change checklist

A change note (development_handbook.md#change-notes) is required for any pull request which modifies:

  • The structure or layout of the release artifacts.
  • The evaluation performance (memory, execution time) of an existing query.
  • The results of an existing query in any circumstance.

If you are only adding new rule queries, a change note is not required.

Author: Is a change note required?

  • Yes
  • No

🚨🚨🚨
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.

  • Confirmed

Reviewer: Confirm that either a change note is not required or the change note is required and has been added.

  • Confirmed

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

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    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.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

Reviewer

  • Have all the relevant rule package description files been checked in?
  • Have you verified that the metadata properties of each new query is set appropriately?
  • Do all the unit tests contain both "COMPLIANT" and "NON_COMPLIANT" cases?
  • Are the alert messages properly formatted and consistent with the style guide?
  • Have you run the queries on OpenPilot and verified that the performance and results are acceptable?
    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.
  • Does the query have an appropriate level of in-query comments/documentation?
  • Have you considered/identified possible edge cases?
  • Does the query not reinvent features in the standard library?
  • Can the query be simplified further (not golfed!)

@MichaelRFairhurst MichaelRFairhurst changed the base branch from main to michaelrfairhurst/package-undefined-behavior March 16, 2026 18:27
@MichaelRFairhurst MichaelRFairhurst marked this pull request as ready for review March 17, 2026 04:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Undefined rule 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 .testref files are expected to contain a single path line (as generated by scripts/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 .ql path.
cpp/common/test/rules/accessofundefinedmemberthroughnullpointer/AccessOfUndefinedMemberThroughNullPointer.ql

cpp/misra/test/rules/RULE-4-1-3/UninitializedStaticPointerToMemberUndefinedBehavior.testref:2

  • These .testref files are expected to contain a single path line (as generated by scripts/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 .ql path.
cpp/common/test/rules/accessofundefinedmemberthroughuninitializedstaticpointer/AccessOfUndefinedMemberThroughUninitializedStaticPointer.ql

cpp/misra/test/rules/RULE-4-1-3/NonExistentMemberAccessUndefinedBehavior.testref:2

  • These .testref files are expected to contain a single path line (as generated by scripts/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 .ql path.
cpp/common/test/rules/accessofnonexistingmemberthroughpointertomember/AccessOfNonExistingMemberThroughPointerToMember.ql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants