зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1654520 - Concat the networkID to the clientID and SHA256 the result before including in telemetry. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D84859
This commit is contained in:
Родитель
dc37cc06de
Коммит
bb8f770917
|
@ -18,6 +18,7 @@ const { XPCOMUtils } = ChromeUtils.import(
|
|||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
|
||||
ClientID: "resource://gre/modules/ClientID.jsm",
|
||||
ExtensionStorageIDB: "resource://gre/modules/ExtensionStorageIDB.jsm",
|
||||
Heuristics: "resource:///modules/DoHHeuristics.jsm",
|
||||
Preferences: "resource://gre/modules/Preferences.jsm",
|
||||
|
@ -93,6 +94,28 @@ const kLinkStatusChangedTopic = "network:link-status-changed";
|
|||
const kConnectivityTopic = "network:captive-portal-connectivity";
|
||||
const kPrefChangedTopic = "nsPref:changed";
|
||||
|
||||
// Helper function to hash the network ID concatenated with telemetry client ID.
|
||||
// This prevents us from being able to tell if 2 clients are on the same network.
|
||||
function getHashedNetworkID() {
|
||||
let currentNetworkID = gNetworkLinkService.networkID;
|
||||
if (!currentNetworkID) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let hasher = Cc["@mozilla.org/security/hash;1"].createInstance(
|
||||
Ci.nsICryptoHash
|
||||
);
|
||||
|
||||
hasher.init(Ci.nsICryptoHash.SHA256);
|
||||
// Concat the client ID with the network ID before hashing.
|
||||
let clientNetworkID = ClientID.getClientID() + currentNetworkID;
|
||||
hasher.update(
|
||||
clientNetworkID.split("").map(c => c.charCodeAt(0)),
|
||||
clientNetworkID.length
|
||||
);
|
||||
return hasher.finish(true);
|
||||
}
|
||||
|
||||
const DoHController = {
|
||||
_heuristicsAreEnabled: false,
|
||||
|
||||
|
@ -317,7 +340,7 @@ const DoHController = {
|
|||
// care about the startup case though - we want to look at whether the
|
||||
// heuristics result is consistent for networkIDs often seen at startup.
|
||||
// TODO: Use this data to implement cached results to use early at startup.
|
||||
networkID: gNetworkLinkService.networkID,
|
||||
networkID: getHashedNetworkID(),
|
||||
};
|
||||
|
||||
if (results.steeredProvider) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче