Skip to content

Commit 9323313

Browse files
authored
For MRT Core, exclude file names and file paths from logging as they contain PII. (#1462)
* Do not log file names and file paths as it contains PII. We will add this back once a centralized PII scrubber is available. * Fixed a mistake. Verified that the change builds fine. * Addressed feedback.
1 parent fa85391 commit 9323313

2 files changed

Lines changed: 10 additions & 22 deletions

File tree

dev/MRTCore/mrt/mrm/include/mrm/common/MrmTraceLogging.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,10 @@ class MrtRuntimeTraceLoggingProvider : public wil::TraceLoggingProvider
3131
DEFINE_COMPLIANT_MEASURES_EVENT_PARAM4(MeasureGenericEvent, PDT_ProductAndServicePerformance, PCWSTR, functionName, PCWSTR, message1, PCWSTR, message2, int, hresult);
3232
};
3333

34-
// case insensitive prefix match of "*:\users"
35-
__inline PCWSTR RemoveUsernameFromPath(_In_ PCWSTR filePath)
34+
// Remove PII from string
35+
inline PCWSTR RemovePiiUserProfileFilename(PCWSTR)
3636
{
37-
if ((filePath != NULL) &&
38-
(filePath[0] != 0) &&
39-
(filePath[1] == L':') &&
40-
(filePath[2] == L'\\') &&
41-
((filePath[3] == L'u') || (filePath[3] == L'U')) &&
42-
((filePath[4] == L's') || (filePath[4] == L'S')) &&
43-
((filePath[5] == L'e') || (filePath[5] == L'E')) &&
44-
((filePath[6] == L'r') || (filePath[6] == L'R')) &&
45-
((filePath[7] == L's') || (filePath[7] == L'S')) &&
46-
(filePath[8] == L'\\'))
47-
{
48-
PCWSTR logPath = wcsstr(&filePath[9], L"\\");
49-
return (logPath != NULL) ? logPath : L"";
50-
}
51-
return filePath;
37+
// TODO: Once the feature below is available, this function can be removed.
38+
// Create a centralized PII scrubber · Issue #1461 (https://github.com/microsoft/WindowsAppSDK/issues/1461)
39+
return L"";
5240
}

dev/MRTCore/mrt/mrm/include/mrm/common/PlatformWin32.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ extern "C"
9595
#define WRITE_MRMMIN_INIT_TRACE_INFO(msg, hr) MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, hr)
9696
#define WRITE_MRMMIN_INIT_TRACE_INFO_CHECK(msg, hr) \
9797
{ \
98-
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), RemoveUsernameFromPath(msg), hr); \
98+
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), RemovePiiUserProfileFilename(msg), hr); \
9999
}
100100
#define WRITE_MRMMIN_INIT_TRACE_ERROR(msg, hr) MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, hr)
101101
#define WRITE_MRMMIN_INIT_TRACE_ERROR_CHECK(msg, hr) \
102102
{ \
103-
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), RemoveUsernameFromPath(msg), hr); \
103+
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), RemovePiiUserProfileFilename(msg), hr); \
104104
}
105105
#define WRITE_MRMMIN_INIT_TRACE_ERROR_MEASURE(msg, hr) \
106106
{ \
@@ -110,14 +110,14 @@ extern "C"
110110
#define WRITE_MRMMIN_INIT_TRACE_ERROR_MEASURE_CHECK(msg, hr) \
111111
{ \
112112
LOG_ERROR_IN_MEMORY(hr, __LINE__, __FILE__, msg); \
113-
MrtRuntimeTraceLoggingProvider::MeasureGenericEvent(TOWIDE(__FUNCTION__), RemoveUsernameFromPath(msg), hr); \
113+
MrtRuntimeTraceLoggingProvider::MeasureGenericEvent(TOWIDE(__FUNCTION__), RemovePiiUserProfileFilename(msg), hr); \
114114
}
115115

116116
#define WRITE_MRMMIN_TRACE_INFO(msg, msg2, hr) MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, msg2, hr)
117117
#define WRITE_MRMMIN_TRACE_WARNING(msg, msg2, hr) MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, msg2, hr)
118118
#define WRITE_MRMMIN_TRACE_WARNING_CHECK(msg, msg2, hr) \
119119
{ \
120-
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, RemoveUsernameFromPath(msg2), hr); \
120+
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, RemovePiiUserProfileFilename(msg2), hr); \
121121
}
122122
#define WRITE_MRMMIN_TRACE_ERROR(msg, msg2, hr) MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, msg2, hr)
123123
#define WRITE_MRMMIN_TRACE_ERROR_MEASURE(msg, msg2, hr) \
@@ -128,7 +128,7 @@ extern "C"
128128
#define WRITE_MRMMIN_TRACE_ERROR_MEASURE_CHECK(msg, msg2, hr) \
129129
{ \
130130
LOG_ERROR_IN_MEMORY(hr, __LINE__, __FILE__, msg2); \
131-
MrtRuntimeTraceLoggingProvider::MeasureGenericEvent(TOWIDE(__FUNCTION__), msg, RemoveUsernameFromPath(msg2), hr); \
131+
MrtRuntimeTraceLoggingProvider::MeasureGenericEvent(TOWIDE(__FUNCTION__), msg, RemovePiiUserProfileFilename(msg2), hr); \
132132
}
133133

134134
#define WRITE_ETW(etw) __noop

0 commit comments

Comments
 (0)