Skip to content

Commit

Permalink
For MRT Core, exclude file names and file paths from logging as they …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
rohanp-msft authored Sep 21, 2021
1 parent fa85391 commit 9323313
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
22 changes: 5 additions & 17 deletions dev/MRTCore/mrt/mrm/include/mrm/common/MrmTraceLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,10 @@ class MrtRuntimeTraceLoggingProvider : public wil::TraceLoggingProvider
DEFINE_COMPLIANT_MEASURES_EVENT_PARAM4(MeasureGenericEvent, PDT_ProductAndServicePerformance, PCWSTR, functionName, PCWSTR, message1, PCWSTR, message2, int, hresult);
};

// case insensitive prefix match of "*:\users"
__inline PCWSTR RemoveUsernameFromPath(_In_ PCWSTR filePath)
// Remove PII from string
inline PCWSTR RemovePiiUserProfileFilename(PCWSTR)
{
if ((filePath != NULL) &&
(filePath[0] != 0) &&
(filePath[1] == L':') &&
(filePath[2] == L'\\') &&
((filePath[3] == L'u') || (filePath[3] == L'U')) &&
((filePath[4] == L's') || (filePath[4] == L'S')) &&
((filePath[5] == L'e') || (filePath[5] == L'E')) &&
((filePath[6] == L'r') || (filePath[6] == L'R')) &&
((filePath[7] == L's') || (filePath[7] == L'S')) &&
(filePath[8] == L'\\'))
{
PCWSTR logPath = wcsstr(&filePath[9], L"\\");
return (logPath != NULL) ? logPath : L"";
}
return filePath;
// TODO: Once the feature below is available, this function can be removed.
// Create a centralized PII scrubber · Issue #1461 (https://github.com/microsoft/WindowsAppSDK/issues/1461)
return L"";
}
10 changes: 5 additions & 5 deletions dev/MRTCore/mrt/mrm/include/mrm/common/PlatformWin32.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ extern "C"
#define WRITE_MRMMIN_INIT_TRACE_INFO(msg, hr) MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, hr)
#define WRITE_MRMMIN_INIT_TRACE_INFO_CHECK(msg, hr) \
{ \
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), RemoveUsernameFromPath(msg), hr); \
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), RemovePiiUserProfileFilename(msg), hr); \
}
#define WRITE_MRMMIN_INIT_TRACE_ERROR(msg, hr) MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, hr)
#define WRITE_MRMMIN_INIT_TRACE_ERROR_CHECK(msg, hr) \
{ \
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), RemoveUsernameFromPath(msg), hr); \
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), RemovePiiUserProfileFilename(msg), hr); \
}
#define WRITE_MRMMIN_INIT_TRACE_ERROR_MEASURE(msg, hr) \
{ \
Expand All @@ -110,14 +110,14 @@ extern "C"
#define WRITE_MRMMIN_INIT_TRACE_ERROR_MEASURE_CHECK(msg, hr) \
{ \
LOG_ERROR_IN_MEMORY(hr, __LINE__, __FILE__, msg); \
MrtRuntimeTraceLoggingProvider::MeasureGenericEvent(TOWIDE(__FUNCTION__), RemoveUsernameFromPath(msg), hr); \
MrtRuntimeTraceLoggingProvider::MeasureGenericEvent(TOWIDE(__FUNCTION__), RemovePiiUserProfileFilename(msg), hr); \
}

#define WRITE_MRMMIN_TRACE_INFO(msg, msg2, hr) MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, msg2, hr)
#define WRITE_MRMMIN_TRACE_WARNING(msg, msg2, hr) MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, msg2, hr)
#define WRITE_MRMMIN_TRACE_WARNING_CHECK(msg, msg2, hr) \
{ \
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, RemoveUsernameFromPath(msg2), hr); \
MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, RemovePiiUserProfileFilename(msg2), hr); \
}
#define WRITE_MRMMIN_TRACE_ERROR(msg, msg2, hr) MrtRuntimeTraceLoggingProvider::TelemetryGenericEvent(TOWIDE(__FUNCTION__), msg, msg2, hr)
#define WRITE_MRMMIN_TRACE_ERROR_MEASURE(msg, msg2, hr) \
Expand All @@ -128,7 +128,7 @@ extern "C"
#define WRITE_MRMMIN_TRACE_ERROR_MEASURE_CHECK(msg, msg2, hr) \
{ \
LOG_ERROR_IN_MEMORY(hr, __LINE__, __FILE__, msg2); \
MrtRuntimeTraceLoggingProvider::MeasureGenericEvent(TOWIDE(__FUNCTION__), msg, RemoveUsernameFromPath(msg2), hr); \
MrtRuntimeTraceLoggingProvider::MeasureGenericEvent(TOWIDE(__FUNCTION__), msg, RemovePiiUserProfileFilename(msg2), hr); \
}

#define WRITE_ETW(etw) __noop

0 comments on commit 9323313

Please sign in to comment.