public string DirResultLogFromMessage(SnafflerMessage message) { string sharePath = message.DirResult.DirPath; string triage = message.DirResult.Triage.ToString(); return(string.Format(dirResultTemplate, triage, sharePath)); }
public string ShareResultLogFromMessage(SnafflerMessage message) { string sharePath = message.ShareResult.SharePath; string triage = message.ShareResult.Triage.ToString(); string shareResultTemplate = "{{{0}}}({1})"; return(string.Format(shareResultTemplate, triage, sharePath)); }
public string ShareResultLogFromMessage(SnafflerMessage message) { string sharePath = message.ShareResult.SharePath; string triage = message.ShareResult.Triage.ToString(); string shareComment = message.ShareResult.ShareComment; return(string.Format(shareResultTemplate, triage, sharePath, shareComment)); }
private void ProcessMessage(SnafflerMessage message) { // standardized time formatting, UTC string datetime = String.Format("{1}{0}{2:u}{0}", Options.Separator, hostString(), message.DateTime.ToUniversalTime()); switch (message.Type) { case SnafflerMessageType.Trace: Logger.Trace(datetime + "[Trace]" + Options.Separator + message.Message); break; case SnafflerMessageType.Degub: Logger.Debug(datetime + "[Degub]" + Options.Separator + message.Message); break; case SnafflerMessageType.Info: Logger.Info(datetime + "[Info]" + Options.Separator + message.Message); break; case SnafflerMessageType.FileResult: Logger.Warn(datetime + "[File]" + Options.Separator + FileResultLogFromMessage(message)); break; case SnafflerMessageType.DirResult: Logger.Warn(datetime + "[Dir]" + Options.Separator + DirResultLogFromMessage(message)); break; case SnafflerMessageType.ShareResult: Logger.Warn(datetime + "[Share]" + Options.Separator + ShareResultLogFromMessage(message)); break; case SnafflerMessageType.Error: Logger.Error(datetime + "[Error]" + Options.Separator + message.Message); break; case SnafflerMessageType.Fatal: Logger.Fatal(datetime + "[Fatal]" + Options.Separator + message.Message); if (Debugger.IsAttached) { Console.ReadKey(); } Environment.Exit(1); break; case SnafflerMessageType.Finish: Logger.Info("Snaffler out."); if (Debugger.IsAttached) { Console.WriteLine("Press any key to exit."); Console.ReadKey(); } Environment.Exit(0); break; } }
public string FileResultLogFromMessage(SnafflerMessage message) { try { string matchedclassifier = message.FileResult.MatchedRule.RuleName; string triageString = message.FileResult.MatchedRule.Triage.ToString(); DateTime modifiedStamp = message.FileResult.FileInfo.LastWriteTime.ToUniversalTime(); string canread = ""; if (message.FileResult.RwStatus.CanRead) { canread = "R"; } string canwrite = ""; if (message.FileResult.RwStatus.CanWrite) { canwrite = "W"; } string matchedstring = ""; long fileSize = message.FileResult.FileInfo.Length; string fileSizeString; // TSV output will probably be machine-consumed. Don't pretty it up. if (Options.LogTSV) { fileSizeString = fileSize.ToString(); } else { fileSizeString = BytesToString(fileSize); } string filepath = message.FileResult.FileInfo.FullName; string matchcontext = ""; if (message.FileResult.TextResult != null) { matchedstring = message.FileResult.TextResult.MatchedStrings[0]; matchcontext = message.FileResult.TextResult.MatchContext; } return(string.Format(fileResultTemplate, triageString, matchedclassifier, canread, canwrite, matchedstring, fileSizeString, modifiedStamp, filepath, matchcontext)); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.WriteLine(message.FileResult.FileInfo.FullName); return(""); } }
public string ShareResultLogFromMessage(SnafflerMessage message) { var sharePath = message.ShareResult.SharePath; var isadmin = ""; if (message.ShareResult.IsAdminShare) { isadmin = "AdminShare"; } var shareResultTemplate = "<{0}>({1})"; return(string.Format(shareResultTemplate, isadmin, sharePath)); }
private void ProcessMessage(SnafflerMessage message) { string datetime = hostString() + " " + message.DateTime.ToString("yyyy-MM-dd" + Options.Separator + "HH:mm:ss" + Options.Separator + "zzz" + Options.Separator); switch (message.Type) { case SnafflerMessageType.Trace: Logger.Trace(datetime + "[Trace]" + Options.Separator + message.Message); break; case SnafflerMessageType.Degub: Logger.Debug(datetime + "[Degub]" + Options.Separator + message.Message); break; case SnafflerMessageType.Info: Logger.Info(datetime + "[Info]" + Options.Separator + message.Message); break; case SnafflerMessageType.FileResult: Logger.Warn(datetime + "[File]" + Options.Separator + FileResultLogFromMessage(message)); break; case SnafflerMessageType.DirResult: Logger.Warn(datetime + "[Dir]" + Options.Separator + DirResultLogFromMessage(message)); break; case SnafflerMessageType.ShareResult: Logger.Warn(datetime + "[Share]" + Options.Separator + ShareResultLogFromMessage(message)); break; case SnafflerMessageType.Error: Logger.Error(datetime + "[Error]" + Options.Separator + message.Message); break; case SnafflerMessageType.Fatal: Logger.Fatal(datetime + "[Fatal]" + Options.Separator + message.Message); Environment.Exit(1); break; case SnafflerMessageType.Finish: Logger.Info("Snaffler out."); Console.WriteLine("Press any key to exit."); if (Debugger.IsAttached) { Console.ReadKey(); } Environment.Exit(0); break; } }
public string FileResultLogFromMessage(SnafflerMessage message) { try { string matchedclassifier = message.FileResult.MatchedRule.RuleName; //message.FileResult.WhyMatched.ToString(); string triageString = message.FileResult.MatchedRule.Triage.ToString(); string modifiedStamp = message.FileResult.FileInfo.LastWriteTime.ToString(); string canread = ""; if (message.FileResult.RwStatus.CanRead) { canread = "R"; } string canwrite = ""; if (message.FileResult.RwStatus.CanWrite) { canwrite = "W"; } string matchedstring = ""; long fileSize = message.FileResult.FileInfo.Length; string fileSizeString = BytesToString(fileSize); string filepath = message.FileResult.FileInfo.FullName; string matchcontext = ""; if (message.FileResult.TextResult != null) { matchedstring = message.FileResult.TextResult.MatchedStrings[0]; matchcontext = message.FileResult.TextResult.MatchContext; } string fileResultTemplate = " {{{0}}}<{1}|{2}{3}|{4}|{5}|{6}>({7}) {8}"; return(string.Format(fileResultTemplate, triageString, matchedclassifier, canread, canwrite, matchedstring, fileSizeString, modifiedStamp, filepath, matchcontext)); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.WriteLine(message.FileResult.FileInfo.FullName); return(""); } }
public string FileResultLogFromMessage(SnafflerMessage message) { var matchreason = message.FileResult.WhyMatched.ToString(); var canread = ""; if (message.FileResult.RwStatus.CanRead) { canread = "R"; } var canwrite = ""; if (message.FileResult.RwStatus.CanWrite) { canwrite = "W"; } var matchedstring = ""; var fileSize = message.FileResult.FileInfo.Length; var fileSizeString = BytesToString(fileSize); var filepath = message.FileResult.FileInfo.FullName; var grepcontext = ""; if (message.FileResult.GrepFileResult != null) { matchedstring = message.FileResult.GrepFileResult.GreppedStrings[0]; grepcontext = message.FileResult.GrepFileResult.GrepContext; } var fileResultTemplate = "<{0}|{1}{2}|{3}|{4}>({5}) {6}"; return(string.Format(fileResultTemplate, matchreason, canread, canwrite, matchedstring, fileSizeString, filepath, grepcontext)); }
public string ShareResultLogFromMessage(SnafflerMessage message) { string sharePath = message.ShareResult.SharePath; string triage = message.ShareResult.Triage.ToString(); string shareComment = message.ShareResult.ShareComment; string rwString = ""; if (message.ShareResult.RootReadable) { rwString = rwString + "R"; } if (message.ShareResult.RootWritable) { rwString = rwString + "W"; } if (message.ShareResult.RootModifyable) { rwString = rwString + "M"; } return(string.Format(shareResultTemplate, triage, sharePath, rwString, shareComment)); }
private void ProcessMessage(SnafflerMessage message) { var datetime = message.DateTime.ToString("yyyy-MM-dd HH:mm:ss zzz "); switch (message.Type) { case SnafflerMessageType.Trace: Logger.Trace(datetime + "[Trace] " + message.Message); break; case SnafflerMessageType.Degub: Logger.Debug(datetime + "[Degub] " + message.Message); break; case SnafflerMessageType.Info: Logger.Info(datetime + "[Info] " + message.Message); break; case SnafflerMessageType.FileResult: Logger.Warn(datetime + "[File]" + FileResultLogFromMessage(message)); break; case SnafflerMessageType.ShareResult: Logger.Warn(datetime + "[Share]" + ShareResultLogFromMessage(message)); break; case SnafflerMessageType.Error: Logger.Error(datetime + "[Error] " + message.Message); break; case SnafflerMessageType.Fatal: Logger.Fatal(datetime + "[Fatal] " + message.Message); Environment.Exit(1); break; } }