mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Merge pull request #4781 from hvitved/csharp/persisten-cookie-tests
C#: Add tests for `PersistentCookie.ql`
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
// semmle-extractor-options: ${testdir}/../../../../resources/stubs/System.Web.cs /r:System.Collections.Specialized.dll
|
||||
using System;
|
||||
|
||||
class PersistentCookie
|
||||
{
|
||||
void M(System.Web.HttpCookie cookie)
|
||||
{
|
||||
cookie.Expires = DateTime.Now.AddMonths(12); // BAD
|
||||
cookie.Expires = DateTime.Now.AddMinutes(3); // GOOD
|
||||
cookie.Expires = DateTime.Now.AddSeconds(301); // BAD
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
| PersistentCookie.cs:8:9:8:51 | ... = ... | Avoid persistent cookies. |
|
||||
| PersistentCookie.cs:10:9:10:53 | ... = ... | Avoid persistent cookies. |
|
||||
@@ -0,0 +1 @@
|
||||
Security Features/PersistentCookie.ql
|
||||
@@ -183,6 +183,7 @@ namespace System.Web
|
||||
public NameValueCollection Values => null;
|
||||
public string this[string s] { get => null; set { } }
|
||||
public bool Secure { get; set; }
|
||||
public System.DateTime Expires { get; set; }
|
||||
}
|
||||
|
||||
public abstract class HttpCookieCollection : System.Collections.Specialized.NameObjectCollectionBase
|
||||
|
||||
Reference in New Issue
Block a user