Files
wekan/models/lib/securityTxt.js
T
Lauri Ojansivu 1652c86f55 security.txt, the support period and an SBOM on every release, and an operator guide for GDPR, HIPAA and NIS2.
docs/Compliance/README.md WP-9 (rows 5.2, 5.3 and 5.5):

- /.well-known/security.txt and /security.txt (RFC 9116) are made from the
  security contact of Admin Panel / Settings / Legal pages: one Contact per
  address (an e-mail becomes mailto:, only https: URLs are kept), Expires
  180 days ahead, Canonical from ROOT_URL. 404 while no contact is set.
- SECURITY.md has a Support period: security fixes go into the newest
  release only, with no backports.
- The sbom job of release-all.yml writes the CycloneDX SBOM with npm's own
  npm sbom from the tagged package-lock.json and attaches it as
  wekan-<version>-sbom.cdx.json; Admin Panel / Settings / Version links the
  one of the running version. The Docker image attestation stays off.
- docs/Security/Compliance/README.md: what WeKan provides for GDPR, HIPAA,
  NIS2, ISO 27001 and SOC 2, the recommended settings, encryption at rest,
  break-glass access, and DPA/BAA notes.

Thanks to xet7 !
2026-11-24 03:44:47 +02:00

56 lines
2.3 KiB
JavaScript

'use strict';
// /.well-known/security.txt ([RFC9116]; docs/Compliance/README.md WP-9, row
// 7.5): where to report a vulnerability in THIS WeKan, from the security
// contact an administrator sets in Admin Panel / Settings / Legal pages.
// Nothing is served while no contact is set - a security.txt that points
// nowhere is worse than none.
//
// RFC 9116 requires Contact (a URI, one per line) and Expires (less than a
// year ahead, 2.5.5); the file is made on every request, so Expires is always
// EXPIRES_DAYS from now. Canonical names this file's own address.
//
// Pure: tests/securityTxt.test.cjs.
const EXPIRES_DAYS = 180;
const DAY_MS = 24 * 60 * 60 * 1000;
// One contact as an RFC 9116 URI: an e-mail address becomes mailto:, an
// https: (or mailto:/tel:) URI is kept, anything else is dropped.
function contactUri(value) {
const v = String(value || '').trim();
if (/^(https:\/\/|mailto:|tel:)[^\s<>"]+$/i.test(v)) return v;
if (/^[^\s@<>"]+@[^\s@<>"]+\.[^\s@<>"]+$/.test(v)) return `mailto:${v}`;
return '';
}
// The contacts in the field: several may be given, separated by commas,
// semicolons, spaces or new lines.
function contactUris(field) {
return [...new Set(String(field || '').split(/[\s,;]+/).map(contactUri).filter(Boolean))];
}
function securityTxt({ securityContact, rootUrl, now = Date.now() } = {}) {
const contacts = contactUris(securityContact);
if (contacts.length === 0) return null;
const lines = contacts.map(c => `Contact: ${c}`);
lines.push(`Expires: ${new Date(now + EXPIRES_DAYS * DAY_MS).toISOString().replace(/\.\d{3}Z$/, 'Z')}`);
const root = String(rootUrl || '').replace(/\/+$/, '');
if (/^https:\/\//i.test(root)) lines.push(`Canonical: ${root}/.well-known/security.txt`);
lines.push('Preferred-Languages: en');
return `${lines.join('\n')}\n`;
}
module.exports = { EXPIRES_DAYS, contactUri, contactUris, securityTxt };
// The release's SBOM (WP-9), attached to its GitHub Release by
// .github/workflows/release-all.yml as wekan-<version>-sbom.cdx.json; the
// version is package.json's, "v13.30.0" for the release v13.30.
function sbomUrl(version) {
const m = /^v?(\d+\.\d+)(?:\.0)?$/.exec(String(version || '').trim());
if (!m) return '';
return `https://github.com/wekan/wekan/releases/download/v${m[1]}/wekan-${m[1]}-sbom.cdx.json`;
}
module.exports.sbomUrl = sbomUrl;