diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f1b1f706965..911ff380873 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -619,6 +619,15 @@ importers: eslint-config-etherpad: specifier: ^5.0.3 version: 5.0.3(eslint@10.15.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@7.0.2) + eslint-plugin-express-security: + specifier: ^4.4.3 + version: 4.4.3(eslint@10.15.0(supports-color@8.1.1))(typescript@7.0.2) + eslint-plugin-node-security: + specifier: ^6.3.8 + version: 6.3.8(eslint@10.15.0(supports-color@8.1.1))(typescript@7.0.2) + eslint-plugin-secure-coding: + specifier: ^6.5.7 + version: 6.5.7(eslint@10.15.0(supports-color@8.1.1))(typescript@7.0.2) etherpad-cli-client: specifier: ^4.0.3 version: 4.0.3(supports-color@8.1.1) @@ -1129,6 +1138,21 @@ packages: '@iconify/types@2.0.0': resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} + '@interlace/eslint-devkit@2.5.2': + resolution: {integrity: sha512-Fq3MsmedSnr4nWNpMMFyT1L/9GPe1dv3o1iW9UrO8+Dq7I1M+pAOc3okWXv1vzTyNsvHN3b/LgI/Mqs/072a+g==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + peerDependencies: + eslint: ^8.40.0 || ^9.0.0 || ^10.0.0 + oxc-resolver: ^11.24.2 + typescript: '>=4.8.4' + peerDependenciesMeta: + eslint: + optional: true + oxc-resolver: + optional: true + typescript: + optional: true + '@internationalized/number@3.6.8': resolution: {integrity: sha512-8UmMFia46DUt+k97zKd9fKWXcWHR+k8ae3eYzILETuT2KbIvLyOfac7zesw+sJdRAAZ7Q9pM1Mk22aXp2LD0Ig==} @@ -3283,6 +3307,15 @@ packages: peerDependencies: eslint: '>=8' + eslint-plugin-express-security@4.4.3: + resolution: {integrity: sha512-vOmmfFJ8HXDjSZnq8H9YqOSb0HSLApcB36tKb6cPKGuFKEYnMlmUeX/GSU9wTXiLduCyHduwMkTX21Enqc8mRg==} + engines: {node: '>=22.13.0'} + peerDependencies: + eslint: ^8.40.0 || ^9.0.0 || ^10.0.0 + peerDependenciesMeta: + eslint: + optional: true + eslint-plugin-import@2.32.0: resolution: {integrity: sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==} engines: {node: '>=4'} @@ -3310,6 +3343,15 @@ packages: peerDependencies: eslint: '>=8.23.0' + eslint-plugin-node-security@6.3.8: + resolution: {integrity: sha512-cHnsuquJPccnzpya39o40xVgAfHLi6hBKnDAbyz1wCo4zRxZbPHAe6If0Qf+qTuM0JlLCIwjjffpVso2gpDOSg==} + engines: {node: '>=22.13.0'} + peerDependencies: + eslint: ^8.40.0 || ^9.0.0 || ^10.0.0 + peerDependenciesMeta: + eslint: + optional: true + eslint-plugin-prefer-arrow@1.2.3: resolution: {integrity: sha512-J9I5PKCOJretVuiZRGvPQxCbllxGAV/viI20JO3LYblAodofBxyMnZAJ+WGeClHgANnSJberTNoFWWjrWKBuXQ==} peerDependencies: @@ -3332,6 +3374,18 @@ packages: peerDependencies: eslint: ^9 || ^10 + eslint-plugin-secure-coding@6.5.7: + resolution: {integrity: sha512-fDAoNykcl4sO4KHMZcfFTR9gCWAF6wdd5X3AnsTWid6Sk+9Tk6HNla0NvqUeyG/2LkteUvkz6KcAqJIEsrfVWw==} + engines: {node: '>=22.13.0'} + peerDependencies: + eslint: ^8.40.0 || ^9.0.0 || ^10.0.0 + recheck: ^4.6.2 + peerDependenciesMeta: + eslint: + optional: true + recheck: + optional: true + eslint-plugin-you-dont-need-lodash-underscore@6.14.0: resolution: {integrity: sha512-3zkkU/O1agczP7szJGHmisZJS/AknfVl6mb0Zqoc95dvFsdmfK+cbhrn+Ffy0UWB1pgDJwQr7kIO3rPstWs3Dw==} engines: {node: '>=4.0'} @@ -6495,6 +6549,11 @@ snapshots: '@iconify/types@2.0.0': {} + '@interlace/eslint-devkit@2.5.2(eslint@10.15.0(supports-color@8.1.1))(typescript@7.0.2)': + optionalDependencies: + eslint: 10.15.0(supports-color@8.1.1) + typescript: 7.0.2 + '@internationalized/number@3.6.8': dependencies: '@swc/helpers': 0.5.23 @@ -8563,6 +8622,15 @@ snapshots: eslint: 10.15.0(supports-color@8.1.1) eslint-compat-utils: 0.5.1(eslint@10.15.0(supports-color@8.1.1)) + eslint-plugin-express-security@4.4.3(eslint@10.15.0(supports-color@8.1.1))(typescript@7.0.2): + dependencies: + '@interlace/eslint-devkit': 2.5.2(eslint@10.15.0(supports-color@8.1.1))(typescript@7.0.2) + optionalDependencies: + eslint: 10.15.0(supports-color@8.1.1) + transitivePeerDependencies: + - oxc-resolver + - typescript + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.74.0(eslint@10.15.0(supports-color@8.1.1))(supports-color@8.1.1)(typescript@7.0.2))(eslint-import-resolver-typescript@3.9.1)(eslint@10.15.0(supports-color@8.1.1))(supports-color@8.1.1): dependencies: '@rtsao/scc': 1.1.0 @@ -8620,6 +8688,15 @@ snapshots: transitivePeerDependencies: - typescript + eslint-plugin-node-security@6.3.8(eslint@10.15.0(supports-color@8.1.1))(typescript@7.0.2): + dependencies: + '@interlace/eslint-devkit': 2.5.2(eslint@10.15.0(supports-color@8.1.1))(typescript@7.0.2) + optionalDependencies: + eslint: 10.15.0(supports-color@8.1.1) + transitivePeerDependencies: + - oxc-resolver + - typescript + eslint-plugin-prefer-arrow@1.2.3(eslint@10.15.0(supports-color@8.1.1)): dependencies: eslint: 10.15.0(supports-color@8.1.1) @@ -8642,6 +8719,15 @@ snapshots: dependencies: eslint: 10.15.0(supports-color@8.1.1) + eslint-plugin-secure-coding@6.5.7(eslint@10.15.0(supports-color@8.1.1))(typescript@7.0.2): + dependencies: + '@interlace/eslint-devkit': 2.5.2(eslint@10.15.0(supports-color@8.1.1))(typescript@7.0.2) + optionalDependencies: + eslint: 10.15.0(supports-color@8.1.1) + transitivePeerDependencies: + - oxc-resolver + - typescript + eslint-plugin-you-dont-need-lodash-underscore@6.14.0: dependencies: kebab-case: 1.0.2 diff --git a/src/.eslintrc.cjs b/src/.eslintrc.cjs index 03d432edeff..1c81b3caee3 100644 --- a/src/.eslintrc.cjs +++ b/src/.eslintrc.cjs @@ -3,6 +3,10 @@ // This is a workaround for https://github.com/eslint/eslint/issues/3458 require('eslint-config-etherpad/patch/modern-module-resolution'); +// The recommended rule sets of the Interlace security plugins. Rules that do not fit this code +// today are turned off in the override below, each with its reason. +const recommended = (name) => require(`eslint-plugin-${name}`).configs.recommended.rules; + module.exports = { ignorePatterns: [ '/static/js/vendors/browser.js', @@ -10,10 +14,42 @@ module.exports = { '/static/js/vendors/gritter.js', '/static/js/vendors/html10n.js', '/static/js/vendors/jquery.js', + '/static/js/vendors/jquery.ts', '/static/js/vendors/nice-select.js', + // Minified third-party bundle; the security rules overflow the stack on it. + '/static/vendor/', '/tests/frontend/lib/', ], overrides: [ + { + files: [ + '**/*', + ], + excludedFiles: [ + '**/.eslintrc.*', + ], + plugins: ['node-security', 'express-security', 'secure-coding'], + rules: { + ...recommended('node-security'), + ...recommended('express-security'), + ...recommended('secure-coding'), + // node-security + 'node-security/no-arbitrary-file-access': 'off', // admin routes read paths from the settings file + 'node-security/no-toctou-vulnerability': 'off', // check-then-use on files the server itself owns + 'node-security/detect-eval-with-expression': 'off', // a Playwright test evaluates a fixed string + // express-security + 'express-security/require-express-body-parser-limits': 'off', // limits are set where the parsers are mounted + 'express-security/no-host-header-in-links': 'off', // links use the configured base URL, Host only as fallback + 'express-security/no-permissive-trust-proxy': 'off', // trustProxy is an opt-in setting for reverse proxies + 'express-security/no-exposed-debug-endpoints': 'off', // matches /stats and update-status routes, which are gated + 'express-security/no-insecure-cookie-options': 'off', // cookie flags follow the request's secure state + // secure-coding + 'secure-coding/no-unlimited-resource-allocation': 'off', // the admin read is bounded by the settings file + 'secure-coding/no-log-injection': 'off', // logged values are escaped by the logger + 'secure-coding/no-redos-vulnerable-regex': 'off', // the regex runs on sanitiser input of bounded size + 'secure-coding/no-sensitive-data-exposure': 'off', // test fixtures contain token-like strings on purpose + }, + }, { files: [ '**/.eslintrc.*', diff --git a/src/package.json b/src/package.json index af4ad69b9e4..e742f17c9dc 100644 --- a/src/package.json +++ b/src/package.json @@ -123,6 +123,9 @@ "chokidar": "^6.0.0", "eslint": "^10.15.0", "eslint-config-etherpad": "^5.0.3", + "eslint-plugin-express-security": "^4.4.3", + "eslint-plugin-node-security": "^6.3.8", + "eslint-plugin-secure-coding": "^6.5.7", "etherpad-cli-client": "^4.0.3", "mocha": "12.0.3", "mocha-froth": "^0.2.10",