dta.js 303 B

1234567891011121314
  1. 'use strict';
  2. // https://en.wikipedia.org/wiki/Directory_traversal_attack
  3. const isSafePath = require('../utils').isSafePath;
  4. module.exports = () => {
  5. return function dta(ctx, next) {
  6. const path = ctx.path;
  7. if (!isSafePath(path, ctx)) {
  8. ctx.throw(400);
  9. }
  10. return next();
  11. };
  12. };