Skip to content

Commit 311df4d

Browse files
committed
add test for the cookie npm package
1 parent 92d59aa commit 311df4d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

javascript/ql/test/query-tests/Security/CWE-614/ClearTextCookie.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
| tst-cleartextCookie.js:177:5:177:19 | document.cookie | Sensitive cookie sent without enforcing SSL encryption |
1414
| tst-cleartextCookie.js:181:5:181:41 | cookies ... hkey()) | Sensitive cookie sent without enforcing SSL encryption |
1515
| tst-cleartextCookie.js:186:5:186:46 | cookie. ... hkey()) | Sensitive cookie sent without enforcing SSL encryption |
16+
| tst-cleartextCookie.js:195:33:195:74 | cookie. ... hkey()) | Sensitive cookie sent without enforcing SSL encryption |

javascript/ql/test/query-tests/Security/CWE-614/tst-cleartextCookie.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,14 @@ function clientCookies() {
185185

186186
cookie.serialize('authKey', makeAuthkey()); // NOT OK
187187
cookie.serialize('authKey', makeAuthkey(), { secure: true, expires: 7 }); // OK
188-
}
188+
}
189+
190+
const cookie = require('cookie');
191+
192+
http.createServer((req, res) => {
193+
res.setHeader('Content-Type', 'text/html');
194+
res.setHeader("Set-Cookie", cookie.serialize("authKey", makeAuthkey(), {secure: true,httpOnly: true})); // OK
195+
res.setHeader("Set-Cookie", cookie.serialize("authKey", makeAuthkey())); // NOT OK
196+
res.writeHead(200, { 'Content-Type': 'text/plain' });
197+
res.end('ok');
198+
});

0 commit comments

Comments
 (0)