Skip to content

Fix telemetry PII concerns: sanitize exceptions, project paths, and custom names#13344

Merged
YuliiaKovalova merged 1 commit into
mainfrom
fix/telemetry-pii-concerns
Mar 9, 2026
Merged

Fix telemetry PII concerns: sanitize exceptions, project paths, and custom names#13344
YuliiaKovalova merged 1 commit into
mainfrom
fix/telemetry-pii-concerns

Conversation

@YuliiaKovalova

@YuliiaKovalova YuliiaKovalova commented Mar 9, 2026

Copy link
Copy Markdown
Member

Summary

This PR addresses several PII concerns in MSBuild telemetry, identified through a comprehensive audit of the telemetry codebase.

Copilot AI review requested due to automatic review settings March 9, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses PII (Personally Identifiable Information) concerns in MSBuild telemetry by sanitizing exceptions, file paths, and custom target names before they are emitted.

Changes:

  • Introduces SanitizedException wrapper to sanitize exception messages and stack traces before passing to VS Telemetry's FaultEvent, 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 full ProjectPath in telemetry, and hashes custom build target names against a KnownTargetNames allowlist using SHA-256.
  • Applies CrashTelemetry.TruncateMessage() to sanitize exception messages in BuildCheckTelemetry before 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

Comment thread src/Framework/Telemetry/BuildTelemetry.cs
Comment thread src/Framework/Telemetry/CrashTelemetry.cs Outdated
Comment thread src/Build.UnitTests/BackEnd/KnownTelemetry_Tests.cs Outdated
Comment thread src/Framework/Telemetry/CrashTelemetryRecorder.cs
…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
@YuliiaKovalova YuliiaKovalova force-pushed the fix/telemetry-pii-concerns branch from fd4f1ef to 3b4488f Compare March 9, 2026 13:41
@YuliiaKovalova YuliiaKovalova enabled auto-merge (squash) March 9, 2026 15:33
@YuliiaKovalova YuliiaKovalova merged commit fd46d4a into main Mar 9, 2026
10 checks passed
@YuliiaKovalova YuliiaKovalova deleted the fix/telemetry-pii-concerns branch March 9, 2026 15:41
This was referenced May 13, 2026
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.

3 participants