Reuse A2-13-4 as an audit query for undefined behavior.#1081
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 refactors the AUTOSAR A2-13-4 query for “string literals assigned to non-const pointers” into a shared implementation, and reuses that shared logic to add a MISRA C++ RULE-4-1-3 audit query under the “Undefined behavior” rule package.
Changes:
- Extracted the A2-13-4 query logic into a new shared module (
StringLiteralsAssignedToNonConstantPointersShared) and updated the AUTOSAR query to import it. - Added a new MISRA RULE-4-1-3 audit query that reuses the shared implementation, plus corresponding rule-package and exclusions metadata wiring.
- Added shared tests for the new shared module and referenced them from both AUTOSAR and MISRA test trees; added a change note.
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| rule_packages/cpp/Undefined.json | Adds a new audit query entry (RULE-4-1-3) reusing the shared implementation. |
| rule_packages/cpp/Strings.json | Links A2-13-4 to the shared implementation via shared_implementation_short_name. |
| cpp/misra/test/rules/RULE-4-1-3/StringLiteralPossiblyModifiedAudit.testref | Points MISRA test coverage to the shared-module test query. |
| cpp/misra/src/rules/RULE-4-1-3/StringLiteralPossiblyModifiedAudit.ql | New MISRA audit query that instantiates the shared module with UndefinedPackage exclusions. |
| cpp/common/test/rules/stringliteralsassignedtononconstantpointersshared/test.cpp | Adds the shared-module C++ test cases for string-literal-to-non-const-pointer conversions. |
| cpp/common/test/rules/stringliteralsassignedtononconstantpointersshared/StringLiteralsAssignedToNonConstantPointersShared.ql | Adds the shared-module test query driver (generated) for the shared tests. |
| cpp/common/test/rules/stringliteralsassignedtononconstantpointersshared/StringLiteralsAssignedToNonConstantPointersShared.expected | Expected results for the shared-module tests. |
| cpp/common/src/codingstandards/cpp/rules/stringliteralsassignedtononconstantpointersshared/StringLiteralsAssignedToNonConstantPointersShared.qll | New shared implementation of the query logic. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Undefined.qll | Wires the new MISRA audit query into Undefined package query metadata/exclusions. |
| cpp/autosar/test/rules/A2-13-4/StringLiteralsAssignedToNonConstantPointers.testref | Points AUTOSAR test coverage to the shared-module test query. |
| cpp/autosar/test/rules/A2-13-4/StringLiteralsAssignedToNonConstantPointers.qlref | Removes the old direct production-query reference in favor of .testref. |
| cpp/autosar/src/rules/A2-13-4/StringLiteralsAssignedToNonConstantPointers.ql | Refactors AUTOSAR query to instantiate the shared module. |
| change_notes/2026-03-13-make-string-literal-query-shared.md | Change note documenting the refactor and intended no-behavior-change. |
| * for the following issue: | ||
| * The type of string literal as of C++0x was changed from 'array of char' to array of | ||
| * const char and therefore assignment to a non-const pointer is considered an error, | ||
| * which is reported as a warning by some compliers. |
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-3A2-13-4Release 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.