mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
recognize barrier guard where the result is stored in a variable
This commit is contained in:
@@ -438,7 +438,7 @@ private predicate barrierGuardBlocksNode(BarrierGuardNode guard, DataFlow::Node
|
||||
barrierGuardIsRelevant(guard) and
|
||||
exists(AccessPath p, BasicBlock bb, ConditionGuardNode cond, boolean outcome |
|
||||
nd = DataFlow::valueNode(p.getAnInstanceIn(bb)) and
|
||||
guard.getEnclosingExpr() = cond.getTest() and
|
||||
(guard.getEnclosingExpr() = cond.getTest() or guard = cond.getTest().flow().getALocalSource()) and
|
||||
outcome = cond.getOutcome() and
|
||||
barrierGuardBlocksAccessPath(guard, outcome, p, label) and
|
||||
cond.dominates(bb)
|
||||
|
||||
@@ -68,3 +68,20 @@ app.get('/user/:id', function(req, res) {
|
||||
|
||||
res.send(escapeHtml1(url)); // OK
|
||||
});
|
||||
|
||||
const matchHtmlRegExp = /["'&<>]/;
|
||||
function escapeHtml2 (string) {
|
||||
const str = '' + string;
|
||||
const match = matchHtmlRegExp.exec(str);
|
||||
|
||||
if (!match) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
app.get('/user/:id', function(req, res) {
|
||||
const url = req.params.id;
|
||||
|
||||
res.send(escapeHtml2(url)); // OK
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user