Skip to content

Commit ba88391

Browse files
authored
Remove Telemetry (#550)
* Remove Telemetry * Remove Cached Docs build * Delete PRIVACY.md
1 parent 85d1d50 commit ba88391

File tree

166 files changed

+92
-62606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+92
-62606
lines changed

Benchmarks/LiteDbManager.cs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static class LiteDbManager
2323

2424
private static readonly ConcurrentBag<ILiteCollection<WriteObject>> WriteObjectCollections = new ConcurrentBag<ILiteCollection<WriteObject>>();
2525

26-
private static Settings settings { get; set; } = new Settings() { SchemaVersion = SCHEMA_VERSION, ShardingFactor = 1, TelemetryEnabled = true };
26+
private static Settings settings { get; set; } = new Settings() { SchemaVersion = SCHEMA_VERSION, ShardingFactor = 1 };
2727

2828
public static ConcurrentQueue<WriteObject> WriteQueue { get; private set; } = new ConcurrentQueue<WriteObject>();
2929

@@ -435,32 +435,6 @@ public static void DeleteRun(string runId)
435435
Results?.DeleteMany(x => x.RunId == runId);
436436
}
437437

438-
public static bool GetOptOut()
439-
{
440-
//var settings = db.GetCollection<Setting>("Settings");
441-
//var optout = settings.FindOne(x => x.Name == "TelemetryOptOut");
442-
//return bool.Parse(optout.Value);
443-
return false;
444-
}
445-
446-
public static void SetOptOut(bool OptOut)
447-
{
448-
//var settings = db.GetCollection<Setting>("Settings");
449-
450-
//settings.Upsert(new Setting() { Name = "TelemetryOptOut", Value = OptOut.ToString() });
451-
}
452-
453-
//public static void WriteFileMonitor(FileMonitorObject obj, string runId)
454-
//{
455-
// var fme = db.GetCollection<FileMonitorEvent>();
456-
457-
// fme.Insert(new FileMonitorEvent()
458-
// {
459-
// RunId = runId,
460-
// FMO = obj
461-
// });
462-
//}
463-
464438
public static AsaRun? GetRun(string RunId)
465439
{
466440
var runs = db?.GetCollection<AsaRun>("Runs");

Benchmarks/SystemSqliteDatabaseManager.cs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ public static bool Setup(string filename, DBSettings? dbSettingsIn = null)
150150

151151
dbSettings.ShardingFactor = settings.ShardingFactor;
152152

153-
AsaTelemetry.SetEnabled(settings.TelemetryEnabled);
154153
}
155154
else
156155
{
@@ -202,7 +201,6 @@ public static bool Setup(string filename, DBSettings? dbSettingsIn = null)
202201
{
203202
SchemaVersion = SCHEMA_VERSION,
204203
ShardingFactor = dbSettings.ShardingFactor,
205-
TelemetryEnabled = true
206204
});
207205

208206
Connections.AsParallel().ForAll(cxn =>
@@ -618,7 +616,6 @@ public static void InsertRun(AsaRun run)
618616
{
619617
Log.Warning(e.StackTrace);
620618
Log.Warning(e.Message);
621-
AsaTelemetry.TrackTrace(Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Error, e);
622619
}
623620
}
624621
else
@@ -765,27 +762,7 @@ public static void DeleteRun(string runid)
765762
truncateCollectTable.ExecuteNonQuery();
766763
});
767764
}
768-
769-
public static bool GetTelemetryEnabled()
770-
{
771-
var settings = GetSettings();
772-
if (settings != null)
773-
{
774-
return settings.TelemetryEnabled;
775-
}
776-
return true;
777-
}
778-
779-
public static void SetTelemetryEnabled(bool Enabled)
780-
{
781-
var settings = GetSettings();
782-
if (settings != null)
783-
{
784-
settings.TelemetryEnabled = Enabled;
785-
SetSettings(settings);
786-
}
787-
}
788-
765+
789766
public static void WriteFileMonitor(FileMonitorObject fmo, string RunId)
790767
{
791768
if (fmo == null)

Cli/Controllers/HomeController.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,6 @@ public IActionResult Collect()
181181
return View();
182182
}
183183

184-
public ActionResult ChangeTelemetryState(bool EnableTelemetry)
185-
{
186-
AsaTelemetry.SetEnabled(EnableTelemetry);
187-
188-
return Json(true);
189-
}
190-
191184
public ActionResult StartMonitoring(string RunId, string Directory)
192185
{
193186
if (RunId != null)

Cli/Program.cs

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ private static int RunGuiCommand(GuiCommandOptions opts)
137137
#else
138138
Logger.Setup(opts.Debug, opts.Verbose, opts.Quiet);
139139
#endif
140-
AsaTelemetry.Setup();
141140

142141
var server = WebHost.CreateDefaultBuilder(Array.Empty<string>())
143142
.UseStartup<Startup>()
@@ -166,7 +165,6 @@ private static void SleepAndOpenBrowser(int sleep)
166165
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>")]
167166
private static int RunConfigCommand(ConfigCommandOptions opts)
168167
{
169-
AsaTelemetry.Setup();
170168

171169
if (opts.ResetDatabase)
172170
{
@@ -176,8 +174,6 @@ private static int RunConfigCommand(ConfigCommandOptions opts)
176174
}
177175
else
178176
{
179-
CheckFirstRun();
180-
181177
SetupDatabase(opts);
182178

183179
if (opts.ListRuns)
@@ -242,9 +238,6 @@ private static int RunConfigCommand(ConfigCommandOptions opts)
242238
}
243239
}
244240

245-
AsaTelemetry.SetEnabled(opts.TelemetryOptOut);
246-
Log.Information(Strings.Get("TelemetryOptOut"), opts.TelemetryOptOut ? "Opted out" : "Opted in");
247-
248241
if (opts.DeleteRunId != null)
249242
{
250243
DatabaseManager.DeleteRun(opts.DeleteRunId);
@@ -271,9 +264,6 @@ private static int RunExportCollectCommand(ExportCollectCommandOptions opts)
271264
return 0;
272265
}
273266

274-
CheckFirstRun();
275-
AsaTelemetry.Setup();
276-
277267
if (opts.ExportSingleRun)
278268
{
279269
if (opts.SecondRunId is null)
@@ -312,11 +302,6 @@ private static int RunExportCollectCommand(ExportCollectCommandOptions opts)
312302

313303
Log.Information(Strings.Get("Comparing"), opts.FirstRunId, opts.SecondRunId);
314304

315-
Dictionary<string, string> StartEvent = new Dictionary<string, string>();
316-
StartEvent.Add("OutputPathSet", (opts.OutputPath != null).ToString(CultureInfo.InvariantCulture));
317-
318-
AsaTelemetry.TrackEvent("{0} Export Compare", StartEvent);
319-
320305
CompareCommandOptions options = new CompareCommandOptions(opts.FirstRunId, opts.SecondRunId)
321306
{
322307
DatabaseFilename = opts.DatabaseFilename,
@@ -458,17 +443,6 @@ public static void WriteScanJson(int ResultType, string BaseId, string CompareId
458443

459444
}
460445

461-
private static void CheckFirstRun()
462-
{
463-
if (DatabaseManager.FirstRun)
464-
{
465-
string exeStr = $"config --telemetry-opt-out";
466-
Log.Information(Strings.Get("ApplicationHasTelemetry"));
467-
Log.Information(Strings.Get("ApplicationHasTelemetry2"), "https://github.com/Microsoft/AttackSurfaceAnalyzer/blob/master/PRIVACY.md");
468-
Log.Information(Strings.Get("ApplicationHasTelemetry3"), exeStr);
469-
}
470-
}
471-
472446
private static int RunExportMonitorCommand(ExportMonitorCommandOptions opts)
473447
{
474448
#if DEBUG
@@ -483,9 +457,6 @@ private static int RunExportMonitorCommand(ExportMonitorCommandOptions opts)
483457
return 0;
484458
}
485459

486-
CheckFirstRun();
487-
AsaTelemetry.Setup();
488-
489460
if (opts.RunId is null)
490461
{
491462
List<string> runIds = DatabaseManager.GetLatestRunIds(1, RUN_TYPE.MONITOR);
@@ -503,11 +474,6 @@ private static int RunExportMonitorCommand(ExportMonitorCommandOptions opts)
503474

504475
Log.Information("{0} {1}", Strings.Get("Exporting"), opts.RunId);
505476

506-
Dictionary<string, string> StartEvent = new Dictionary<string, string>();
507-
StartEvent.Add("OutputPathSet", (opts.OutputPath != null).ToString(CultureInfo.InvariantCulture));
508-
509-
AsaTelemetry.TrackEvent("Begin Export Monitor", StartEvent);
510-
511477
WriteMonitorJson(opts.RunId, (int)RESULT_TYPE.FILE, opts.OutputPath ?? "monitor.json");
512478

513479
return 0;
@@ -548,15 +514,6 @@ private static int RunMonitorCommand(MonitorCommandOptions opts)
548514
#endif
549515
AdminOrQuit();
550516

551-
AsaTelemetry.Setup();
552-
553-
Dictionary<string, string> StartEvent = new Dictionary<string, string>();
554-
StartEvent.Add("Files", opts.EnableFileSystemMonitor.ToString(CultureInfo.InvariantCulture));
555-
StartEvent.Add("Admin", AsaHelpers.IsAdmin().ToString(CultureInfo.InvariantCulture));
556-
AsaTelemetry.TrackEvent("Begin monitoring", StartEvent);
557-
558-
CheckFirstRun();
559-
560517
if (opts.RunId is string)
561518
{
562519
opts.RunId = opts.RunId.Trim();
@@ -793,7 +750,6 @@ public static List<BaseCompare> GetComparators()
793750
}
794751

795752
DatabaseManager.Commit();
796-
AsaTelemetry.TrackEvent("End Command", EndEvent);
797753
return c.Results;
798754
}
799755

@@ -862,7 +818,6 @@ public static void AdminOrQuit()
862818
}
863819
}
864820

865-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Acceptable tradeoff with telemetry (to identify issues) to lessen severity of individual collector crashes.")]
866821
public static int RunCollectCommand(CollectCommandOptions opts)
867822
{
868823
if (opts == null) { return -1; }
@@ -874,25 +829,8 @@ public static int RunCollectCommand(CollectCommandOptions opts)
874829

875830
collectors.Clear();
876831

877-
AsaTelemetry.Setup();
878-
879-
Dictionary<string, string> StartEvent = new Dictionary<string, string>();
880-
StartEvent.Add("Files", opts.EnableAllCollectors ? "True" : opts.EnableFileSystemCollector.ToString(CultureInfo.InvariantCulture));
881-
StartEvent.Add("Ports", opts.EnableNetworkPortCollector.ToString(CultureInfo.InvariantCulture));
882-
StartEvent.Add("Users", opts.EnableUserCollector.ToString(CultureInfo.InvariantCulture));
883-
StartEvent.Add("Certificates", opts.EnableCertificateCollector.ToString(CultureInfo.InvariantCulture));
884-
StartEvent.Add("Registry", opts.EnableRegistryCollector.ToString(CultureInfo.InvariantCulture));
885-
StartEvent.Add("Service", opts.EnableServiceCollector.ToString(CultureInfo.InvariantCulture));
886-
StartEvent.Add("Firewall", opts.EnableFirewallCollector.ToString(CultureInfo.InvariantCulture));
887-
StartEvent.Add("ComObject", opts.EnableComObjectCollector.ToString(CultureInfo.InvariantCulture));
888-
StartEvent.Add("EventLog", opts.EnableEventLogCollector.ToString(CultureInfo.InvariantCulture));
889-
StartEvent.Add("Admin", AsaHelpers.IsAdmin().ToString(CultureInfo.InvariantCulture));
890-
AsaTelemetry.TrackEvent("Run Command", StartEvent);
891-
892832
AdminOrQuit();
893833

894-
CheckFirstRun();
895-
896834
int returnValue = (int)ASA_ERROR.NONE;
897835
opts.RunId = opts.RunId?.Trim() ?? DateTime.Now.ToString("o", CultureInfo.InvariantCulture);
898836

@@ -1033,15 +971,9 @@ public static int RunCollectCommand(CollectCommandOptions opts)
1033971
catch (Exception e)
1034972
{
1035973
Log.Error(Strings.Get("Err_CollectingFrom"), c.GetType().Name, e.Message, e.StackTrace);
1036-
Dictionary<string, string> ExceptionEvent = new Dictionary<string, string>();
1037-
ExceptionEvent.Add("Exception Type", e.GetType().ToString());
1038-
ExceptionEvent.Add("Stack Trace", e.StackTrace ?? string.Empty);
1039-
ExceptionEvent.Add("Message", e.Message);
1040-
AsaTelemetry.TrackEvent("CollectorCrashRogueException", ExceptionEvent);
1041974
returnValue = 1;
1042975
}
1043976
}
1044-
AsaTelemetry.TrackEvent("End Command", EndEvent);
1045977

1046978
DatabaseManager.Commit();
1047979
return returnValue;

Cli/Startup.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ public void ConfigureServices(IServiceCollection services)
4343
}
4444
});
4545

46-
services.AddApplicationInsightsTelemetry();
47-
4846
services.AddControllersWithViews();
49-
50-
5147
}
5248

5349
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

Cli/Views/Home/Index.cshtml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,6 @@
2727
<a asp-area="" asp-controller="Home" asp-action="Collect" class="btn btn-primary btn-square" id="indexGetStartedButton">Get Started</a>
2828
</div>
2929
</div>
30-
@{
31-
if (AsaTelemetry.Enabled)
32-
{
33-
<label for="TelemetryOpt">
34-
<input type="checkbox" id="TelemetryOpt" checked /> @Strings.Get("UsageData") <a href="https://github.com/Microsoft/AttackSurfaceAnalyzer/blob/master/PRIVACY.md" target="_blank">Privacy</a>
35-
</label>
36-
}
37-
else
38-
{
39-
<label for="TelemetryOpt">
40-
<input type="checkbox" id="TelemetryOpt" /> @Strings.Get("UsageData") <a href="https://github.com/Microsoft/AttackSurfaceAnalyzer/blob/master/PRIVACY.md" target="_blank">Privacy</a>
41-
</label>
42-
}
43-
}
4430
<br />
4531
<div class="spacer"></div>
4632
<div id="moreInfo">

Cli/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
2-
@using Microsoft.ApplicationInsights.Extensibility;
3-
@using AttackSurfaceAnalyzer.Utils;
1+
@using AttackSurfaceAnalyzer.Utils;
42
@using System.Runtime.InteropServices;
53

64
<!DOCTYPE html>
@@ -15,12 +13,6 @@
1513
<link rel="stylesheet" href="~/css/bootstrap.min.css">
1614
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
1715
<link rel="localizations" href="~/American-English.json" type="application/vnd.oftn.l10n+json" />
18-
@{
19-
if (AsaTelemetry.Enabled)
20-
{
21-
Html.Raw(snippet.FullScript);
22-
}
23-
}
2416

2517
<script src="~/lib/jquery-3.4.1.min.js"></script>
2618
<script src="~/lib/fontawesome.js"></script>

Cli/wwwroot/js/Index.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)