Skip to content

Commit 1c653e3

Browse files
authored
Add CLI output to indicate where output went (#141)
1 parent a3398ea commit 1c653e3

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

Cli/AttackSurfaceAnalyzerCli.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
<ItemGroup>
5050
<None Remove="asa.sqlite" />
5151
</ItemGroup>
52+
<ItemGroup>
53+
<Compile Update="Properties\Resources.Designer.cs">
54+
<DesignTime>True</DesignTime>
55+
<AutoGen>True</AutoGen>
56+
<DependentUpon>Resources.resx</DependentUpon>
57+
</Compile>
58+
</ItemGroup>
5259
<ItemGroup>
5360
<EmbeddedResource Update="Properties\Resources.resx">
5461
<Generator>PublicResXFileCodeGenerator</Generator>

Cli/Program.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,16 @@ private static int RunExportCollectCommand(ExportCollectCommandOptions opts)
366366
};
367367
serializer.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
368368
Log.Debug("{0} RunExportCollectCommand", Strings.Get("End"));
369+
string path = Path.Combine(opts.OutputPath, Helpers.MakeValidFileName(opts.FirstRunId + "_vs_" + opts.SecondRunId + "_summary.json.txt"));
369370

370-
using (StreamWriter sw = new StreamWriter(Path.Combine(opts.OutputPath, Helpers.MakeValidFileName(opts.FirstRunId + "_vs_" + opts.SecondRunId + "_summary.json.txt")))) //lgtm[cs/path-injection]
371+
using (StreamWriter sw = new StreamWriter(path)) //lgtm[cs/path-injection]
371372
{
372373
using (JsonWriter writer = new JsonTextWriter(sw))
373374
{
374375
serializer.Serialize(writer, results);
375376
}
376377
}
377-
Log.Information(Strings.Get("DoneWriting"));
378+
Log.Information(Strings.Get("OutputWrittenTo"), path);
378379
return 0;
379380

380381
}
@@ -567,6 +568,7 @@ private static int RunExportMonitorCommand(ExportMonitorCommandOptions opts)
567568
Telemetry.TrackEvent("Begin Export Monitor", StartEvent);
568569

569570
WriteMonitorJson(opts.RunId, (int)RESULT_TYPE.FILE, opts.OutputPath);
571+
570572
return 0;
571573
}
572574

@@ -596,13 +598,17 @@ public static void WriteMonitorJson(string RunId, int ResultType, string OutputP
596598
JsonSerializer serializer = JsonSerializer.Create(settings);
597599
serializer.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
598600

599-
using (StreamWriter sw = new StreamWriter(Path.Combine(OutputPath, Helpers.MakeValidFileName(RunId + "_Monitoring_" + ((RESULT_TYPE)ResultType).ToString() + ".json.txt")))) //lgtm[cs/path-injection]
601+
string path = Path.Combine(OutputPath, Helpers.MakeValidFileName(RunId + "_Monitoring_" + ((RESULT_TYPE)ResultType).ToString() + ".json.txt"));
602+
603+
using (StreamWriter sw = new StreamWriter(path)) //lgtm[cs/path-injection]
600604
{
601605
using (JsonWriter writer = new JsonTextWriter(sw))
602606
{
603607
serializer.Serialize(writer, records);
604608
}
605609
}
610+
Log.Information(Strings.Get("OutputWrittenTo"), path);
611+
606612
}
607613

608614
private static int RunMonitorCommand(MonitorCommandOptions opts)
@@ -1314,6 +1320,7 @@ private static int RunCompareCommand(CompareCommandOptions opts)
13141320

13151321
var result = engine.CompileRenderAsync("Output" + Path.DirectorySeparatorChar + "Output.cshtml", results).Result;
13161322
File.WriteAllText($"{opts.OutputBaseFilename}.html", result);
1323+
Log.Information(Strings.Get("OutputWrittenTo"), opts.OutputBaseFilename + ".html");
13171324

13181325
return 0;
13191326
}

Cli/Properties/Resources.Designer.cs

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cli/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,7 @@
393393
<data name="ExcludingHive" xml:space="preserve">
394394
<value>Excluding Hive</value>
395395
</data>
396+
<data name="OutputWrittenTo" xml:space="preserve">
397+
<value>Output written to: {0}</value>
398+
</data>
396399
</root>

0 commit comments

Comments
 (0)