Skip to content

Commit 5764033

Browse files
Use hashed name of Linux distros that do not appear in the allowed list
1 parent 2270cf9 commit 5764033

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/platform.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import * as crypto from 'crypto';
67
import * as fs from 'fs';
78
import * as os from 'os';
89
import * as util from './common';
@@ -35,21 +36,29 @@ export class LinuxDistribution {
3536

3637
/**
3738
* Returns a string representation of LinuxDistribution that only returns the
38-
* distro name if it appears on an approved list of known distros. Otherwise,
39+
* distro name if it appears on an allowed list of known distros. Otherwise,
3940
* it returns 'other'.
4041
*/
4142
public toTelemetryString(): string {
42-
const approvedList = [
43+
const allowedList = [
4344
'antergos', 'arch', 'centos', 'debian', 'deepin', 'elementary', 'fedora',
4445
'galliumos', 'gentoo', 'kali', 'linuxmint', 'manjoro', 'neon', 'opensuse',
4546
'parrot', 'rhel', 'ubuntu', 'zorin'
4647
];
4748

48-
if (this.name === unknown || approvedList.indexOf(this.name) >= 0) {
49+
if (this.name === unknown || allowedList.indexOf(this.name) >= 0) {
4950
return this.toString();
5051
}
5152
else {
52-
return 'other';
53+
// Having a hash of the name will be helpful to identify spikes in the 'other'
54+
// bucket when a new distro becomes popular and needs to be added to the
55+
// allowed list above.
56+
const hash = crypto.createHash('sha256');
57+
hash.update(this.name);
58+
59+
const hashedName = hash.digest('hex');
60+
61+
return `other (${hashedName})`;
5362
}
5463
}
5564

0 commit comments

Comments
 (0)