diff --git a/Cli/Program.cs b/Cli/Program.cs index 7589cd6b5..5beb80153 100644 --- a/Cli/Program.cs +++ b/Cli/Program.cs @@ -197,7 +197,11 @@ public static class AttackSurfaceAnalyzerCLI static void Main(string[] args) { - Logger.Setup(); +#if DEBUG + Logger.Setup(true,false); +#else + Logger.Setup(false,false); +#endif Strings.Setup(); string version = (Assembly @@ -252,21 +256,41 @@ private static int RunConfigCommand(ConfigCommandOptions opts) { while (reader.Read()) { - string output = String.Format("{0} {1} {2} {3}", - reader["timestamp"].ToString(), - reader["version"].ToString(), - reader["type"].ToString(), - reader["run_id"].ToString()); - Log.Information(output); - output = String.Format("{0} {1} {2} {3} {4} {5}", - (int.Parse(reader["file_system"].ToString()) != 0) ? "FILES" : "", - (int.Parse(reader["ports"].ToString()) != 0) ? "PORTS" : "", - (int.Parse(reader["users"].ToString()) != 0) ? "USERS" : "", - (int.Parse(reader["services"].ToString()) != 0) ? "SERVICES" : "", - (int.Parse(reader["certificates"].ToString()) != 0) ? "CERTIFICATES" : "", - (int.Parse(reader["registry"].ToString()) != 0) ? "REGISTRY" : ""); - Log.Information(output); - + Log.Information("RunId:{2} Timestamp:{0} AsaVersion:{1} ", + reader["timestamp"], + reader["version"], + reader["run_id"]); + List resultTypes = new List(); + if (int.Parse(reader["file_system"].ToString()) != 0) + { + resultTypes.Add(RESULT_TYPE.FILE); + } + if (int.Parse(reader["ports"].ToString()) != 0) + { + resultTypes.Add(RESULT_TYPE.PORT); + } + if (int.Parse(reader["users"].ToString()) != 0) + { + resultTypes.Add(RESULT_TYPE.USER); + } + if (int.Parse(reader["services"].ToString()) != 0) + { + resultTypes.Add(RESULT_TYPE.SERVICES); + } + if (int.Parse(reader["certificates"].ToString()) != 0) + { + resultTypes.Add(RESULT_TYPE.CERTIFICATE); + } + if (int.Parse(reader["registry"].ToString()) != 0) + { + resultTypes.Add(RESULT_TYPE.REGISTRY); + } + + foreach (RESULT_TYPE type in resultTypes) + { + int num = DatabaseManager.GetNumResults(type, reader["run_id"].ToString()); + Log.Information("{0} : {1}", type, num); + } } } } @@ -415,33 +439,37 @@ public static void WriteScanJson(int ResultType, string BaseId, string CompareId string BaseString = ""; CHANGE_TYPE ChangeType = (CHANGE_TYPE)int.Parse(reader["change_type"].ToString()); - if (ChangeType == CHANGE_TYPE.CREATED || ChangeType == CHANGE_TYPE.MODIFIED) + using (var inner_cmd = new SqliteCommand(GET_SERIALIZED_RESULTS.Replace("@table_name", Helpers.ResultTypeToTableName(ExportType)), DatabaseManager.Connection)) { - var inner_cmd = new SqliteCommand(GET_SERIALIZED_RESULTS.Replace("@table_name", Helpers.ResultTypeToTableName(ExportType)), DatabaseManager.Connection); - inner_cmd.Parameters.AddWithValue("@run_id", reader["compare_run_id"].ToString()); - inner_cmd.Parameters.AddWithValue("@row_key", reader["compare_row_key"].ToString()); - using (var inner_reader = inner_cmd.ExecuteReader()) + if (ChangeType == CHANGE_TYPE.CREATED || ChangeType == CHANGE_TYPE.MODIFIED) { - while (inner_reader.Read()) + inner_cmd.Parameters.Clear(); + inner_cmd.Parameters.AddWithValue("@run_id", reader["compare_run_id"].ToString()); + inner_cmd.Parameters.AddWithValue("@row_key", reader["compare_row_key"].ToString()); + using (var inner_reader = inner_cmd.ExecuteReader()) { - CompareString = inner_reader["serialized"].ToString(); + while (inner_reader.Read()) + { + CompareString = inner_reader["serialized"].ToString(); + } } } - } - if (ChangeType == CHANGE_TYPE.DELETED || ChangeType == CHANGE_TYPE.MODIFIED) - { - var inner_cmd = new SqliteCommand(GET_SERIALIZED_RESULTS.Replace("@table_name", Helpers.ResultTypeToTableName(ExportType)), DatabaseManager.Connection); - inner_cmd.Parameters.AddWithValue("@run_id", reader["base_run_id"].ToString()); - inner_cmd.Parameters.AddWithValue("@row_key", reader["base_row_key"].ToString()); - using (var inner_reader = inner_cmd.ExecuteReader()) + if (ChangeType == CHANGE_TYPE.DELETED || ChangeType == CHANGE_TYPE.MODIFIED) { - while (inner_reader.Read()) + inner_cmd.Parameters.Clear(); + inner_cmd.Parameters.AddWithValue("@run_id", reader["base_run_id"].ToString()); + inner_cmd.Parameters.AddWithValue("@row_key", reader["base_row_key"].ToString()); + using (var inner_reader = inner_cmd.ExecuteReader()) { - BaseString = inner_reader["serialized"].ToString(); + while (inner_reader.Read()) + { + BaseString = inner_reader["serialized"].ToString(); + } } } } + CompareResult obj; switch (ExportType) { diff --git a/Cli/Properties/Resources.Designer.cs b/Cli/Properties/Resources.Designer.cs index 3ef86ca48..ca4b3ac8a 100644 --- a/Cli/Properties/Resources.Designer.cs +++ b/Cli/Properties/Resources.Designer.cs @@ -10,48 +10,35 @@ namespace AttackSurfaceAnalyzer.Properties { using System; + using System.Reflection; - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { - private static global::System.Resources.ResourceManager resourceMan; + private static System.Resources.ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static System.Globalization.CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Resources.ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AttackSurfaceAnalyzer.Properties.Resources", typeof(Resources).Assembly); + if (object.Equals(null, resourceMan)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("AttackSurfaceAnalyzer.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + public static System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -60,840 +47,561 @@ public class Resources { } } - /// - /// Looks up a localized string similar to Account Type. - /// - public static string AccountType { - get { - return ResourceManager.GetString("AccountType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Address. - /// - public static string Address { - get { - return ResourceManager.GetString("Address", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Analyze Results. - /// - public static string AnalyzeResults { + public static string Begin { get { - return ResourceManager.GetString("AnalyzeResults", resourceCulture); + return ResourceManager.GetString("Begin", resourceCulture); } } - /// - /// Looks up a localized string similar to Base Run Id. - /// - public static string BaseRunId { + public static string Comparing { get { - return ResourceManager.GetString("BaseRunId", resourceCulture); + return ResourceManager.GetString("Comparing", resourceCulture); } } - /// - /// Looks up a localized string similar to Status messages appear here after starting analysis.. - /// - public static string BaseStatus { + public static string Completed { get { - return ResourceManager.GetString("BaseStatus", resourceCulture); + return ResourceManager.GetString("Completed", resourceCulture); } } - /// - /// Looks up a localized string similar to Begin. - /// - public static string Begin { + public static string DeletedDatabase { get { - return ResourceManager.GetString("Begin", resourceCulture); + return ResourceManager.GetString("DeletedDatabase", resourceCulture); } } - /// - /// Looks up a localized string similar to Certificates. - /// - public static string Certificates { + public static string DoneWriting { get { - return ResourceManager.GetString("Certificates", resourceCulture); + return ResourceManager.GetString("DoneWriting", resourceCulture); } } - /// - /// Looks up a localized string similar to Change Type. - /// - public static string ChangeType { + public static string End { get { - return ResourceManager.GetString("ChangeType", resourceCulture); + return ResourceManager.GetString("End", resourceCulture); } } - /// - /// Looks up a localized string similar to Choose Collectors. - /// - public static string ChooseCollectors { + public static string EnumeratingCollectRunIds { get { - return ResourceManager.GetString("ChooseCollectors", resourceCulture); + return ResourceManager.GetString("EnumeratingCollectRunIds", resourceCulture); } } - /// - /// Looks up a localized string similar to Choose a monitor run to evaluate.. - /// - public static string ChooseMonitor { + public static string EnumeratingMonitorRunIds { get { - return ResourceManager.GetString("ChooseMonitor", resourceCulture); + return ResourceManager.GetString("EnumeratingMonitorRunIds", resourceCulture); } } - /// - /// Looks up a localized string similar to Collectors. - /// - public static string Collectors { + public static string Err_CollectingFrom { get { - return ResourceManager.GetString("Collectors", resourceCulture); + return ResourceManager.GetString("Err_CollectingFrom", resourceCulture); } } - /// - /// Looks up a localized string similar to Collect snapshot data about the current state of the system and monitor for changes.. - /// - public static string CollectSnapshotDesc { + public static string Err_CouldntDetermineOneRun { get { - return ResourceManager.GetString("CollectSnapshotDesc", resourceCulture); + return ResourceManager.GetString("Err_CouldntDetermineOneRun", resourceCulture); } } - /// - /// Looks up a localized string similar to Compare a base scan and a product scan to determine changes made to the system.. - /// - public static string CompareDesc { + public static string Err_CouldntDetermineTwoRun { get { - return ResourceManager.GetString("CompareDesc", resourceCulture); + return ResourceManager.GetString("Err_CouldntDetermineTwoRun", resourceCulture); } } - /// - /// Looks up a localized string similar to Product Run Id. - /// - public static string CompareRunId { + public static string Err_NoMonitors { get { - return ResourceManager.GetString("CompareRunId", resourceCulture); + return ResourceManager.GetString("Err_NoMonitors", resourceCulture); } } - /// - /// Looks up a localized string similar to Comparing. - /// - public static string Comparing { + public static string Err_RunIdAlreadyUsed { get { - return ResourceManager.GetString("Comparing", resourceCulture); + return ResourceManager.GetString("Err_RunIdAlreadyUsed", resourceCulture); } } - /// - /// Looks up a localized string similar to Completed. - /// - public static string Completed { + public static string Exporting { get { - return ResourceManager.GetString("Completed", resourceCulture); + return ResourceManager.GetString("Exporting", resourceCulture); } } - /// - /// Looks up a localized string similar to Contents. - /// - public static string Contents { + public static string InvalidPath { get { - return ResourceManager.GetString("Contents", resourceCulture); + return ResourceManager.GetString("InvalidPath", resourceCulture); } } - /// - /// Looks up a localized string similar to Created. - /// - public static string Created { + public static string MonitoringPressC { get { - return ResourceManager.GetString("Created", resourceCulture); + return ResourceManager.GetString("MonitoringPressC", resourceCulture); } } - /// - /// Looks up a localized string similar to Current State. - /// - public static string CurrentState { + public static string MonitorStartedFor { get { - return ResourceManager.GetString("CurrentState", resourceCulture); + return ResourceManager.GetString("MonitorStartedFor", resourceCulture); } } - /// - /// Looks up a localized string similar to Deleted. - /// - public static string Deleted { + public static string TelemetryOptOut { get { - return ResourceManager.GetString("Deleted", resourceCulture); + return ResourceManager.GetString("TelemetryOptOut", resourceCulture); } } - /// - /// Looks up a localized string similar to Successfully deleted database.. - /// - public static string DeletedDatabase { + public static string WelcomeHeader { get { - return ResourceManager.GetString("DeletedDatabase", resourceCulture); + return ResourceManager.GetString("WelcomeHeader", resourceCulture); } } - /// - /// Looks up a localized string similar to Description. - /// - public static string Description { + public static string AccountType { get { - return ResourceManager.GetString("Description", resourceCulture); + return ResourceManager.GetString("AccountType", resourceCulture); } } - /// - /// Looks up a localized string similar to DIsplay Name. - /// - public static string DisplayName { + public static string Address { get { - return ResourceManager.GetString("DisplayName", resourceCulture); + return ResourceManager.GetString("Address", resourceCulture); } } - /// - /// Looks up a localized string similar to Done writing!. - /// - public static string DoneWriting { + public static string AnalyzeResults { get { - return ResourceManager.GetString("DoneWriting", resourceCulture); + return ResourceManager.GetString("AnalyzeResults", resourceCulture); } } - /// - /// Looks up a localized string similar to Due To Filter. - /// - public static string DueToFilter { + public static string BaseRunId { get { - return ResourceManager.GetString("DueToFilter", resourceCulture); + return ResourceManager.GetString("BaseRunId", resourceCulture); } } - /// - /// Looks up a localized string similar to End. - /// - public static string End { + public static string BaseStatus { get { - return ResourceManager.GetString("End", resourceCulture); + return ResourceManager.GetString("BaseStatus", resourceCulture); } } - /// - /// Looks up a localized string similar to Enumerating Collect Run Ids. - /// - public static string EnumeratingCollectRunIds { + public static string Certificates { get { - return ResourceManager.GetString("EnumeratingCollectRunIds", resourceCulture); + return ResourceManager.GetString("Certificates", resourceCulture); } } - /// - /// Looks up a localized string similar to Enumerating Monitor Run Ids. - /// - public static string EnumeratingMonitorRunIds { + public static string ChangeType { get { - return ResourceManager.GetString("EnumeratingMonitorRunIds", resourceCulture); + return ResourceManager.GetString("ChangeType", resourceCulture); } } - /// - /// Looks up a localized string similar to Could not get file permissions. - /// - public static string Err_AccessControl { + public static string ChooseCollectors { get { - return ResourceManager.GetString("Err_AccessControl", resourceCulture); + return ResourceManager.GetString("ChooseCollectors", resourceCulture); } } - /// - /// Looks up a localized string similar to Error collecting from. - /// - public static string Err_CollectingFrom { + public static string ChooseMonitor { get { - return ResourceManager.GetString("Err_CollectingFrom", resourceCulture); + return ResourceManager.GetString("ChooseMonitor", resourceCulture); } } - /// - /// Looks up a localized string similar to Couldn't determine latest run id. Can't continue.. - /// - public static string Err_CouldntDetermineOneRun { + public static string CollectSnapshotDesc { get { - return ResourceManager.GetString("Err_CouldntDetermineOneRun", resourceCulture); + return ResourceManager.GetString("CollectSnapshotDesc", resourceCulture); } } - /// - /// Looks up a localized string similar to Couldn't determine latest two run ids. Can't continue.. - /// - public static string Err_CouldntDetermineTwoRun { + public static string CompareDesc { get { - return ResourceManager.GetString("Err_CouldntDetermineTwoRun", resourceCulture); + return ResourceManager.GetString("CompareDesc", resourceCulture); } } - /// - /// Looks up a localized string similar to Json error parsing your filters.json file.. - /// - public static string Err_FiltersFile { + public static string CompareRunId { get { - return ResourceManager.GetString("Err_FiltersFile", resourceCulture); + return ResourceManager.GetString("CompareRunId", resourceCulture); } } - /// - /// Looks up a localized string similar to You must collect some results before performing analysis.. - /// - public static string Err_NeedResults { + public static string Contents { get { - return ResourceManager.GetString("Err_NeedResults", resourceCulture); + return ResourceManager.GetString("Contents", resourceCulture); } } - /// - /// Looks up a localized string similar to No collectors have been defined.. - /// - public static string Err_NoCollectors { + public static string CurrentState { get { - return ResourceManager.GetString("Err_NoCollectors", resourceCulture); + return ResourceManager.GetString("CurrentState", resourceCulture); } } - /// - /// Looks up a localized string similar to No monitors have been defined.. - /// - public static string Err_NoMonitors { + public static string Description { get { - return ResourceManager.GetString("Err_NoMonitors", resourceCulture); + return ResourceManager.GetString("Description", resourceCulture); } } - /// - /// Looks up a localized string similar to That runid was already used. Must use a unique runid for each run. Use --overwrite to discard previous run information.. - /// - public static string Err_RunIdAlreadyUsed { + public static string DisplayName { get { - return ResourceManager.GetString("Err_RunIdAlreadyUsed", resourceCulture); + return ResourceManager.GetString("DisplayName", resourceCulture); } } - /// - /// Looks up a localized string similar to Excluding Hive. - /// - public static string ExcludingHive { + public static string Err_NeedResults { get { - return ResourceManager.GetString("ExcludingHive", resourceCulture); + return ResourceManager.GetString("Err_NeedResults", resourceCulture); } } - /// - /// Looks up a localized string similar to Export all available result types. - /// public static string ExportAll { get { return ResourceManager.GetString("ExportAll", resourceCulture); } } - /// - /// Looks up a localized string similar to Output Directory For Export. - /// public static string ExportDirectory { get { return ResourceManager.GetString("ExportDirectory", resourceCulture); } } - /// - /// Looks up a localized string similar to Exporting. - /// - public static string Exporting { - get { - return ResourceManager.GetString("Exporting", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Export only the selected result type. - /// public static string ExportOnly { get { return ResourceManager.GetString("ExportOnly", resourceCulture); } } - /// - /// Looks up a localized string similar to Export Options. - /// public static string ExportOptions { get { return ResourceManager.GetString("ExportOptions", resourceCulture); } } - /// - /// Looks up a localized string similar to Could not parse. - /// - public static string FailedParsed { - get { - return ResourceManager.GetString("FailedParsed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Files. - /// public static string Files { get { return ResourceManager.GetString("Files", resourceCulture); } } - /// - /// Looks up a localized string similar to The first, pre-installation scan should be run on a clean system without the software under test installed.. - /// public static string FirstScanDesc { get { return ResourceManager.GetString("FirstScanDesc", resourceCulture); } } - /// - /// Looks up a localized string similar to Found. - /// - public static string Found { - get { - return ResourceManager.GetString("Found", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Hash. - /// public static string Hash { get { return ResourceManager.GetString("Hash", resourceCulture); } } - /// - /// Looks up a localized string similar to The path supplied was invalid.. - /// - public static string InvalidPath { - get { - return ResourceManager.GetString("InvalidPath", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Live Monitoring. - /// public static string LiveMonitoring { get { return ResourceManager.GetString("LiveMonitoring", resourceCulture); } } - /// - /// Looks up a localized string similar to This will monitor your system for changes as they happen.. - /// public static string LiveMonitoringDesc { get { return ResourceManager.GetString("LiveMonitoringDesc", resourceCulture); } } - /// - /// Looks up a localized string similar to Loaded filters:. - /// - public static string LoadedFilters { - get { - return ResourceManager.GetString("LoadedFilters", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Modified. - /// - public static string Modified { - get { - return ResourceManager.GetString("Modified", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Monitoring, press CTRL+C to stop.... - /// - public static string MonitoringPressC { - get { - return ResourceManager.GetString("MonitoringPressC", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Monitor started for. - /// - public static string MonitorStartedFor { - get { - return ResourceManager.GetString("MonitorStartedFor", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to For more information, please visit our. - /// public static string MoreInfo1 { get { return ResourceManager.GetString("MoreInfo1", resourceCulture); } } - /// - /// Looks up a localized string similar to page to review the ASA user guide, documentation and source code.. - /// public static string MoreInfo2 { get { return ResourceManager.GetString("MoreInfo2", resourceCulture); } } - /// - /// Looks up a localized string similar to Name. - /// public static string Name { get { return ResourceManager.GetString("Name", resourceCulture); } } - /// - /// Looks up a localized string similar to Old Name. - /// public static string OldName { get { return ResourceManager.GetString("OldName", resourceCulture); } } - /// - /// Looks up a localized string similar to Old Path. - /// public static string OldPath { get { return ResourceManager.GetString("OldPath", resourceCulture); } } - /// - /// Looks up a localized string similar to Output Directory For Export. - /// - public static string OutputDirectory { - get { - return ResourceManager.GetString("OutputDirectory", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Output written to: {0}. - /// - public static string OutputWrittenTo { - get { - return ResourceManager.GetString("OutputWrittenTo", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Path. - /// public static string Path { get { return ResourceManager.GetString("Path", resourceCulture); } } - /// - /// Looks up a localized string similar to Permissions. - /// public static string Permissions { get { return ResourceManager.GetString("Permissions", resourceCulture); } } - /// - /// Looks up a localized string similar to Ports. - /// public static string Ports { get { return ResourceManager.GetString("Ports", resourceCulture); } } - /// - /// Looks up a localized string similar to Ready to scan.. - /// public static string ReadyToScan { get { return ResourceManager.GetString("ReadyToScan", resourceCulture); } } - /// - /// Looks up a localized string similar to Registry. - /// public static string Registry { get { return ResourceManager.GetString("Registry", resourceCulture); } } - /// - /// Looks up a localized string similar to Compare, view, and export Scan and Monitor results.. - /// public static string ResultsDesc { get { return ResourceManager.GetString("ResultsDesc", resourceCulture); } } - /// - /// Looks up a localized string similar to Run started.. - /// - public static string RunStarted { - get { - return ResourceManager.GetString("RunStarted", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Run Status. - /// public static string RunStatus { get { return ResourceManager.GetString("RunStatus", resourceCulture); } } - /// - /// Looks up a localized string similar to Run Id. - /// public static string ScanId { get { return ResourceManager.GetString("ScanId", resourceCulture); } } - /// - /// Looks up a localized string similar to Scanning. - /// - public static string Scanning { - get { - return ResourceManager.GetString("Scanning", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Scan Type. - /// public static string ScanType { get { return ResourceManager.GetString("ScanType", resourceCulture); } } - /// - /// Looks up a localized string similar to The second, post-installation scan should be run after installing the software onto the system.. - /// public static string SecondScanDesc { get { return ResourceManager.GetString("SecondScanDesc", resourceCulture); } } - /// - /// Looks up a localized string similar to Select a type of result to view.. - /// public static string SelectResultType { get { return ResourceManager.GetString("SelectResultType", resourceCulture); } } - /// - /// Looks up a localized string similar to Service Name. - /// public static string ServiceName { get { return ResourceManager.GetString("ServiceName", resourceCulture); } } - /// - /// Looks up a localized string similar to Services. - /// public static string Services { get { return ResourceManager.GetString("Services", resourceCulture); } } - /// - /// Looks up a localized string similar to Size. - /// public static string Size { get { return ResourceManager.GetString("Size", resourceCulture); } } - /// - /// Looks up a localized string similar to Starting. - /// - public static string Starting { - get { - return ResourceManager.GetString("Starting", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Start Type. - /// public static string StartType { get { return ResourceManager.GetString("StartType", resourceCulture); } } - /// - /// Looks up a localized string similar to Static Scan. - /// public static string StaticScan { get { return ResourceManager.GetString("StaticScan", resourceCulture); } } - /// - /// Looks up a localized string similar to This will scan your system to gather a snapshot of the chosen parameters. To determine the changes made by the installation of a specific piece of software the system must be scanned at least twice.. - /// public static string StaticScanDesc { get { return ResourceManager.GetString("StaticScanDesc", resourceCulture); } } - /// - /// Looks up a localized string similar to Store Location. - /// public static string StoreLocation { get { return ResourceManager.GetString("StoreLocation", resourceCulture); } } - /// - /// Looks up a localized string similar to Store Name. - /// public static string StoreName { get { return ResourceManager.GetString("StoreName", resourceCulture); } } - /// - /// Looks up a localized string similar to Subject. - /// - public static string Subject { - get { - return ResourceManager.GetString("Subject", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Successfully Parsed. - /// - public static string SuccessParsed { + public static string OutputDirectory { get { - return ResourceManager.GetString("SuccessParsed", resourceCulture); + return ResourceManager.GetString("OutputDirectory", resourceCulture); } } - /// - /// Looks up a localized string similar to Your telemetry opt out setting is now. - /// - public static string TelemetryOptOut { + public static string Subject { get { - return ResourceManager.GetString("TelemetryOptOut", resourceCulture); + return ResourceManager.GetString("Subject", resourceCulture); } } - /// - /// Looks up a localized string similar to Type. - /// public static string Type { get { return ResourceManager.GetString("Type", resourceCulture); } } - /// - /// Looks up a localized string similar to Send usage data to Microsoft to help us improve our products.. - /// public static string UsageData { get { return ResourceManager.GetString("UsageData", resourceCulture); } } - /// - /// Looks up a localized string similar to Users. - /// public static string Users { get { return ResourceManager.GetString("Users", resourceCulture); } } - /// - /// Looks up a localized string similar to Value. - /// public static string Value { get { return ResourceManager.GetString("Value", resourceCulture); } } - /// - /// Looks up a localized string similar to Attack Surface Analyzer catalogues the changes made to an operating system attack surface by the installation of new software. ASA can be used to take a snapshot of your system state before and after the installation of product(s) and displays the changes made to a number of key elements of the system attack surface allowing you to see what attack surfaces may be exposed after installation of the target product(s). ASA was developed by Microsoft.. - /// public static string WelcomeBody { get { return ResourceManager.GetString("WelcomeBody", resourceCulture); } } - /// - /// Looks up a localized string similar to Welcome to Attack Surface Analyzer. - /// - public static string WelcomeHeader { + public static string RunStarted { get { - return ResourceManager.GetString("WelcomeHeader", resourceCulture); + return ResourceManager.GetString("RunStarted", resourceCulture); + } + } + + public static string Created { + get { + return ResourceManager.GetString("Created", resourceCulture); + } + } + + public static string Deleted { + get { + return ResourceManager.GetString("Deleted", resourceCulture); + } + } + + public static string Err_NoCollectors { + get { + return ResourceManager.GetString("Err_NoCollectors", resourceCulture); + } + } + + public static string Found { + get { + return ResourceManager.GetString("Found", resourceCulture); + } + } + + public static string Collectors { + get { + return ResourceManager.GetString("Collectors", resourceCulture); + } + } + + public static string Err_AccessControl { + get { + return ResourceManager.GetString("Err_AccessControl", resourceCulture); + } + } + + public static string Err_FiltersFile { + get { + return ResourceManager.GetString("Err_FiltersFile", resourceCulture); + } + } + + public static string FailedParsed { + get { + return ResourceManager.GetString("FailedParsed", resourceCulture); + } + } + + public static string LoadedFilters { + get { + return ResourceManager.GetString("LoadedFilters", resourceCulture); + } + } + + public static string Modified { + get { + return ResourceManager.GetString("Modified", resourceCulture); + } + } + + public static string Scanning { + get { + return ResourceManager.GetString("Scanning", resourceCulture); + } + } + + public static string Starting { + get { + return ResourceManager.GetString("Starting", resourceCulture); + } + } + + public static string SuccessParsed { + get { + return ResourceManager.GetString("SuccessParsed", resourceCulture); + } + } + + public static string DueToFilter { + get { + return ResourceManager.GetString("DueToFilter", resourceCulture); + } + } + + public static string ExcludingHive { + get { + return ResourceManager.GetString("ExcludingHive", resourceCulture); + } + } + + public static string OutputWrittenTo { + get { + return ResourceManager.GetString("OutputWrittenTo", resourceCulture); } } } diff --git a/Lib/Utils/DatabaseManager.cs b/Lib/Utils/DatabaseManager.cs index dbfa4d2e2..21526ca1d 100644 --- a/Lib/Utils/DatabaseManager.cs +++ b/Lib/Utils/DatabaseManager.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; using System.Collections.Generic; +using AttackSurfaceAnalyzer.ObjectTypes; using Microsoft.Data.Sqlite; using Serilog; @@ -55,6 +56,7 @@ public static class DatabaseManager private static readonly string SQL_SELECT_LATEST_N_RUNS = "select run_id from runs where type = @type order by timestamp desc limit 0,@limit;"; private static readonly string SQL_GET_SCHEMA_VERSION = "select value from persisted_settings where setting = 'schema_version' limit 0,1"; + private static readonly string SQL_GET_NUM_RESULTS = "select count(*) as the_count from @table_name where run_id = @run_id"; private static readonly string SCHEMA_VERSION = "1"; @@ -183,6 +185,32 @@ public static List GetLatestRunIds(int numberOfIds, string type) return output; } + public static int GetNumResults(RESULT_TYPE ResultType, string runId) + { + try + { + using (var cmd = new SqliteCommand(SQL_GET_NUM_RESULTS.Replace("@table_name", Helpers.ResultTypeToTableName(ResultType)), DatabaseManager.Connection, DatabaseManager.Transaction)) + { + cmd.Parameters.AddWithValue("@run_id", runId); + + using (var reader = cmd.ExecuteReader()) + { + + while (reader.Read()) + { + return int.Parse(reader["the_count"].ToString()); + } + } + } + } + catch(Exception e) + { + Log.Debug(e.GetType().ToString()); + Log.Debug(e.Message); + } + return -1; + } + public static SqliteTransaction Transaction { @@ -211,7 +239,6 @@ public static void Commit() } _transaction = null; - } private static string _SqliteFilename = "asa.sqlite";