-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix filtering of analytic events on Unix platforms. #6086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1321,7 +1321,7 @@ private static bool WriteScriptBlockToLog(ScriptBlock scriptBlock, int segment, | |
| // they can just wait on the compromised box and see the sensitive data eventually anyways. | ||
|
|
||
| string errorMessage = StringUtil.Format(SecuritySupportStrings.CouldNotEncryptContent, textToLog, error.ToString()); | ||
| PSEtwLog.LogOperationalError(PSEventId.ScriptBlock_Compile_Detail, PSOpcode.Create, PSTask.ExecuteCommand, PSKeyword.UseAlwaysAnalytic, | ||
| PSEtwLog.LogOperationalError(PSEventId.ScriptBlock_Compile_Detail, PSOpcode.Create, PSTask.ExecuteCommand, PSKeyword.UseAlwaysOperational, | ||
| 0, 0, errorMessage, scriptBlock.Id.ToString(), scriptBlock.File ?? String.Empty); | ||
| } | ||
| else | ||
|
|
@@ -1334,12 +1334,12 @@ private static bool WriteScriptBlockToLog(ScriptBlock scriptBlock, int segment, | |
|
|
||
| if (scriptBlock._scriptBlockData.HasSuspiciousContent) | ||
| { | ||
| PSEtwLog.LogOperationalWarning(PSEventId.ScriptBlock_Compile_Detail, PSOpcode.Create, PSTask.ExecuteCommand, PSKeyword.UseAlwaysAnalytic, | ||
| PSEtwLog.LogOperationalWarning(PSEventId.ScriptBlock_Compile_Detail, PSOpcode.Create, PSTask.ExecuteCommand, PSKeyword.UseAlwaysOperational, | ||
| segment + 1, segments, textToLog, scriptBlock.Id.ToString(), scriptBlock.File ?? String.Empty); | ||
| } | ||
| else | ||
| { | ||
| PSEtwLog.LogOperationalVerbose(PSEventId.ScriptBlock_Compile_Detail, PSOpcode.Create, PSTask.ExecuteCommand, PSKeyword.UseAlwaysAnalytic, | ||
| PSEtwLog.LogOperationalVerbose(PSEventId.ScriptBlock_Compile_Detail, PSOpcode.Create, PSTask.ExecuteCommand, PSKeyword.UseAlwaysOperational, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are 4 more instances of
Can you please correct them all?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Script block logging moves from Analytic to Operational, which is different from Windows PowerShell. Is this considered a breaking change that needs to be communicated to Windows platform users?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The methods That piece of code is weird. I don't understand why those two keywords are simply ignored on Windows. Maybe it's just a misunderstanding when implementing
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That does look weird ... how do we know it defaults to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not default to |
||
| segment + 1, segments, textToLog, scriptBlock.Id.ToString(), scriptBlock.File ?? String.Empty); | ||
| } | ||
|
|
||
|
|
@@ -1405,7 +1405,7 @@ private static bool GetAndValidateEncryptionRecipients(ScriptBlock scriptBlock, | |
| // attacker seeing potentially sensitive data. Because if they aren't detected, then | ||
| // they can just wait on the compromised box and see the sensitive data eventually anyways. | ||
| string errorMessage = StringUtil.Format(SecuritySupportStrings.CouldNotUseCertificate, error.ToString()); | ||
| PSEtwLog.LogOperationalError(PSEventId.ScriptBlock_Compile_Detail, PSOpcode.Create, PSTask.ExecuteCommand, PSKeyword.UseAlwaysAnalytic, | ||
| PSEtwLog.LogOperationalError(PSEventId.ScriptBlock_Compile_Detail, PSOpcode.Create, PSTask.ExecuteCommand, PSKeyword.UseAlwaysOperational, | ||
| 0, 0, errorMessage, scriptBlock.Id.ToString(), scriptBlock.File ?? String.Empty); | ||
|
|
||
| return true; | ||
|
|
@@ -1430,7 +1430,7 @@ private static bool GetAndValidateEncryptionRecipients(ScriptBlock scriptBlock, | |
| } | ||
|
|
||
| string errorMessage = StringUtil.Format(SecuritySupportStrings.CertificateContainsPrivateKey, certificateForLog); | ||
| PSEtwLog.LogOperationalError(PSEventId.ScriptBlock_Compile_Detail, PSOpcode.Create, PSTask.ExecuteCommand, PSKeyword.UseAlwaysAnalytic, | ||
| PSEtwLog.LogOperationalError(PSEventId.ScriptBlock_Compile_Detail, PSOpcode.Create, PSTask.ExecuteCommand, PSKeyword.UseAlwaysOperational, | ||
| 0, 0, errorMessage, scriptBlock.Id.ToString(), scriptBlock.File ?? String.Empty); | ||
| } | ||
| } | ||
|
|
@@ -1794,7 +1794,7 @@ internal static void LogScriptBlockStart(ScriptBlock scriptBlock, Guid runspaceI | |
|
|
||
| if (GetScriptBlockLoggingSetting()?.EnableScriptBlockInvocationLogging == true) | ||
| { | ||
| PSEtwLog.LogOperationalVerbose(PSEventId.ScriptBlock_Invoke_Start_Detail, PSOpcode.Create, PSTask.CommandStart, PSKeyword.UseAlwaysAnalytic, | ||
| PSEtwLog.LogOperationalVerbose(PSEventId.ScriptBlock_Invoke_Start_Detail, PSOpcode.Create, PSTask.CommandStart, PSKeyword.UseAlwaysOperational, | ||
| scriptBlock.Id.ToString(), runspaceId.ToString()); | ||
| } | ||
| } | ||
|
|
@@ -1803,7 +1803,7 @@ internal static void LogScriptBlockEnd(ScriptBlock scriptBlock, Guid runspaceId) | |
| { | ||
| if (GetScriptBlockLoggingSetting()?.EnableScriptBlockInvocationLogging == true) | ||
| { | ||
| PSEtwLog.LogOperationalVerbose(PSEventId.ScriptBlock_Invoke_Complete_Detail, PSOpcode.Create, PSTask.CommandStop, PSKeyword.UseAlwaysAnalytic, | ||
| PSEtwLog.LogOperationalVerbose(PSEventId.ScriptBlock_Invoke_Complete_Detail, PSOpcode.Create, PSTask.CommandStop, PSKeyword.UseAlwaysOperational, | ||
| scriptBlock.Id.ToString(), runspaceId.ToString()); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,11 @@ internal class PSSysLogProvider : LogProvider | |
| { | ||
| private static SysLogProvider s_provider; | ||
|
|
||
| // by default, do not include analytic events | ||
| internal const PSKeyword DefaultKeywords = (PSKeyword) (0xFFFFFFFFFFFFFFFF & ~(ulong)PSKeyword.UseAlwaysAnalytic); | ||
| // by default, do not include channel bits | ||
| internal const PSKeyword DefaultKeywords = (PSKeyword) (0x00FFFFFFFFFFFFFF); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default keyword should be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's as intended; channel bits use the high order byte.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. Closed. |
||
|
|
||
| // the default enabled channel(s) | ||
| internal const PSChannel DefaultChannels = PSChannel.Operational; | ||
|
|
||
| /// <summary> | ||
| /// Class constructor. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The enum is actually not a flags enum on Windows ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed