Ver Fonte

Bug 1475: Mask out password in .NET assembly output log

https://winscp.net/tracker/1475

Source commit: f70363c489d8acb04445b63c863b5ad27d44363d
Martin Prikryl há 9 anos atrás
pai
commit
11903086f8

+ 1 - 1
dotnet/Session.cs

@@ -1349,7 +1349,7 @@ namespace WinSCP
         private void WriteCommand(string command, string log)
         {
             Logger.WriteLine("Command: [{0}]", log);
-            _process.ExecuteCommand(command);
+            _process.ExecuteCommand(command, log);
             GotOutput();
         }
 

+ 7 - 4
dotnet/internal/ExeSessionProcess.cs

@@ -365,7 +365,8 @@ namespace WinSCP
                             e.Str = _input[0];
                             e.Result = true;
                             _input.RemoveAt(0);
-                            Print(false, false, e.Str + "\n");
+                            Print(false, false, _log[0] + "\n");
+                            _log.RemoveAt(0);
                             return;
                         }
                     }
@@ -653,7 +654,7 @@ namespace WinSCP
             }
         }
 
-        private void AddInput(string str)
+        private void AddInput(string str, string log)
         {
             Type structType = typeof(ConsoleInputEventStruct);
             FieldInfo strField = structType.GetField("Str");
@@ -674,15 +675,16 @@ namespace WinSCP
             lock (_input)
             {
                 _input.Add(str);
+                _log.Add(log);
                 _inputEvent.Set();
             }
         }
 
-        public void ExecuteCommand(string command)
+        public void ExecuteCommand(string command, string log)
         {
             using (_logger.CreateCallstack())
             {
-                AddInput(command);
+                AddInput(command, log);
             }
         }
 
@@ -938,6 +940,7 @@ namespace WinSCP
         private string _lastFromBeginning;
         private string _incompleteLine;
         private readonly List<string> _input = new List<string>();
+        private readonly List<string> _log = new List<string>();
         private AutoResetEvent _inputEvent = new AutoResetEvent(false);
         private Job _job;
     }

+ 1 - 0
dotnet/properties/AssemblyInfo.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Reflection;
+using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // General Information about an assembly is controlled through the following