瀏覽代碼

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

https://winscp.net/tracker/1475

Source commit: f70363c489d8acb04445b63c863b5ad27d44363d
Martin Prikryl 9 年之前
父節點
當前提交
11903086f8
共有 3 個文件被更改,包括 9 次插入5 次删除
  1. 1 1
      dotnet/Session.cs
  2. 7 4
      dotnet/internal/ExeSessionProcess.cs
  3. 1 0
      dotnet/properties/AssemblyInfo.cs

+ 1 - 1
dotnet/Session.cs

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

+ 7 - 4
dotnet/internal/ExeSessionProcess.cs

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

+ 1 - 0
dotnet/properties/AssemblyInfo.cs

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