Adding support for putting the warning string at index of problem #1406
Merged
ThomsonTan merged 2 commits intomainfrom Jan 28, 2026
Merged
Adding support for putting the warning string at index of problem #1406ThomsonTan merged 2 commits intomainfrom
ThomsonTan merged 2 commits intomainfrom
Conversation
…tead of at the beginning
frank-msodsp
approved these changes
Jan 27, 2026
Contributor
|
Is modules set the the latest commit in submodule? The new commit hash b48f76d8284b5785572569134db181bccf856d75 seems not correct. |
eafbb90 to
5f75378
Compare
Updates lib/modules submodule pointer to reference the merged commit b34f1c412 from PR #317 on master branch. The core C++ changes have been reviewed and merged into the submodule. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
5f75378 to
ef9550f
Compare
ThomsonTan
approved these changes
Jan 28, 2026
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.
Add Configurable Warning Message Placement
Summary
This change adds a new configuration option
InsertWarningAtProblemLocationthat controls where warning messages are placed in sanitized strings. When enabled, warnings are inserted at the problem location (right before the detected pattern) instead of being prepended to the beginning of the string.Motivation
Previously, all warning messages were prepended to the beginning of strings, which could make it difficult to understand the context of the detected issue. By inserting warnings at the exact location where the problem was detected, users get better context about what triggered the sanitizer.
Example Behavior
Input:
"User accessed https://evil.com/secret"Pattern detected:
https://evil.comat index 14Before (default behavior -
InsertWarningAtProblemLocation = false):"WARNING: aka.ms/ODSPSanitizerURL User accessed https://evil.com/secret"
After (when enabled -
InsertWarningAtProblemLocation = true):"User accessed WARNING: aka.ms/ODSPSanitizerURL https://evil.com/secret"
Implementation Details
Core C++ Changes
InsertWarningAtProblemLocationboolean field toSanitizerConfiguration(default:false)HandleWarningMessageto accept amatchIndexparameter indicating where the pattern was foundCreateWarningMessage(prefix, str, offset)alongside existingCreateWarningMessage(prefix, str)InsertWarningAtProblemLocation == trueandmatchIndex > 0, the new 3-parameter overload is calledCross-Platform Support
Configuration propagates through all platform layers:
SanitizerConfiguration.java,Sanitizer.java, andSanitizer_jni.cppODWSanitizerInitConfig.hand.mmSanitizerInitConfig.swiftwrapperEdge Case Handling
offset == 0: Falls back to prepend behavioroffset >= string.length(): Falls back to prepend behaviorTesting
Added comprehensive unit tests:
Backwards Compatibility
✅ Fully backwards compatible - default value is
false, maintaining existing prepend behavior✅ Existing code that doesn't set this configuration field continues to work unchanged
✅ No breaking changes to any public APIs
Technical Notes
std::memcpy,resize(), pointer arithmetic)Files Modified
Core C++ (5 files)
lib/modules/sanitizer/SanitizerConfiguration.hpplib/modules/sanitizer/SanitizerProvider.hpplib/modules/sanitizer/SanitizerProvider.cpplib/modules/sanitizer/SanitizerStringUtils.hpplib/modules/sanitizer/SanitizerStringUtils.cppPlatform Wrappers (6 files)
lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/SanitizerConfiguration.javalib/android_build/maesdk/src/main/java/com/microsoft/applications/events/Sanitizer.javalib/jni/Sanitizer_jni.cppwrappers/obj-c/ODWSanitizerInitConfig.hwrappers/obj-c/ODWSanitizerInitConfig.mmwrappers/swift/Sources/OneDSSwift/SanitizerInitConfig.swiftTests (2 files)
lib/modules/sanitizer/tests/unittests/SanitizerStringUtilsTests.cpplib/modules/sanitizer/tests/unittests/SanitizerProviderTests.cpp