-
Notifications
You must be signed in to change notification settings - Fork 335
Telemetry #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Telemetry #529
Changes from 23 commits
94142ee
f538052
4c9a924
4bba47f
5c6ca68
1dc4516
7ec8e95
4b99f99
dd3e61e
f3e549d
7408471
1cbc4ae
4db523a
d726807
1732a33
c0e0cd6
8f1361e
841ddd8
f653eb6
f8596da
b4f484e
91e4868
c5aba35
0ff658c
93a1203
bd6a1eb
b56b372
3b5d5c8
dd67c4c
f96d760
791708c
63e995b
8e989c1
4f96457
09c0e31
5562de9
2680760
ec73f1d
150605e
fa64976
07870a1
baccc08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* ++ | ||
|
||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
Module Name: | ||
|
||
TraceLoggingConfig.h | ||
|
||
Abstract: | ||
|
||
Macro definitions used by this project's TraceLogging ETW providers: | ||
|
||
- Configuration macros that select the ETW Provider Groups to be used by | ||
this project. | ||
- Constants for tags that are commonly used in Microsoft's | ||
TraceLogging-based ETW. | ||
|
||
Different versions of this file use different definitions for the | ||
TraceLoggingOption configuration macros. The definitions in this file are | ||
empty. As a result, providers using this configuration file will not join | ||
any ETW Provider Groups and will not be given any special treatment by | ||
group-sensitive ETW listeners. | ||
|
||
Environment: | ||
|
||
User mode or kernel mode. | ||
|
||
--*/ | ||
|
||
#pragma once | ||
|
||
// Configuration macro for use in TRACELOGGING_DEFINE_PROVIDER. The definition | ||
// in this file configures the provider as a normal (non-telemetry) provider. | ||
#define TraceLoggingOptionMicrosoftTelemetry() \ | ||
// Empty definition for TraceLoggingOptionMicrosoftTelemetry | ||
|
||
// Configuration macro for use in TRACELOGGING_DEFINE_PROVIDER. The definition | ||
// in this file configures the provider as a normal (non-telemetry) provider. | ||
#define TraceLoggingOptionWindowsCoreTelemetry() \ | ||
// Empty definition for TraceLoggingOptionWindowsCoreTelemetry | ||
|
||
// Event privacy tags. Use the PDT macro values for the tag parameter, e.g.: | ||
// TraceLoggingWrite(..., | ||
// TelemetryPrivacyDataTag(PDT_BrowsingHistory | PDT_ProductAndServiceUsage), | ||
// ...); | ||
#define TelemetryPrivacyDataTag(tag) TraceLoggingUInt64((tag), "PartA_PrivTags") | ||
#define PDT_BrowsingHistory 0x0000000000000002u | ||
#define PDT_DeviceConnectivityAndConfiguration 0x0000000000000800u | ||
#define PDT_InkingTypingAndSpeechUtterance 0x0000000000020000u | ||
#define PDT_ProductAndServicePerformance 0x0000000001000000u | ||
#define PDT_ProductAndServiceUsage 0x0000000002000000u | ||
#define PDT_SoftwareSetupAndInventory 0x0000000080000000u | ||
|
||
// Event categories specified via keywords, e.g.: | ||
// TraceLoggingWrite(..., | ||
// TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), | ||
// ...); | ||
#define MICROSOFT_KEYWORD_CRITICAL_DATA 0x0000800000000000 // Bit 47 | ||
#define MICROSOFT_KEYWORD_MEASURES 0x0000400000000000 // Bit 46 | ||
#define MICROSOFT_KEYWORD_TELEMETRY 0x0000200000000000 // Bit 45 | ||
#define MICROSOFT_KEYWORD_RESERVED_44 0x0000100000000000 // Bit 44 (reserved for future assignment) | ||
|
||
// Event categories specified via event tags, e.g.: | ||
// TraceLoggingWrite(..., | ||
// TraceLoggingEventTag(MICROSOFT_EVENTTAG_REALTIME_LATENCY), | ||
// ...); | ||
#define MICROSOFT_EVENTTAG_DROP_USER_IDS 0x00008000 | ||
#define MICROSOFT_EVENTTAG_AGGREGATE 0x00010000 | ||
#define MICROSOFT_EVENTTAG_DROP_PII_EXCEPT_IP 0x00020000 | ||
#define MICROSOFT_EVENTTAG_COSTDEFERRED_LATENCY 0x00040000 | ||
#define MICROSOFT_EVENTTAG_CORE_DATA 0x00080000 | ||
#define MICROSOFT_EVENTTAG_INJECT_XTOKEN 0x00100000 | ||
#define MICROSOFT_EVENTTAG_REALTIME_LATENCY 0x00200000 | ||
#define MICROSOFT_EVENTTAG_NORMAL_LATENCY 0x00400000 | ||
#define MICROSOFT_EVENTTAG_CRITICAL_PERSISTENCE 0x00800000 | ||
#define MICROSOFT_EVENTTAG_NORMAL_PERSISTENCE 0x01000000 | ||
#define MICROSOFT_EVENTTAG_DROP_PII 0x02000000 | ||
#define MICROSOFT_EVENTTAG_HASH_PII 0x04000000 | ||
#define MICROSOFT_EVENTTAG_MARK_PII 0x08000000 | ||
|
||
// Field categories specified via field tags, e.g.: | ||
// TraceLoggingWrite(..., | ||
// TraceLoggingString(szUser, "UserName", "User's name", MICROSOFT_FIELDTAG_HASH_PII), | ||
// ...); | ||
#define MICROSOFT_FIELDTAG_DROP_PII 0x04000000 | ||
#define MICROSOFT_FIELDTAG_HASH_PII 0x08000000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
/* | ||
this file defines functions to collect Microsoft Telemetry, | ||
tgauth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
which will only be sent for Windows In-Box releases. | ||
GitHub releases will not send any Telemetry. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <Objbase.h> | ||
|
||
#include "telemetry.h" | ||
#include "telemetryInternal.h" | ||
|
||
// {0d986661-0dd7-561a-b15b-fcc1cd46d2bb} | ||
TRACELOGGING_DEFINE_PROVIDER( | ||
g_hProvider1, | ||
"Microsoft.Windows.Win32OpenSSH", | ||
(0x0d986661, 0x0dd7, 0x561a, 0xb1, 0x5b, 0xfc, 0xc1, 0xcd, 0x46, 0xd2, 0xbb), | ||
TraceLoggingOptionMicrosoftTelemetry()); | ||
|
||
void send_auth_telemetry(const int status, const char* auth_type) | ||
{ | ||
#ifdef WINDOWS_TELEMETRY | ||
TraceLoggingRegister(g_hProvider1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for registering and unregistering in the each telemetry function? Isn't it supposed to be one time activity? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about this, as well. My reasoning was to always ensure the provider gets properly unregistered, since I can't guarantee that ssh/sshd will make it to the last telemetry call, if I were to only do it once. What would be the best place to unregister the provider (if necessary)? |
||
TraceLoggingWrite( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this defined for the Github release? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you checked the increase in the number of warnings .. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the question, but this file will be included in the Github release
Warnings when building in VS? I do not see any increase in the number of warnings. There are 5 warnings that also occur in the latestw_all branch, and the 81010002 warnings from the targetos.manifest file do not occur |
||
g_hProvider1, | ||
"Auth", | ||
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), | ||
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), | ||
TraceLoggingInt16(status, "Success"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you paste how it looks like once telemetry is posted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the ETW trace from my local device: Tracelogging Sample. It only includes the telemetry that falls under tracelogging. |
||
TraceLoggingString(auth_type, "Auth Type") | ||
); | ||
TraceLoggingUnregister(g_hProvider1); | ||
#endif | ||
} | ||
|
||
void send_encryption_telemetry(const char* direction, const char* cipher, const char* kex, | ||
const char* mac, const char* comp, const char* host_key, const char** cproposal, const char** sproposal) | ||
{ | ||
#ifdef WINDOWS_TELEMETRY | ||
TraceLoggingRegister(g_hProvider1); | ||
TraceLoggingWrite( | ||
g_hProvider1, | ||
"Encryption", | ||
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), | ||
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), | ||
TraceLoggingString(direction, "direction"), | ||
TraceLoggingString(cipher, "cipher"), | ||
TraceLoggingString(kex, "kex"), | ||
TraceLoggingString(mac, "mac"), | ||
TraceLoggingString(comp, "compression"), | ||
TraceLoggingString(host_key, "host_key"), | ||
TraceLoggingString(cproposal[0], "client proposed kex"), | ||
TraceLoggingString(cproposal[1], "client proposed host keys"), | ||
TraceLoggingString(cproposal[2], "client proposed ciphers ctos"), | ||
TraceLoggingString(cproposal[3], "client proposed ciphers stoc"), | ||
TraceLoggingString(cproposal[4], "client proposed MACs ctos"), | ||
TraceLoggingString(cproposal[5], "client proposed MACs stoc"), | ||
TraceLoggingString(cproposal[6], "client proposed compression ctos"), | ||
TraceLoggingString(cproposal[7], "client proposed compression stoc"), | ||
TraceLoggingString(sproposal[0], "server proposed kex"), | ||
TraceLoggingString(sproposal[1], "server proposed host keys"), | ||
TraceLoggingString(sproposal[2], "server proposed ciphers ctos"), | ||
TraceLoggingString(sproposal[3], "server proposed ciphers stoc"), | ||
TraceLoggingString(sproposal[4], "server proposed MACs ctos"), | ||
TraceLoggingString(sproposal[5], "server proposed MACs stoc"), | ||
TraceLoggingString(sproposal[6], "server proposed compression ctos"), | ||
TraceLoggingString(sproposal[7], "server proposed compression stoc") | ||
); | ||
TraceLoggingUnregister(g_hProvider1); | ||
#endif | ||
} | ||
|
||
void send_key_telemetry(const char* key) | ||
tgauth marked this conversation as resolved.
Show resolved
Hide resolved
tgauth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
#ifdef WINDOWS_TELEMETRY | ||
TraceLoggingRegister(g_hProvider1); | ||
TraceLoggingWrite( | ||
g_hProvider1, | ||
"Key", | ||
tgauth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), | ||
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), | ||
TraceLoggingString(key, "Status") | ||
); | ||
TraceLoggingUnregister(g_hProvider1); | ||
#endif | ||
} | ||
|
||
void send_shell_telemetry(const int pty, const int shell_type) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think shell_type comes under PIR. please check with Danny. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Asked Danny on Teams, please see Telemetry summary thread |
||
{ | ||
#ifdef WINDOWS_TELEMETRY | ||
TraceLoggingRegister(g_hProvider1); | ||
TraceLoggingWrite( | ||
g_hProvider1, | ||
"Shell", | ||
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), | ||
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), | ||
TraceLoggingInt16(pty, "PTY"), | ||
TraceLoggingInt16(shell_type, "Type") | ||
); | ||
TraceLoggingUnregister(g_hProvider1); | ||
#endif | ||
} | ||
|
||
void send_sign_telemetry(const char* sign_status) | ||
tgauth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
#ifdef WINDOWS_TELEMETRY | ||
TraceLoggingRegister(g_hProvider1); | ||
TraceLoggingWrite( | ||
g_hProvider1, | ||
"Signing", | ||
tgauth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), | ||
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), | ||
TraceLoggingString(sign_status, "Status") | ||
); | ||
TraceLoggingUnregister(g_hProvider1); | ||
#endif | ||
} | ||
|
||
void send_ssh_telemetry(const char* conn) | ||
tgauth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
#ifdef WINDOWS_TELEMETRY | ||
TraceLoggingRegister(g_hProvider1); | ||
TraceLoggingWrite( | ||
g_hProvider1, | ||
"Connection", | ||
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), | ||
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), | ||
TraceLoggingString(conn, "Status") | ||
); | ||
TraceLoggingUnregister(g_hProvider1); | ||
#endif | ||
} | ||
|
||
void send_sshd_telemetry(const int num_auth_methods, const char** auth_methods, | ||
tgauth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const unsigned int num_ports, const int ports[]) | ||
{ | ||
#ifdef WINDOWS_TELEMETRY | ||
char* auth_buffer = NULL; | ||
|
||
|
||
if (num_auth_methods == 0) { | ||
auth_buffer = (char*)malloc(5 * sizeof(char)); | ||
strcpy_s(auth_buffer, 5, "none"); | ||
} | ||
else { | ||
// concatenate all the auth methods into a | ||
// single string to pass to tracelogging | ||
size_t buffer_size = (size_t)num_auth_methods; | ||
for (int i = 0; i < num_auth_methods; i++) { | ||
buffer_size += strlen(auth_methods[i]); | ||
} | ||
auth_buffer = (char*)malloc(buffer_size * sizeof(char)); | ||
tgauth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
auth_buffer[0] = '\0'; | ||
for (int i = 0; i < num_auth_methods; i++) { | ||
strcat_s(auth_buffer, buffer_size, auth_methods[i]); | ||
if (i < num_auth_methods - 1) { | ||
strcat_s(auth_buffer, buffer_size, ","); | ||
} | ||
} | ||
} | ||
|
||
TraceLoggingRegister(g_hProvider1); | ||
TraceLoggingWrite( | ||
g_hProvider1, | ||
"SSHD", | ||
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), | ||
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), | ||
TraceLoggingInt32Array(ports, num_ports, "Port"), | ||
TraceLoggingString(auth_buffer, "Auth Methods") | ||
); | ||
TraceLoggingUnregister(g_hProvider1); | ||
free(auth_buffer); | ||
#endif | ||
} | ||
|
||
void send_startup_telemetry(const char* ssh_version, const char* peer_version, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename it to send_ssh_version_telemetry There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a common code for both client and server. See if you can add it's coming from client or server |
||
const char* remote_protocol_supported) | ||
{ | ||
#ifdef WINDOWS_TELEMETRY | ||
TraceLoggingRegister(g_hProvider1); | ||
TraceLoggingWrite( | ||
g_hProvider1, | ||
"Startup", | ||
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), | ||
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), | ||
TraceLoggingString(ssh_version, " our version"), | ||
TraceLoggingString(remote_protocol_supported, "remote protocol error"), | ||
TraceLoggingString(peer_version, "peer version") | ||
); | ||
TraceLoggingUnregister(g_hProvider1); | ||
#endif | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
// sends authentication status & method (key, pw, etc.) | ||
tgauth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
void send_auth_telemetry(const int status, const char* auth_type); | ||
|
||
// sends crypto information like cipher, kex, and mac | ||
void send_encryption_telemetry(const char* direction, | ||
const char* cipher, const char* kex, const char* mac, | ||
const char* comp, const char* host_key, | ||
const char** cproposal, const char** sproposal); | ||
|
||
// sends status if using key-based auth | ||
void send_key_telemetry(const char* key); | ||
|
||
// sends shell configuration and if pty session is used | ||
void send_shell_telemetry(const int pty, const int shell_type); | ||
|
||
// sends signing status if using key-based auth | ||
void send_sign_telemetry(const char* sign_status); | ||
|
||
// sends connection status from ssh client | ||
void send_ssh_telemetry(const char* conn); | ||
|
||
// sends ports and auth methods configured by sshd | ||
void send_sshd_telemetry(const int num_auth_methods, const char** auth_methods, | ||
const unsigned int num_ports, const int ports[]); | ||
|
||
// sends version and peer version from ssh & sshd | ||
void send_startup_telemetry(const char* ssh_version, | ||
const char* peer_version, const char* remote_protocol_supported); |
Uh oh!
There was an error while loading. Please reload this page.