@@ -894,7 +894,7 @@ public static string checksum(string filename)
894
894
return result ;
895
895
}
896
896
897
- public static void LogEvent ( string content )
897
+ public static void LogEvent ( string content )
898
898
{
899
899
string exeName = Path . GetFileNameWithoutExtension ( System . Reflection . Assembly . GetEntryAssembly ( ) . Location ) ;
900
900
@@ -909,9 +909,22 @@ public static void LogEvent(string content)
909
909
910
910
try
911
911
{
912
+ JObject jsonObject = JsonConvert . DeserializeObject < JObject > ( content ) ;
913
+
914
+ // Redact sensitive fields - Add more if you would like.
915
+ RedactField ( jsonObject , "sessionid" ) ;
916
+ RedactField ( jsonObject , "ownerid" ) ;
917
+ RedactField ( jsonObject , "app" ) ;
918
+ RedactField ( jsonObject , "secret" ) ;
919
+ RedactField ( jsonObject , "version" ) ;
920
+ RedactField ( jsonObject , "fileid" ) ;
921
+ RedactField ( jsonObject , "webhooks" ) ;
922
+ RedactField ( jsonObject , "nonce" ) ;
923
+ string redactedContent = jsonObject . ToString ( Newtonsoft . Json . Formatting . None ) ;
924
+
912
925
using ( StreamWriter writer = File . AppendText ( logFilePath ) )
913
926
{
914
- writer . WriteLine ( $ "[{ DateTime . Now } ] [{ AppDomain . CurrentDomain . FriendlyName } ] { content } ") ;
927
+ writer . WriteLine ( $ "[{ DateTime . Now } ] [{ AppDomain . CurrentDomain . FriendlyName } ] { redactedContent } ") ;
915
928
}
916
929
}
917
930
catch ( Exception ex )
@@ -920,6 +933,15 @@ public static void LogEvent(string content)
920
933
}
921
934
}
922
935
936
+ private static void RedactField ( JObject jsonObject , string fieldName )
937
+ {
938
+ JToken token ;
939
+ if ( jsonObject . TryGetValue ( fieldName , out token ) )
940
+ {
941
+ jsonObject [ fieldName ] = "REDACTED" ;
942
+ }
943
+ }
944
+
923
945
public static void error ( string message )
924
946
{
925
947
string folder = @"Logs" , file = Path . Combine ( folder , "ErrorLogs.txt" ) ;
0 commit comments