Skip to content

Commit 626d43b

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 cf2d702 commit 626d43b

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
@@ -106,7 +106,6 @@ internal struct TOKEN_USER
106106
/// <param name="peUse"></param>
107107
/// <returns></returns>
108108
[DllImport(PinvokeDllNames.LookupAccountSidDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
109-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
110109
[return: MarshalAs(UnmanagedType.Bool)]
111110
private static extern unsafe bool LookupAccountSid(string lpSystemName,
112111
IntPtr sid,
@@ -138,7 +137,6 @@ internal static unsafe bool LookupAccountSid(string lpSystemName,
138137
}
139138

140139
[DllImport(PinvokeDllNames.CloseHandleDllName, SetLastError = true)]
141-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
142140
[return: MarshalAs(UnmanagedType.Bool)]
143141
internal static extern bool CloseHandle(IntPtr handle);
144142

@@ -150,7 +148,6 @@ internal static unsafe bool LookupAccountSid(string lpSystemName,
150148
/// <param name="tokenHandle">Process token.</param>
151149
/// <returns>The current process token.</returns>
152150
[DllImport(PinvokeDllNames.OpenProcessTokenDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
153-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
154151
[return: MarshalAs(UnmanagedType.Bool)]
155152
internal static extern bool OpenProcessToken(IntPtr processHandle, uint desiredAccess, out IntPtr tokenHandle);
156153

@@ -165,7 +162,6 @@ internal static unsafe bool LookupAccountSid(string lpSystemName,
165162
/// <param name="returnLength"></param>
166163
/// <returns></returns>
167164
[DllImport(PinvokeDllNames.GetTokenInformationDllName, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
168-
[SuppressMessage("Microsoft.Security", "CA2118:ReviewSuppressUnmanagedCodeSecurityUsage")]
169165
[return: MarshalAs(UnmanagedType.Bool)]
170166
internal static extern bool GetTokenInformation(IntPtr tokenHandle,
171167
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)