зеркало из
1
0
Форкнуть 0

Address CR feedback. Remove the json content blob from telemetry

This commit is contained in:
Madhu Pandeti 2019-05-28 11:37:46 -07:00
Родитель 668e149621
Коммит 26ea8cc599
5 изменённых файлов: 29 добавлений и 53 удалений

Просмотреть файл

@ -368,35 +368,9 @@ void LogApplicationAndProcessesCollection()
}
}
void LogJsonConfig()
{
#pragma warning(suppress:4996) // Nonsense warning; _wfopen is perfectly safe
auto file = _wfopen((std::filesystem::path(PSFQueryPackageRootPath()) / L"config.json").c_str(), L"rb, ccs=UTF-8");
if (file)
{
fseek(file, 0, SEEK_END);
auto size = ftell(file);
auto fileContents = std::make_unique<char[]>(static_cast<int>(size + 1));
rewind(file);
fread(fileContents.get(), sizeof(char), size, file);
fileContents[size] = 0;
TraceLoggingWrite(
g_Log_ETW_ComponentProvider,
"JsonConfig",
TraceLoggingValue(fileContents.get(), "config_data"),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage),
TraceLoggingKeyword(MICROSOFT_KEYWORD_CRITICAL_DATA));
fclose(file);
}
}
int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR args, int cmdShow)
{
TraceLoggingRegister(g_Log_ETW_ComponentProvider);
LogJsonConfig();
int result = launcher_main(args, cmdShow);
TraceLoggingUnregister(g_Log_ETW_ComponentProvider);
return result;

Просмотреть файл

@ -53,5 +53,5 @@ Here is how you can contribute to the Package Support Framework:
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## Data/Telemetry
Telemetry datapoint has been hooked to collect usage data and sends it to Microsoft to help improve our products and services. Read Microsoft's [privacy statement to learn more](https://privacy.microsoft.com/en-US/privacystatement). However, Data will be collected only when the PSF binaries are used from [Nuget package](https://www.nuget.org/packages?q=packagesupportframework)
on Windows 10 devices and only if users have enabled collection of data. Nuget package has the binaries signed and will collect usage data from machine. When the binaries are built locally by cloning the repo or downloading the bits, then telemetry is not collected.
Telemetry datapoint has been hooked to collect usage data and sends it to Microsoft to help improve our products and services. Read Microsoft's [privacy statement to learn more](https://privacy.microsoft.com/en-US/privacystatement). However, data will be collected only when the PSF binaries are used from [Nuget package](https://www.nuget.org/packages?q=packagesupportframework)
on Windows 10 devices and only if users have enabled collection of data. The Nuget package has binaries signed and will collect usage data from machine. When the binaries are built locally by cloning the repo or downloading the bits, then telemetry is not collected.

Просмотреть файл

@ -177,9 +177,10 @@ void InitializeConfiguration()
if (auto rootConfig = ::PSFQueryCurrentDllConfig())
{
auto& rootObject = rootConfig->as_object();
traceDataStream << " config:\n";
if (auto pathsValue = rootObject.try_get("redirectedPaths"))
{
traceDataStream << " redirectedPaths : \n";
traceDataStream << " redirectedPaths:\n";
auto& redirectedPathsObject = pathsValue->as_object();
auto initializeRedirection = [&traceDataStream](const std::filesystem::path & basePath, const psf::json_array & specs, bool traceOnly = false)
{
@ -187,12 +188,12 @@ void InitializeConfiguration()
{
auto& specObject = spec.as_object();
auto path = psf::remove_trailing_path_separators(basePath / specObject.get("base").as_string().wstring());
traceDataStream << " base : " << RemovePIIfromFilePath(specObject.get("base").as_string().wide());
traceDataStream << " patterns : ";
traceDataStream << " base:" << RemovePIIfromFilePath(specObject.get("base").as_string().wide()) << " ;";
traceDataStream << " patterns:";
for (auto& pattern : specObject.get("patterns").as_array())
{
auto patternString = pattern.as_string().wstring();
traceDataStream << pattern.as_string().wide();
traceDataStream << pattern.as_string().wide() << " ;";
if (!traceOnly)
{
g_redirectionSpecs.emplace_back();
@ -205,26 +206,26 @@ void InitializeConfiguration()
if (auto packageRelativeValue = redirectedPathsObject.try_get("packageRelative"))
{
traceDataStream << " packageRelative : \n";
traceDataStream << " packageRelative:\n";
initializeRedirection(g_packageRootPath, packageRelativeValue->as_array());
}
if (auto packageDriveRelativeValue = redirectedPathsObject.try_get("packageDriveRelative"))
{
traceDataStream << " packageDriveRelative : \n";
traceDataStream << " packageDriveRelative:\n";
initializeRedirection(g_packageRootPath.root_name(), packageDriveRelativeValue->as_array());
}
if (auto knownFoldersValue = redirectedPathsObject.try_get("knownFolders"))
{
traceDataStream << " knownFolders : \n";
traceDataStream << " knownFolders:\n";
for (auto& knownFolderValue : knownFoldersValue->as_array())
{
auto& knownFolderObject = knownFolderValue.as_object();
auto path = path_from_known_folder_string(knownFolderObject.get("id").as_string().wstring());
traceDataStream << " id : " << knownFolderObject.get("id").as_string().wide();
traceDataStream << " id:" << knownFolderObject.get("id").as_string().wide() << " ;";
traceDataStream << " relativePaths : \n";
traceDataStream << " relativePaths:\n";
initializeRedirection(path, knownFolderObject.get("relativePaths").as_array(), !path.empty());
}
}
@ -242,13 +243,13 @@ void InitializeConfiguration()
TraceLoggingUnregister(g_Log_ETW_ComponentProvider);
}
bool path_relative_to(const wchar_t* path, const std::filesystem::path & basePath)
bool path_relative_to(const wchar_t* path, const std::filesystem::path& basePath)
{
return std::equal(basePath.native().begin(), basePath.native().end(), path, psf::path_compare{});
}
template <typename CharT>
normalized_path NormalizePathImpl(const CharT * path)
normalized_path NormalizePathImpl(const CharT* path)
{
normalized_path result;
@ -380,7 +381,7 @@ std::wstring GenerateRedirectedPath(std::wstring_view relativePath, bool ensureD
/// <param name="deVirtualizedPath">The original path from the app</param>
/// <param name="ensureDirectoryStructure">If true, the deVirtualizedPath will be appended to the allowed write location</param>
/// <returns>The new absolute path.</returns>
std::wstring RedirectedPath(const normalized_path & deVirtualizedPath, bool ensureDirectoryStructure)
std::wstring RedirectedPath(const normalized_path& deVirtualizedPath, bool ensureDirectoryStructure)
{
//To prevent apps breaking on an upgrade we redirect writes to the package root path to
//a path that contains the package family name and not the package full name.
@ -427,7 +428,7 @@ std::wstring RedirectedPath(const normalized_path & deVirtualizedPath, bool ensu
}
template <typename CharT>
static path_redirect_info ShouldRedirectImpl(const CharT * path, redirect_flags flags)
static path_redirect_info ShouldRedirectImpl(const CharT* path, redirect_flags flags)
{
path_redirect_info result;

Просмотреть файл

@ -206,11 +206,11 @@ BOOL __stdcall DllMain(HINSTANCE, DWORD reason, LPVOID) noexcept try
{
auto& configObj = config->as_object();
traceDataStream << "config : \n";
traceDataStream << " config:\n";
if (auto method = configObj.try_get("traceMethod"))
{
auto methodStr = method->as_string().string();
traceDataStream << " traceMethod : " << method->as_string().wide() << " ;";
traceDataStream << " traceMethod:" << method->as_string().wide() << " ;";
if (methodStr == "printf"sv)
{
@ -231,12 +231,12 @@ BOOL __stdcall DllMain(HINSTANCE, DWORD reason, LPVOID) noexcept try
if (auto levels = configObj.try_get("traceLevels"))
{
g_traceLevels = &levels->as_object();
traceDataStream << " traceLevels : \n";
traceDataStream << " traceLevels:\n";
// Set default level immediately for fallback purposes
if (auto defaultLevel = g_traceLevels->try_get("default"))
{
traceDataStream << " default : \n" << defaultLevel->as_string().wide() << " ;";
traceDataStream << " default:\n" << defaultLevel->as_string().wide() << " ;";
g_defaultTraceLevel = trace_level_from_configuration(defaultLevel->as_string().string(), g_defaultTraceLevel);
}
}
@ -244,37 +244,37 @@ BOOL __stdcall DllMain(HINSTANCE, DWORD reason, LPVOID) noexcept try
if (auto levels = configObj.try_get("breakOn"))
{
g_breakLevels = &levels->as_object();
traceDataStream << " breakOn : \n";
traceDataStream << " breakOn:\n";
// Set default level immediately for fallback purposes
if (auto defaultLevel = g_breakLevels->try_get("default"))
{
traceDataStream << " default : " << defaultLevel->as_string().wide() << " ;";
traceDataStream << " default:" << defaultLevel->as_string().wide() << " ;";
g_defaultBreakLevel = trace_level_from_configuration(defaultLevel->as_string().string(), g_defaultBreakLevel);
}
}
if (auto debuggerConfig = configObj.try_get("waitForDebugger"))
{
traceDataStream << " waitForDebugger : " << static_cast<bool>(debuggerConfig->as_boolean()) << " ;";
traceDataStream << " waitForDebugger:" << static_cast<bool>(debuggerConfig->as_boolean()) << " ;";
wait_for_debugger = static_cast<bool>(debuggerConfig->as_boolean());
}
if (auto traceEntryConfig = configObj.try_get("traceFunctionEntry"))
{
traceDataStream << " traceFunctionEntry : " << static_cast<bool>(traceEntryConfig->as_boolean()) << " ;";
traceDataStream << " traceFunctionEntry:" << static_cast<bool>(traceEntryConfig->as_boolean()) << " ;";
trace_function_entry = static_cast<bool>(traceEntryConfig->as_boolean());
}
if (auto callerConfig = configObj.try_get("traceCallingModule"))
{
traceDataStream << " traceCallingModule : " << static_cast<bool>(callerConfig->as_boolean()) << " ;";
traceDataStream << " traceCallingModule:" << static_cast<bool>(callerConfig->as_boolean()) << " ;";
trace_calling_module = static_cast<bool>(callerConfig->as_boolean());
}
if (auto ignoreDllConfig = configObj.try_get("ignoreDllLoad"))
{
traceDataStream << " ignoreDllLoad : " << static_cast<bool>(ignoreDllConfig->as_boolean()) << " ;";
traceDataStream << " ignoreDllLoad:" << static_cast<bool>(ignoreDllConfig->as_boolean()) << " ;";
ignore_dll_load = static_cast<bool>(ignoreDllConfig->as_boolean());
}

Просмотреть файл

@ -42,11 +42,12 @@ extern "C" {
bool waitForDebugger = true;
if (auto config = ::PSFQueryCurrentDllConfig())
{
auto& configObject = config->as_object();
auto& configObject = config->as_object();
if (auto enabledValue = configObject.try_get("enabled"))
{
std::wstringstream traceDataStream;
traceDataStream << " enabled : " << static_cast<bool>(enabledValue->as_boolean()) << " ;";
traceDataStream << " config:\n";
traceDataStream << " enabled:" << static_cast<bool>(enabledValue->as_boolean()) << " ;";
TraceLoggingWrite(
g_Log_ETW_ComponentProvider,