-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b823c4
commit 79fe6b8
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...zer-dotnet/tests/SonarAnalyzer.UnitTest/TestCases/CookieShouldBeSecure_NetCore.CSharp9.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
CookieOptions topLevelStatement1 = new(); // FN | ||
CookieOptions topLevelStatement2 = new CookieOptions(); // Noncompliant | ||
|
||
class Program | ||
{ | ||
CookieOptions field1 = new(); // FN | ||
CookieOptions field2; | ||
|
||
CookieOptions Property0 { get; init; } = new CookieOptions(); // Noncompliant | ||
CookieOptions Property1 { get; init; } = new (); // FN | ||
CookieOptions Property2 { get; init; } | ||
|
||
Program() | ||
{ | ||
Property2.Secure = false; // Noncompliant | ||
} | ||
|
||
void InitializerSetsNotAllowedValue() | ||
{ | ||
CookieOptions c0 = new () { Secure = false }; // FN | ||
CookieOptions c1 = new () { HttpOnly = true }; // FN, as Secure is not set | ||
} | ||
} | ||
|
||
// See https://github.com/dotnet/roslyn/issues/45510 | ||
namespace System.Runtime.CompilerServices | ||
{ | ||
public class IsExternalInit { } | ||
} |