-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathtst.js
More file actions
55 lines (47 loc) · 1.75 KB
/
tst.js
File metadata and controls
55 lines (47 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: true}));
app.get("/login", (req, res) => {
const username = req.query.username; // OK - usernames are fine
const password = req.query.password; // $ Alert - password read
checkUser(username, password, (result) => {
res.send(result);
});
doThing(req.query.userId); // OK - userId
});
app.post("/login", (req, res) => {
const username = req.body.username; // OK - usernames are fine
const password = req.body.password; // OK - not a query parameter
checkUser(username, password, (result) => {
res.send(result);
});
});
app.get("/login2", (req, res) => {
const username = req.param('username'); // OK - usernames are fine
const password = req.param('password'); // $ Alert - password read
checkUser(username, password, (result) => {
res.send(result);
});
const myPassword = req.param('word'); // $ Alert - is used in a sensitive write below.
checkUser(username, myPassword, (result) => {
res.send(result);
});
});
app.get("/login", ({query}, res) => {
const username = query.username; // OK - usernames are fine
const currentPassword = query.current; // $ Alert - password read
checkUser(username, currentPassword, (result) => {
res.send(result);
});
});
app.get('/rest/user/change-password', mkHandler());
function mkHandler() {
return (req, res) => {
const username = req.param('username'); // OK - usernames are fine
const currentPassword = req.param('current'); // $ Alert - password read
checkUser(username, currentPassword, (result) => {
res.send(result);
});
}
}