diff --git a/src/core/common/utils/__snapshots__/purify.spec.ts.snap b/src/core/common/utils/__snapshots__/purify.spec.ts.snap index 657199578..88426454b 100644 --- a/src/core/common/utils/__snapshots__/purify.spec.ts.snap +++ b/src/core/common/utils/__snapshots__/purify.spec.ts.snap @@ -16,6 +16,13 @@ exports[`allows anchor tags and counts them correctly 1`] = ` " `; +exports[`allows mailto links 1`] = ` +Object { + "body": "email@example.com", + "linkCount": 1, +} +`; + exports[`sanitizes out attributes not allowed 1`] = ` Object { "body": "
Test
", diff --git a/src/core/common/utils/purify.spec.ts b/src/core/common/utils/purify.spec.ts index df113cee7..f8978da81 100644 --- a/src/core/common/utils/purify.spec.ts +++ b/src/core/common/utils/purify.spec.ts @@ -33,6 +33,15 @@ it("allows anchor links", () => { ).toMatchSnapshot(); }); +it("allows mailto links", () => { + expect( + sanitizeCommentBody( + DOMPurify, + 'email@example.com' + ) + ).toMatchSnapshot(); +}); + it("allows anchor tags and counts them correctly", () => { const { body, linkCount } = sanitizeCommentBody( DOMPurify, diff --git a/src/core/server/app/index.ts b/src/core/server/app/index.ts index a4bd51ce2..12373dd61 100644 --- a/src/core/server/app/index.ts +++ b/src/core/server/app/index.ts @@ -147,22 +147,28 @@ function configureApplication(options: AppOptions) { function configureApplicationHTTPS(options: AppOptions) { const { parent, config } = options; + const log = logger.child( + { env: config.get("env"), forceSSL: config.get("force_ssl") }, + true + ); + // If we're in production mode, configure some production security settings. if (config.get("env") === "production") { - if (config.get("disable_force_ssl")) { - logger.warn( - "SSL enforcement has been disabled in production, this should not be used except for testing" - ); - } else { + if (config.get("force_ssl")) { // Coral in production requires SSL, so we'll send the HSTS headers here as // well as force the use of HTTPS with a 301 redirect. parent.use( hsts({ - // We don't want to break existing other services that run with SSL. + // We don't want to break existing other services that don't run with + // SSL. includeSubDomains: false, }) ); parent.use(enforceHTTPSMiddleware()); + } else { + log.warn( + "FORCE_SSL=true should be set when a SSL terminating proxy has been configured" + ); } } } diff --git a/src/core/server/config.ts b/src/core/server/config.ts index 812a7e430..20ab8155e 100644 --- a/src/core/server/config.ts +++ b/src/core/server/config.ts @@ -269,13 +269,13 @@ const config = convict({ env: "PERSPECTIVE_TIMEOUT", arg: "perspectiveTimeout", }, - disable_force_ssl: { + force_ssl: { doc: - "Disables forcing SSL in production environments. Should not be used except for testing.", + "Forces SSL in production by redirecting all HTTP requests to HTTPS, and sending HSTS headers.", format: Boolean, default: false, - env: "DISABLE_FORCE_SSL", - arg: "disableForceSSL", + env: "FORCE_SSL", + arg: "forceSSL", }, });