security: swap sanitizer to xss and harden logging

- Replace isomorphic-dompurify with xss to avoid ESM-only transitive
  dependencies (jsdom/htmlparser2) that break the existing Jest test suite.
- Sanitize rendered docs and Terms-of-Service HTML via xss() in routes/docs.js
  and routes/index.js.
- Remove full-object new-user logging from models/user_ldap.js and reduce
  login-path error output to error.name/error.message only.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-18 23:03:33 -04:00
parent 07819a6254
commit cf80c966eb
5 changed files with 37 additions and 530 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ const fs = require('fs');
const path = require('path');
const router = require('express').Router();
const {marked} = require('marked');
const DOMPurify = require('isomorphic-dompurify');
const xss = require('xss');
const conf = require('@simpleworkjs/conf');
const buildInfo = require('../utils/build_info');
const rateLimit = require('../middleware/rate_limit');
@@ -132,7 +132,7 @@ router.get('/:slug', function(req, res, next) {
docs: docList,
currentSlug: req.params.slug,
docTitle: doc.title,
docHtml: DOMPurify.sanitize(fixDocLinks(fixImagePaths(marked(content)))),
docHtml: xss(fixDocLinks(fixImagePaths(marked(content)))),
});
} catch (error) {
next(error);