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
+3 -3
View File
@@ -5,7 +5,7 @@ var express = require('express');
var router = express.Router();
const moment = require('moment');
const {marked} = require('marked');
const DOMPurify = require('isomorphic-dompurify');
const xss = require('xss');
const {InviteToken, PasswordResetToken} = require('./../models/token');
const {Tos} = require('../models/tos');
const conf = require('@simpleworkjs/conf');
@@ -47,7 +47,7 @@ router.get('/health', function(req, res) {
router.get('/tos', async function(req, res, next) {
try {
const tos = await Tos.getCurrent();
res.render('tos', {...values, tosHtml: DOMPurify.sanitize(marked(tos.content)), tosUpdatedOnFmt: moment(tos.updated_on, 'x').format('MMMM YYYY')});
res.render('tos', {...values, tosHtml: xss(marked(tos.content)), tosUpdatedOnFmt: moment(tos.updated_on, 'x').format('MMMM YYYY')});
} catch (error) {
next(error);
}
@@ -69,7 +69,7 @@ router.get('/invites', function(req, res) {
router.get('/onboarding', async function(req, res, next) {
try {
const tos = await Tos.getCurrent();
res.render('onboarding', {...values, tosHtml: DOMPurify.sanitize(marked(tos.content))});
res.render('onboarding', {...values, tosHtml: xss(marked(tos.content))});
} catch (error) {
next(error);
}