]> Untitled Git - lemmy-ui.git/commitdiff
Add Security.txt (#1408)
authorRobert C. Maehl <rcmaehl@aol.com>
Thu, 29 Jun 2023 03:10:13 +0000 (23:10 -0400)
committerGitHub <noreply@github.com>
Thu, 29 Jun 2023 03:10:13 +0000 (23:10 -0400)
* Create security-handler.ts

https://securitytxt.org/

* Add SecurityHandler

* Update security-handler.ts

* Update index.tsx

* Ensure external domain.tld is used

---------

Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>
src/server/handlers/security-handler.ts [new file with mode: 0644]
src/server/index.tsx

diff --git a/src/server/handlers/security-handler.ts b/src/server/handlers/security-handler.ts
new file mode 100644 (file)
index 0000000..ceece13
--- /dev/null
@@ -0,0 +1,11 @@
+import type { Response } from "express";
+
+export default async ({ res }: { res: Response }) => {
+  res.setHeader("content-type", "text/plain; charset=utf-8");
+
+  res.send(`Contact: mailto:security@lemmy.ml
+  Contact: mailto:admin@` + process.env.LEMMY_UI_LEMMY_EXTERNAL_HOST + `
+  Contact: mailto:security@` + process.env.LEMMY_UI_LEMMY_EXTERNAL_HOST + `
+  Expires: 2024-01-01T04:59:00.000Z
+  `);
+};
index aed8bca7cca193f84a2dff6ed7546783534b5529..e8966418c8467b381eedc48b1be1fc01e74997ab 100644 (file)
@@ -4,6 +4,7 @@ import path from "path";
 import process from "process";
 import CatchAllHandler from "./handlers/catch-all-handler";
 import ManifestHandler from "./handlers/manifest-handler";
+import SecurityHandler from "./handlers/security-handler";
 import RobotsHandler from "./handlers/robots-handler";
 import ServiceWorkerHandler from "./handlers/service-worker-handler";
 import ThemeHandler from "./handlers/theme-handler";
@@ -25,6 +26,7 @@ if (!process.env["LEMMY_UI_DISABLE_CSP"] && !process.env["LEMMY_UI_DEBUG"]) {
   server.use(setDefaultCsp);
 }
 
+server.get("/.well-known/security.txt", SecurityHandler);
 server.get("/robots.txt", RobotsHandler);
 server.get("/service-worker.js", ServiceWorkerHandler);
 server.get("/manifest.webmanifest", ManifestHandler);