Skip to content

Commit 93f70b3

Browse files
Add unit tests
1 parent b28d799 commit 93f70b3

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

python/ql/src/Security/CWE-614/InsecureCookie.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ predicate hasAlert(Http::Server::CookieWrite cookie, string alert) {
3838
or
3939
numProblems = 2 and
4040
alert =
41-
strictconcat(string prob, int idx | hasProblem(cookie, prob, idx) | " and ", prob order by idx)
41+
strictconcat(string prob, int idx | hasProblem(cookie, prob, idx) | prob, " and " order by idx)
4242
+ " attributes"
4343
or
4444
numProblems = 3 and
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
| test.py:10:5:10:37 | ControlFlowNode for Attribute() | Cookie is added without the Secure and HttpOnly attributes properly set. |
2+
| test.py:11:5:11:50 | ControlFlowNode for Attribute() | Cookie is added without the HttpOnly attribute properly set. |
3+
| test.py:12:5:12:52 | ControlFlowNode for Attribute() | Cookie is added without the Secure attribute properly set. |
4+
| test.py:13:5:13:56 | ControlFlowNode for Attribute() | Cookie is added without the Secure and HttpOnly attributes properly set. |
5+
| test.py:14:5:14:53 | ControlFlowNode for Attribute() | Cookie is added without the Secure and HttpOnly attributes properly set. |
6+
| test.py:15:5:15:54 | ControlFlowNode for Attribute() | Cookie is added without the Secure, HttpOnly, and SameSite attributes properly set. |
7+
| test.py:16:5:16:69 | ControlFlowNode for Attribute() | Cookie is added without the HttpOnly attribute properly set. |
8+
| test.py:17:5:17:71 | ControlFlowNode for Attribute() | Cookie is added without the Secure attribute properly set. |
9+
| test.py:18:5:18:67 | ControlFlowNode for Attribute() | Cookie is added without the HttpOnly and SameSite attributes properly set. |
10+
| test.py:19:5:19:69 | ControlFlowNode for Attribute() | Cookie is added without the Secure and SameSite attributes properly set. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Security/CWE-614/InsecureCookie.ql
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from flask import Flask, request, make_response
2+
import lxml.etree
3+
import markupsafe
4+
5+
app = Flask(__name__)
6+
7+
@app.route("/test")
8+
def test():
9+
resp = make_response()
10+
resp.set_cookie("key1", "value1")
11+
resp.set_cookie("key2", "value2", secure=True)
12+
resp.set_cookie("key2", "value2", httponly=True)
13+
resp.set_cookie("key2", "value2", samesite="Strict")
14+
resp.set_cookie("key2", "value2", samesite="Lax")
15+
resp.set_cookie("key2", "value2", samesite="None")
16+
resp.set_cookie("key2", "value2", secure=True, samesite="Strict")
17+
resp.set_cookie("key2", "value2", httponly=True, samesite="Strict")
18+
resp.set_cookie("key2", "value2", secure=True, samesite="None")
19+
resp.set_cookie("key2", "value2", httponly=True, samesite="None")
20+
resp.set_cookie("key2", "value2", secure=True, httponly=True, samesite="Strict")

0 commit comments

Comments
 (0)