Update Microsoft.CodeAnalysis.NetAnalyzers to 3.3.0-beta3.20407.4 (#40560)
authorStephen Toub <stoub@microsoft.com>
Sun, 9 Aug 2020 09:32:44 +0000 (05:32 -0400)
committerGitHub <noreply@github.com>
Sun, 9 Aug 2020 09:32:44 +0000 (05:32 -0400)
eng/Analyzers.props
eng/CodeAnalysis.ruleset
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CreateProcessWithLogon.cs
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CryptGetDefaultProvider.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.cs
src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp.cs
src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj
src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/LibcupsNative.cs
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs
src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/FakeInterop.cs

index 2c9b1c8..c14a869 100644 (file)
@@ -6,7 +6,7 @@
   </PropertyGroup>
   <ItemGroup Condition="'$(EnableAnalyzers)' == 'true'">
     <PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
-    <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="3.3.0-beta1.20355.1" PrivateAssets="all" />
+    <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="3.3.0-beta3.20407.4" PrivateAssets="all" />
     <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164" PrivateAssets="all" />
   </ItemGroup>
 </Project>
index 42ea385..3726904 100644 (file)
@@ -64,6 +64,7 @@
       <Rule Id="CA1308" Action="None" />             <!-- Normalize strings to uppercase -->
       <Rule Id="CA1309" Action="None" />             <!-- Use ordinal stringcomparison -->
       <Rule Id="CA1401" Action="Warning" />          <!-- P/Invokes should not be visible -->
+      <Rule Id="CA1417" Action="Warning" />          <!-- Do not use 'OutAttribute' on string parameters for P/Invokes -->
       <Rule Id="CA1501" Action="None" />             <!-- Avoid excessive inheritance -->
       <Rule Id="CA1502" Action="None" />             <!-- Avoid excessive complexity -->
       <Rule Id="CA1505" Action="None" />             <!-- Avoid unmaintainable code -->
       <Rule Id="CA1834" Action="Warning" />          <!-- Consider using 'StringBuilder.Append(char)' when applicable. -->
       <Rule Id="CA1835" Action="Warning" />          <!-- Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync' -->
       <Rule Id="CA1836" Action="Info" />             <!-- Prefer IsEmpty over Count -->
+      <Rule Id="CA1837" Action="Warning" />          <!-- Use 'Environment.ProcessId' -->
+      <Rule Id="CA1838" Action="Warning" />          <!-- Avoid 'StringBuilder' parameters for P/Invokes -->
       <Rule Id="CA2000" Action="None" />             <!-- Dispose objects before losing scope -->
       <Rule Id="CA2002" Action="None" />             <!-- Do not lock on objects with weak identity -->
       <Rule Id="CA2007" Action="Warning" />          <!-- Consider calling ConfigureAwait on the awaited task -->
       <Rule Id="CA2328" Action="None" />             <!-- Ensure that JsonSerializerSettings are secure -->
       <Rule Id="CA2329" Action="None" />             <!-- Do not deserialize with JsonSerializer using an insecure configuration -->
       <Rule Id="CA2330" Action="None" />             <!-- Ensure that JsonSerializer has a secure configuration when deserializing -->
+      <Rule Id="CA2350" Action="None" />             <!-- Do not use DataTable.ReadXml() with untrusted data -->
+      <Rule Id="CA2351" Action="None" />             <!-- Do not use DataSet.ReadXml() with untrusted data -->
+      <Rule Id="CA2352" Action="None" />             <!-- Unsafe DataSet or DataTable in serializable type can be vulnerable to remote code execution attacks -->
+      <Rule Id="CA2353" Action="None" />             <!-- Unsafe DataSet or DataTable in serializable type -->
+      <Rule Id="CA2354" Action="None" />             <!-- Unsafe DataSet or DataTable in deserialized object graph can be vulnerable to remote code execution attacks -->
+      <Rule Id="CA2355" Action="None" />             <!-- Unsafe DataSet or DataTable type found in deserializable object graph -->
+      <Rule Id="CA2356" Action="None" />             <!-- Unsafe DataSet or DataTable type in web deserializable object graph -->
+      <Rule Id="CA2361" Action="None" />             <!-- Ensure autogenerated class containing DataSet.ReadXml() is not used with untrusted data -->
+      <Rule Id="CA2362" Action="None" />             <!-- Unsafe DataSet or DataTable in autogenerated serializable type can be vulnerable to remote code execution attacks -->
       <Rule Id="CA3001" Action="None" />             <!-- Review code for SQL injection vulnerabilities -->
       <Rule Id="CA3002" Action="None" />             <!-- Review code for XSS vulnerabilities -->
       <Rule Id="CA3003" Action="None" />             <!-- Review code for file path injection vulnerabilities -->
       <Rule Id="CA5401" Action="None" />             <!-- Do not use CreateEncryptor with non-default IV -->
       <Rule Id="CA5402" Action="None" />             <!-- Use CreateEncryptor with the default IV  -->
       <Rule Id="CA5403" Action="None" />             <!-- Do not hard-code certificate -->
+      <Rule Id="IL3000" Action="None" />             <!-- Avoid using accessing Assembly file path when publishing as a single-file -->
+      <Rule Id="IL3001" Action="None" />             <!-- Avoid using accessing Assembly file path when publishing as a single-file -->
   </Rules>
   <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
     <Rule Id="AD0001" Action="None" /> <!-- Analyzer threw an exception -->
index 7d4fc64..61e28bd 100644 (file)
@@ -18,7 +18,9 @@ internal partial class Interop
             IntPtr password,
             LogonFlags logonFlags,
             string? appName,
+#pragma warning disable CA1838 // reasonable use of StringBuilder to build up a command line
             [In] StringBuilder cmdLine,
+#pragma warning restore CA1838
             int creationFlags,
             IntPtr environmentBlock,
             string lpCurrentDirectory,
index 8b3a702..3a26433 100644 (file)
@@ -20,7 +20,9 @@ internal partial class Interop
             int dwProvType,
             IntPtr pdwReserved,
             GetDefaultProviderFlags dwFlags,
-            StringBuilder? pszProvName,
+#pragma warning disable CA1838 // not on a hot path
+            [Out] StringBuilder? pszProvName,
+#pragma warning restore CA1838
             ref int pcbProvName);
     }
 }
index 104bfe0..95a17f1 100644 (file)
@@ -15,7 +15,9 @@ internal partial class Interop
         [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false, EntryPoint = "CreateProcessW")]
         internal static extern bool CreateProcess(
             string? lpApplicationName,
+#pragma warning disable CA1838 // reasonable use of StringBuilder to build up a command line
             [In] StringBuilder lpCommandLine,
+#pragma warning restore CA1838
             ref SECURITY_ATTRIBUTES procSecAttrs,
             ref SECURITY_ATTRIBUTES threadSecAttrs,
             bool bInheritHandles,
index c56d91b..ddaaf8a 100644 (file)
@@ -43,7 +43,9 @@ internal partial class Interop
         [return: MarshalAs(UnmanagedType.Bool)]
         public static extern bool WinHttpAddRequestHeaders(
             SafeWinHttpHandle requestHandle,
+#pragma warning disable CA1838 // Uses pooled StringBuilder
             [In] StringBuilder headers,
+#pragma warning restore CA1838
             uint headersLength,
             uint modifiers);
 
@@ -59,7 +61,7 @@ internal partial class Interop
         [return: MarshalAs(UnmanagedType.Bool)]
         public static extern bool WinHttpSendRequest(
             SafeWinHttpHandle requestHandle,
-            [In] StringBuilder headers,
+            IntPtr headers,
             uint headersLength,
             IntPtr optional,
             uint optionalLength,
index b9c7252..e118672 100644 (file)
@@ -3,7 +3,7 @@
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-Solaris;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent);netcoreapp2.0-FreeBSD;netcoreapp2.0-Linux;netcoreapp2.0-OSX;netcoreapp2.0-Windows_NT;netstandard2.0;net461-Windows_NT</TargetFrameworks>
     <ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage>
-    <NoWarn>$(NoWarn);CA2249</NoWarn>
+    <NoWarn>$(NoWarn);CA2249;CA1838</NoWarn>
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
index 42937d1..a22f890 100644 (file)
@@ -3,6 +3,7 @@
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;netcoreapp2.0-Windows_NT;net461;netstandard2.0</TargetFrameworks>
     <ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage>
+    <NoWarn>$(NoWarn);CA1838</NoWarn>
   </PropertyGroup>
   <!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
   <PropertyGroup>
index f741f0a..cc3e39f 100644 (file)
@@ -33,7 +33,9 @@ namespace System.Drawing.Printing
         internal static extern void cupsFreeDests(int num_dests, IntPtr dests);
 
         [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Ansi)]
-        internal static extern IntPtr cupsTempFd(StringBuilder sb, int len);
+#pragma warning disable CA1838 // not hot-path enough to worry about the overheads of StringBuilder marshaling
+        internal static extern IntPtr cupsTempFd([Out] StringBuilder sb, int len);
+#pragma warning restore CA1838
 
         [DllImport(LibraryName, ExactSpelling = true)]
         internal static extern IntPtr cupsGetDefault();
index c2b405d..40cd1d5 100644 (file)
@@ -1406,7 +1406,7 @@ namespace System.Net.Http
                 state.Pin();
                 if (!Interop.WinHttp.WinHttpSendRequest(
                     state.RequestHandle,
-                    null,
+                    IntPtr.Zero,
                     0,
                     IntPtr.Zero,
                     0,
index 728aacd..24e4b71 100644 (file)
@@ -157,7 +157,7 @@ internal static partial class Interop
 
         public static bool WinHttpSendRequest(
             SafeWinHttpHandle requestHandle,
-            StringBuilder headers,
+            IntPtr headers,
             uint headersLength,
             IntPtr optional,
             uint optionalLength,