Skip to content

Commit 3e4ef01

Browse files
authored
Merge pull request #2829 from mavasani/DisableCoupleOfSecurityAnalyzers
Disable couple of DFA security analyzers by default
2 parents 293ac30 + 05edb57 commit 3e4ef01

6 files changed

+10
-12
lines changed

src/Microsoft.CodeAnalysis.FxCopAnalyzers/Microsoft.CodeAnalysis.FxCopAnalyzers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ Sr. No. | Rule ID | Title | Category | Enabled | CodeFix | Description |
188188
185 | [CA5386](https://docs.microsoft.com/visualstudio/code-quality/ca5386) | Avoid hardcoding SecurityProtocolType value | Security | False | False | Avoid hardcoding SecurityProtocolType {0}, and instead use SecurityProtocolType.SystemDefault to allow the operating system to choose the best Transport Layer Security protocol to use. |
189189
186 | CA5387 | Do Not Use Weak Key Derivation Function With Insufficient Iteration Count | Security | False | False | When deriving cryptographic keys from user-provided inputs such as password, use sufficient iteration count (at least 100k). |
190190
187 | CA5388 | Ensure Sufficient Iteration Count When Using Weak Key Derivation Function | Security | False | False | When deriving cryptographic keys from user-provided inputs such as password, use sufficient iteration count (at least 100k). |
191-
188 | CA5389 | Do Not Add Archive Item's Path To The Target File System Path | Security | True | False | When extracting files from an archive and using the archive item's path, check if the path is safe. Archive path can be relative and can lead to file system access outside of the expected file system target path, leading to malicious config changes and remote code execution via lay-and-wait technique. |
192-
189 | CA5390 | Do Not Hard Code Encryption Key | Security | True | False | SymmetricAlgorithm's .Key property, or a method's rgbKey parameter, should never be a hardcoded value. |
191+
188 | CA5389 | Do Not Add Archive Item's Path To The Target File System Path | Security | False | False | When extracting files from an archive and using the archive item's path, check if the path is safe. Archive path can be relative and can lead to file system access outside of the expected file system target path, leading to malicious config changes and remote code execution via lay-and-wait technique. |
192+
189 | CA5390 | Do Not Hard Code Encryption Key | Security | False | False | SymmetricAlgorithm's .Key property, or a method's rgbKey parameter, should never be a hardcoded value. |
193193
190 | CA5391 | Use antiforgery tokens in ASP.NET Core MVC controllers | Security | True | False | Handling a POST, PUT, PATCH, or DELETE request without validating an antiforgery token may be vulnerable to cross-site request forgery attacks. A cross-site request forgery attack can send malicious requests from an authenticated user to your ASP.NET Core MVC controller. |
194194
191 | CA5392 | Use DefaultDllImportSearchPaths attribute for P/Invokes | Security | True | False | By default, P/Invokes using DllImportAttribute probe a number of directories, including the current working directory for the library to load. This can be a security issue for certain applications, leading to DLL hijacking. |
195195
192 | CA5393 | Do not use unsafe DllImportSearchPath value | Security | True | False | There could be a malicious DLL in the default DLL search directories. Or, depending on where your application is run from, there could be a malicious DLL in the application's directory. Use a DllImportSearchPath value that specifies an explicit search path instead. The DllImportSearchPath flags that this rule looks for can be configured in .editorconfig. |

src/Microsoft.CodeAnalysis.FxCopAnalyzers/Microsoft.CodeAnalysis.FxCopAnalyzers.sarif

+2-2
Original file line numberDiff line numberDiff line change
@@ -3565,7 +3565,7 @@
35653565
"defaultLevel": "warning",
35663566
"properties": {
35673567
"category": "Security",
3568-
"isEnabledByDefault": true,
3568+
"isEnabledByDefault": false,
35693569
"typeName": "DoNotAddArchiveItemPathToTheTargetFileSystemPath",
35703570
"languages": [
35713571
"C#",
@@ -3584,7 +3584,7 @@
35843584
"defaultLevel": "warning",
35853585
"properties": {
35863586
"category": "Security",
3587-
"isEnabledByDefault": true,
3587+
"isEnabledByDefault": false,
35883588
"typeName": "DoNotHardCodeEncryptionKey",
35893589
"languages": [
35903590
"C#",

src/Microsoft.NetCore.Analyzers/Core/Security/DoNotAddArchiveItemPathToTheTargetFileSystemPath.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

3-
using Analyzer.Utilities;
43
using Analyzer.Utilities.FlowAnalysis.Analysis.TaintedDataAnalysis;
54
using Microsoft.CodeAnalysis;
65
using Microsoft.CodeAnalysis.Diagnostics;
@@ -18,7 +17,7 @@ public class DoNotAddArchiveItemPathToTheTargetFileSystemPath : SourceTriggeredT
1817
typeof(MicrosoftNetCoreAnalyzersResources),
1918
nameof(MicrosoftNetCoreAnalyzersResources.DoNotAddArchiveItemPathToTheTargetFileSystemPath),
2019
nameof(MicrosoftNetCoreAnalyzersResources.DoNotAddArchiveItemPathToTheTargetFileSystemPathMessage),
21-
DiagnosticHelpers.EnabledByDefaultIfNotBuildingVSIX,
20+
isEnabledByDefault: false,
2221
helpLinkUri: null,
2322
descriptionResourceStringName: nameof(MicrosoftNetCoreAnalyzersResources.DoNotAddArchiveItemPathToTheTargetFileSystemPathDescription),
2423
customTags: WellKnownDiagnosticTagsExtensions.DataflowAndTelemetry);

src/Microsoft.NetCore.Analyzers/Core/Security/DoNotHardCodeEncryptionKey.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

3-
using Analyzer.Utilities;
43
using Analyzer.Utilities.FlowAnalysis.Analysis.TaintedDataAnalysis;
54
using Microsoft.CodeAnalysis;
65
using Microsoft.CodeAnalysis.Diagnostics;
@@ -16,7 +15,7 @@ public class DoNotHardCodeEncryptionKey : SourceTriggeredTaintedDataAnalyzerBase
1615
typeof(MicrosoftNetCoreAnalyzersResources),
1716
nameof(MicrosoftNetCoreAnalyzersResources.DoNotHardCodeEncryptionKey),
1817
nameof(MicrosoftNetCoreAnalyzersResources.DoNotHardCodeEncryptionKeyMessage),
19-
DiagnosticHelpers.EnabledByDefaultIfNotBuildingVSIX,
18+
isEnabledByDefault: false,
2019
helpLinkUri: null,
2120
descriptionResourceStringName: nameof(MicrosoftNetCoreAnalyzersResources.DoNotHardCodeEncryptionKeyDescription),
2221
customTags: WellKnownDiagnosticTagsExtensions.DataflowAndTelemetry);

src/Microsoft.NetCore.Analyzers/Microsoft.NetCore.Analyzers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ Sr. No. | Rule ID | Title | Category | Enabled | CodeFix | Description |
9696
93 | [CA5386](https://docs.microsoft.com/visualstudio/code-quality/ca5386) | Avoid hardcoding SecurityProtocolType value | Security | False | False | Avoid hardcoding SecurityProtocolType {0}, and instead use SecurityProtocolType.SystemDefault to allow the operating system to choose the best Transport Layer Security protocol to use. |
9797
94 | CA5387 | Do Not Use Weak Key Derivation Function With Insufficient Iteration Count | Security | False | False | When deriving cryptographic keys from user-provided inputs such as password, use sufficient iteration count (at least 100k). |
9898
95 | CA5388 | Ensure Sufficient Iteration Count When Using Weak Key Derivation Function | Security | False | False | When deriving cryptographic keys from user-provided inputs such as password, use sufficient iteration count (at least 100k). |
99-
96 | CA5389 | Do Not Add Archive Item's Path To The Target File System Path | Security | True | False | When extracting files from an archive and using the archive item's path, check if the path is safe. Archive path can be relative and can lead to file system access outside of the expected file system target path, leading to malicious config changes and remote code execution via lay-and-wait technique. |
100-
97 | CA5390 | Do Not Hard Code Encryption Key | Security | True | False | SymmetricAlgorithm's .Key property, or a method's rgbKey parameter, should never be a hardcoded value. |
99+
96 | CA5389 | Do Not Add Archive Item's Path To The Target File System Path | Security | False | False | When extracting files from an archive and using the archive item's path, check if the path is safe. Archive path can be relative and can lead to file system access outside of the expected file system target path, leading to malicious config changes and remote code execution via lay-and-wait technique. |
100+
97 | CA5390 | Do Not Hard Code Encryption Key | Security | False | False | SymmetricAlgorithm's .Key property, or a method's rgbKey parameter, should never be a hardcoded value. |
101101
98 | CA5391 | Use antiforgery tokens in ASP.NET Core MVC controllers | Security | True | False | Handling a POST, PUT, PATCH, or DELETE request without validating an antiforgery token may be vulnerable to cross-site request forgery attacks. A cross-site request forgery attack can send malicious requests from an authenticated user to your ASP.NET Core MVC controller. |
102102
99 | CA5392 | Use DefaultDllImportSearchPaths attribute for P/Invokes | Security | True | False | By default, P/Invokes using DllImportAttribute probe a number of directories, including the current working directory for the library to load. This can be a security issue for certain applications, leading to DLL hijacking. |
103103
100 | CA5393 | Do not use unsafe DllImportSearchPath value | Security | True | False | There could be a malicious DLL in the default DLL search directories. Or, depending on where your application is run from, there could be a malicious DLL in the application's directory. Use a DllImportSearchPath value that specifies an explicit search path instead. The DllImportSearchPath flags that this rule looks for can be configured in .editorconfig. |

src/Microsoft.NetCore.Analyzers/Microsoft.NetCore.Analyzers.sarif

+2-2
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@
16451645
"defaultLevel": "warning",
16461646
"properties": {
16471647
"category": "Security",
1648-
"isEnabledByDefault": true,
1648+
"isEnabledByDefault": false,
16491649
"typeName": "DoNotAddArchiveItemPathToTheTargetFileSystemPath",
16501650
"languages": [
16511651
"C#",
@@ -1664,7 +1664,7 @@
16641664
"defaultLevel": "warning",
16651665
"properties": {
16661666
"category": "Security",
1667-
"isEnabledByDefault": true,
1667+
"isEnabledByDefault": false,
16681668
"typeName": "DoNotHardCodeEncryptionKey",
16691669
"languages": [
16701670
"C#",

0 commit comments

Comments
 (0)