mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
add express.csrf as an CSRF protecting middleware
This commit is contained in:
@@ -94,6 +94,8 @@ DataFlow::CallNode csrfMiddlewareCreation() {
|
||||
exists(result.getOptionArgument(0, "csrf"))
|
||||
or
|
||||
callee = DataFlow::moduleMember("lusca", "csrf")
|
||||
or
|
||||
callee = DataFlow::moduleMember("express", "csrf")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -73,3 +73,20 @@ var passport = require('passport');
|
||||
let newEmail = req.cookies["newEmail"];
|
||||
})
|
||||
});
|
||||
|
||||
(function () {
|
||||
|
||||
var app = express()
|
||||
|
||||
app.use(cookieParser())
|
||||
app.use(passport.authorize({ session: true }))
|
||||
|
||||
// Assume token is being set somewhere
|
||||
app.use(express.csrf({ value: function (request) {
|
||||
return request.headers['x-xsrf-token'];
|
||||
}}));
|
||||
|
||||
app.post('/changeEmail', function (req, res) {
|
||||
let newEmail = req.cookies["newEmail"];
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user