Fix telemetry PII concerns: sanitize exceptions, project paths, and custom names#13344
Merged
Conversation
MichalPavlik
approved these changes
Mar 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses PII (Personally Identifiable Information) concerns in MSBuild telemetry by sanitizing exceptions, file paths, and custom target names before they are emitted.
Changes:
- Introduces
SanitizedExceptionwrapper to sanitize exception messages and stack traces before passing to VS Telemetry'sFaultEvent, and extends path-redaction regex to handle UNC paths and non-stack-frame lines. - Emits only the file name (via
Path.GetFileName) instead of the fullProjectPathin telemetry, and hashes custom build target names against aKnownTargetNamesallowlist using SHA-256. - Applies
CrashTelemetry.TruncateMessage()to sanitize exception messages inBuildCheckTelemetrybefore emitting.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/Framework/Telemetry/CrashTelemetryRecorder.cs |
Adds SanitizedException wrapper class to sanitize exception message/stack before FaultEvent |
src/Framework/Telemetry/CrashTelemetry.cs |
Extends path-redaction regex for UNC paths; adds path redaction for non-stack-frame lines in SanitizeFilePathsInText |
src/Framework/Telemetry/BuildTelemetry.cs |
Emits only filename for ProjectPath; adds KnownTargetNames allowlist and SanitizeBuildTarget method to hash custom targets |
src/Framework/Telemetry/BuildCheckTelemetry.cs |
Sanitizes exception.Message via TruncateMessage() before emitting in telemetry |
src/Framework.UnitTests/CrashTelemetry_Tests.cs |
Adds tests for UNC path redaction, paths with spaces, and non-stack-frame line redaction |
src/Build.UnitTests/BackEnd/KnownTelemetry_Tests.cs |
Adds tests for filename-only ProjectPath emission and custom target hashing |
…ustom names - Wrap raw Exception in SanitizedException before passing to VS FaultEvent to strip file paths and usernames from messages and stack traces - Emit only the file name (not full directory path) for BuildTelemetry.ProjectPath - Hash custom build target names using SHA-256; preserve well-known targets - Sanitize BuildCheckTelemetry.ExceptionMessage using CrashTelemetry.TruncateMessage - Extend path-redaction regex to match UNC paths (\\\\server\\share\\...) - Apply general path redaction in SanitizeFilePathsInText for non-stack-frame lines - Add tests for UNC path redaction, non-stack-frame path sanitization, ProjectPath file-name-only emission, and custom target hashing
fd4f1ef to
3b4488f
Compare
This was referenced Mar 9, 2026
This was referenced May 13, 2026
Closed
Closed
Closed
This was referenced May 26, 2026
This was referenced Jun 2, 2026
Closed
Bump Microsoft.Build from 18.4.0 to 18.6.3
SkylineCommunications/Skyline.DataMiner.CICD.Packages#159
Open
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.
Summary
This PR addresses several PII concerns in MSBuild telemetry, identified through a comprehensive audit of the telemetry codebase.