Skip to content

Commit

Permalink
Fix Roslyn Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gfs committed Mar 11, 2020
1 parent e966096 commit 4ba21a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
7 changes: 3 additions & 4 deletions Lib/Objects/ResultObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ namespace AttackSurfaceAnalyzer.Objects
public class RawCollectResult
{
public RESULT_TYPE ResultType { get; set; }
public byte[] RowKey { get; set; }
public string RowKey { get; set; }
public string RunId { get; set; }
public string Identity { get; set; }
public byte[] Serialized { get; set; }
public CollectObject DeserializedObject { get; set; }
}

Expand All @@ -42,8 +41,8 @@ public class CompareResult
public ANALYSIS_RESULT_TYPE Analysis { get; set; }
public List<Rule> Rules { get; set; }
public List<Diff> Diffs { get; set; }
public byte[] BaseRowKey { get; set; }
public byte[] CompareRowKey { get; set; }
public string BaseRowKey { get; set; }
public string CompareRowKey { get; set; }
public string BaseRunId { get; set; }
public string CompareRunId { get; set; }
public object Base { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion Lib/Objects/UserAccountObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
using AttackSurfaceAnalyzer.Types;
using System.Collections.Generic;
using System.Globalization;

namespace AttackSurfaceAnalyzer.Objects
{
Expand Down Expand Up @@ -44,7 +45,7 @@ public override string Identity
{
get
{
return string.Format("{0}{1}","User: ",(Domain == null) ? Name : $"{Domain}\\{Name}");
return string.Format(CultureInfo.InvariantCulture,"{0}{1}","User: ",(Domain == null) ? Name : $"{Domain}\\{Name}");
}
}
}
Expand Down
1 change: 0 additions & 1 deletion Lib/Utils/CryptoHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public static string CreateHash(FileStream stream)
}

const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const int length = 64;

private readonly static RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();

Expand Down
17 changes: 5 additions & 12 deletions Lib/Utils/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ public static class DatabaseManager

private const string SQL_GET_RUN = "select * from runs where run_id = @run_id";

private const string SQL_TRUNCATE_FILES_MONITORED = "delete from file_system_monitored where run_id=@run_id";
private const string SQL_TRUNCATE_RUN = "delete from runs where run_id=@run_id";

private const string SQL_TRUNCATE_RESULTS = "delete from results where base_run_id=@run_id or compare_run_id=@run_id";

private const string SQL_SELECT_LATEST_N_RUNS = "select run_id from runs where type = @type order by timestamp desc limit 0,@limit;";

private const string SQL_GET_NUM_RESULTS = "select count(*) as the_count from collect where run_id = @run_id and result_type = @result_type";
Expand Down Expand Up @@ -384,8 +381,7 @@ public static List<RawCollectResult> GetResultsByRunid(string runid)
Identity = reader["identity"].ToString(),
RunId = reader["run_id"].ToString(),
ResultType = (RESULT_TYPE)Enum.Parse(typeof(RESULT_TYPE), reader["result_type"].ToString()),
RowKey = (byte[])reader["row_key"],
Serialized = (byte[])reader["serialized"]
RowKey = Convert.ToBase64String((byte[])reader["row_key"]),
});
}
}
Expand Down Expand Up @@ -640,8 +636,7 @@ public static List<RawCollectResult> GetMissingFromFirst(string firstRunId, stri
Identity = reader["identity"].ToString(),
RunId = reader["run_id"].ToString(),
ResultType = (RESULT_TYPE)Enum.Parse(typeof(RESULT_TYPE), reader["result_type"].ToString()),
RowKey = (byte[])reader["row_key"],
Serialized = (byte[])reader["serialized"],
RowKey = Convert.ToBase64String((byte[])reader["row_key"]),
DeserializedObject = JsonUtils.Hydrate((byte[])reader["serialized"],(RESULT_TYPE)Enum.Parse(typeof(RESULT_TYPE), reader["result_type"].ToString()))
});
}
Expand Down Expand Up @@ -671,17 +666,15 @@ public static List<RawModifiedResult> GetModified(string firstRunId, string seco
Identity = reader["a_identity"].ToString(),
RunId = reader["a_run_id"].ToString(),
ResultType = (RESULT_TYPE)Enum.Parse(typeof(RESULT_TYPE), reader["a_result_type"].ToString()),
RowKey = (byte[])reader["a_row_key"],
Serialized = (byte[])reader["a_serialized"],
RowKey = Convert.ToBase64String((byte[])reader["a_row_key"]),
DeserializedObject = JsonUtils.Hydrate((byte[])reader["a_serialized"], (RESULT_TYPE)Enum.Parse(typeof(RESULT_TYPE), reader["a_result_type"].ToString()))
},
Second = new RawCollectResult()
{
Identity = reader["b_identity"].ToString(),
RunId = reader["b_run_id"].ToString(),
ResultType = (RESULT_TYPE)Enum.Parse(typeof(RESULT_TYPE), reader["b_result_type"].ToString()),
RowKey = (byte[])reader["b_row_key"],
Serialized = (byte[])reader["b_serialized"],
RowKey = Convert.ToBase64String((byte[])reader["b_row_key"]),
DeserializedObject = JsonUtils.Hydrate((byte[])reader["b_serialized"], (RESULT_TYPE)Enum.Parse(typeof(RESULT_TYPE), reader["b_result_type"].ToString()))
}
}
Expand Down Expand Up @@ -855,7 +848,7 @@ public static void RollBack()
{
cxn.Transaction.Rollback();
}
catch (NullReferenceException e)
catch (NullReferenceException)
{ }
finally
{
Expand Down

0 comments on commit 4ba21a7

Please sign in to comment.