mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Disable AMSI content logging in release (#26235)
This commit is contained in:
@@ -3644,6 +3644,7 @@ namespace System.Management.Automation
|
||||
|
||||
internal static class MemberInvocationLoggingOps
|
||||
{
|
||||
#if DEBUG
|
||||
private static readonly Lazy<bool> DumpLogAMSIContent = new Lazy<bool>(
|
||||
() => {
|
||||
object result = Environment.GetEnvironmentVariable("__PSDumpAMSILogContent");
|
||||
@@ -3654,6 +3655,7 @@ namespace System.Management.Automation
|
||||
return false;
|
||||
}
|
||||
);
|
||||
#endif
|
||||
|
||||
private static string ArgumentToString(object arg)
|
||||
{
|
||||
@@ -3708,20 +3710,24 @@ namespace System.Management.Automation
|
||||
|
||||
string content = $"<{targetName}>.{name}({argsBuilder})";
|
||||
|
||||
#if DEBUG
|
||||
if (DumpLogAMSIContent.Value)
|
||||
{
|
||||
Console.WriteLine("\n=== Amsi notification report content ===");
|
||||
Console.WriteLine(content);
|
||||
}
|
||||
#endif
|
||||
|
||||
var success = AmsiUtils.ReportContent(
|
||||
name: contentName,
|
||||
content: content);
|
||||
|
||||
#if DEBUG
|
||||
if (DumpLogAMSIContent.Value)
|
||||
{
|
||||
Console.WriteLine($"=== Amsi notification report success: {success} ===");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch (PSSecurityException)
|
||||
{
|
||||
@@ -3729,12 +3735,16 @@ namespace System.Management.Automation
|
||||
// must be propagated.
|
||||
throw;
|
||||
}
|
||||
#pragma warning disable CS0168 // variable declared but never used
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CS0168
|
||||
{
|
||||
#if DEBUG
|
||||
if (DumpLogAMSIContent.Value)
|
||||
{
|
||||
Console.WriteLine($"!!! Amsi notification report exception: {ex} !!!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user