Skip to content

Commit c2324e0

Browse files
committed
Remove obsolete CA2118 rule suppression
The FxCop [`CA2118:ReviewSuppressUnmanagedCodeSecurityUsage`](https://learn.microsoft.com/previous-versions/visualstudio/visual-studio-2010/ms182311(v=vs.100)) rule [was not ported to roslyn](dotnet/roslyn-analyzers#496).
1 parent cae1dc2 commit c2324e0

3 files changed

Lines changed: 0 additions & 13 deletions

File tree

src/System.Management.Automation/namespaces/TransactedRegistryKey.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ public sealed class TransactedRegistryKey : MarshalByRefObject, IDisposable
141141
// If that call fails with ERROR_INVALID_TRANSACTION, we have possibly run into bug 181242. To workaround
142142
// this, we open the key without a transaction and then open it again with
143143
// a transaction and return THAT hkey.
144-
145-
// Suppressed because there is no way for arbitrary data to be passed.
146-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
147144
private int RegOpenKeyTransactedWrapper(SafeRegistryHandle hKey, string lpSubKey,
148145
int ulOptions, int samDesired, out SafeRegistryHandle hkResult,
149146
SafeTransactionHandle hTransaction, IntPtr pExtendedParameter)

src/System.Management.Automation/namespaces/Win32Native.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ internal struct TOKEN_USER
107107
/// <returns></returns>
108108
[DllImport(PinvokeDllNames.LookupAccountSidDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
109109
[ResourceExposure(ResourceScope.Machine)]
110-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
111110
[return: MarshalAs(UnmanagedType.Bool)]
112111
private static extern unsafe bool LookupAccountSid(string lpSystemName,
113112
IntPtr sid,
@@ -140,7 +139,6 @@ internal static unsafe bool LookupAccountSid(string lpSystemName,
140139

141140
[DllImport(PinvokeDllNames.CloseHandleDllName, SetLastError = true)]
142141
[ResourceExposure(ResourceScope.Machine)]
143-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
144142
[return: MarshalAs(UnmanagedType.Bool)]
145143
internal static extern bool CloseHandle(IntPtr handle);
146144

@@ -153,7 +151,6 @@ internal static unsafe bool LookupAccountSid(string lpSystemName,
153151
/// <returns>The current process token.</returns>
154152
[DllImport(PinvokeDllNames.OpenProcessTokenDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
155153
[ResourceExposure(ResourceScope.Machine)]
156-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
157154
[return: MarshalAs(UnmanagedType.Bool)]
158155
internal static extern bool OpenProcessToken(IntPtr processHandle, uint desiredAccess, out IntPtr tokenHandle);
159156

@@ -169,7 +166,6 @@ internal static unsafe bool LookupAccountSid(string lpSystemName,
169166
/// <returns></returns>
170167
[DllImport(PinvokeDllNames.GetTokenInformationDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
171168
[ResourceExposure(ResourceScope.Machine)]
172-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
173169
[return: MarshalAs(UnmanagedType.Bool)]
174170
internal static extern bool GetTokenInformation(IntPtr tokenHandle,
175171
TOKEN_INFORMATION_CLASS tokenInformationClass,

src/System.Management.Automation/utils/PlatformInvokes.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ internal static extern IntPtr CreateFile(
235235
/// </returns>
236236
[DllImport(PinvokeDllNames.CloseHandleDllName, SetLastError = true)]
237237
[return: MarshalAs(UnmanagedType.Bool)]
238-
// [SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
239238
internal static extern bool CloseHandle(IntPtr handle);
240239

241240
[DllImport(PinvokeDllNames.DosDateTimeToFileTimeDllName, SetLastError = false)]
@@ -412,7 +411,6 @@ internal static bool RestoreTokenPrivilege(string privilegeName, ref TOKEN_PRIVI
412411
/// <param name="lpLuid"></param>
413412
/// <returns></returns>
414413
[DllImport(PinvokeDllNames.LookupPrivilegeValueDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
415-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
416414
[return: MarshalAs(UnmanagedType.Bool)]
417415
internal static extern bool LookupPrivilegeValue(string lpSystemName, string lpName, ref LUID lpLuid);
418416

@@ -424,7 +422,6 @@ internal static bool RestoreTokenPrivilege(string privilegeName, ref TOKEN_PRIVI
424422
/// <param name="pfResult"></param>
425423
/// <returns></returns>
426424
[DllImport(PinvokeDllNames.PrivilegeCheckDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
427-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
428425
[return: MarshalAs(UnmanagedType.Bool)]
429426
internal static extern bool PrivilegeCheck(IntPtr tokenHandler, ref PRIVILEGE_SET requiredPrivileges, out bool pfResult);
430427

@@ -441,7 +438,6 @@ internal static bool RestoreTokenPrivilege(string privilegeName, ref TOKEN_PRIVI
441438
/// <param name="returnLength"></param>
442439
/// <returns></returns>
443440
[DllImport(PinvokeDllNames.AdjustTokenPrivilegesDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
444-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
445441
[return: MarshalAs(UnmanagedType.Bool)]
446442
internal static extern bool AdjustTokenPrivileges(IntPtr tokenHandler, bool disableAllPrivilege,
447443
ref TOKEN_PRIVILEGE newPrivilegeState, int bufferLength,
@@ -482,7 +478,6 @@ internal struct PRIVILEGE_SET
482478
/// </summary>
483479
/// <returns></returns>
484480
[DllImport(PinvokeDllNames.GetCurrentProcessDllName)]
485-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
486481
internal static extern IntPtr GetCurrentProcess();
487482

488483
/// <summary>
@@ -494,7 +489,6 @@ internal struct PRIVILEGE_SET
494489
/// <param name="tokenHandle">Process token.</param>
495490
/// <returns>The current process token.</returns>
496491
[DllImport(PinvokeDllNames.OpenProcessTokenDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
497-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
498492
[return: MarshalAs(UnmanagedType.Bool)]
499493
internal static extern bool OpenProcessToken(IntPtr processHandle, uint desiredAccess, out IntPtr tokenHandle);
500494

0 commit comments

Comments
 (0)