mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
This query flags the cookie-parsing middleware in order to consolidate huge numbers of alerts into a single alert, which is more manageable. But simply annotating the cookie-parsing middleware with 'Alert' isn't a very useful, we want to annotate which middlewares are vulnerable.
23 lines
458 B
JavaScript
23 lines
458 B
JavaScript
const express = require('express')
|
|
const cookieParser = require('cookie-parser')
|
|
const csrf = require('csurf')
|
|
|
|
const app = express()
|
|
app.use(cookieParser()) // $ Alert
|
|
|
|
app.post('/unsafe', (req, res) => {
|
|
req.cookies.x;
|
|
}); // $ RelatedLocation
|
|
|
|
function middlewares() {
|
|
return express.Router()
|
|
.use(csrf({ cookie: true}))
|
|
.use('/', express.bodyParser());
|
|
}
|
|
|
|
app.use(middlewares());
|
|
|
|
app.post('/safe', (req, res) => { // OK
|
|
req.cookies.x;
|
|
});
|