mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
JavaScript: Update qhelp example for CleartextStorage.
This commit is contained in:
@@ -35,8 +35,7 @@ causing logged sensitive information to be stored as well.
|
||||
|
||||
<example>
|
||||
<p>
|
||||
The following example code stores user credentials (in this case, their account
|
||||
name) in a cookie in plain text:
|
||||
The following example code stores user credentials (in this case, their password) in a cookie in plain text:
|
||||
</p>
|
||||
<sample src="examples/CleartextStorage.js"/>
|
||||
<p>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
var express = require('express');
|
||||
|
||||
var app = express();
|
||||
app.get('/', function (req, res) {
|
||||
let accountName = req.param("AccountName");
|
||||
app.get('/remember-password', function (req, res) {
|
||||
let pw = req.param("current_password");
|
||||
// BAD: Setting a cookie value with cleartext sensitive data.
|
||||
res.cookie("AccountName", accountName);
|
||||
res.cookie("password", pw);
|
||||
});
|
||||
|
||||
@@ -8,8 +8,8 @@ function encrypt(text){
|
||||
}
|
||||
|
||||
var app = express();
|
||||
app.get('/', function (req, res) {
|
||||
let accountName = req.param("AccountName");
|
||||
app.get('/remember-password', function (req, res) {
|
||||
let pw = req.param("current_password");
|
||||
// GOOD: Encoding the value before setting it.
|
||||
res.cookie("AccountName", encrypt(accountName));
|
||||
res.cookie("password", encrypt(pw));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user