From 533a36ffd88d33bf621dac3509c252c8431d7766 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 22 Jan 2024 09:06:45 -0500 Subject: [PATCH] Add a year to the build date in code. --- Dockerfile | 2 +- src/server/handlers/security-handler.ts | 10 +++++++++- src/shared/build-date.ts | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 11a6def2..95d96ca6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ COPY .git .git # Set UI version RUN echo "export const VERSION = '$(git describe --tag)';" > "src/shared/version.ts" -RUN echo "export const BUILD_DATE_ISO8601 = '$(date -d "+1 year" -u +"%Y-%m-%dT%H:%M:%SZ")';" > "src/shared/build-date.ts" +RUN echo "export const BUILD_DATE_ISO8601 = '$(date -u +"%Y-%m-%dT%H:%M:%SZ")';" > "src/shared/build-date.ts" RUN yarn --production --prefer-offline --network-timeout 100000 RUN yarn build:prod diff --git a/src/server/handlers/security-handler.ts b/src/server/handlers/security-handler.ts index b9b3bcdb..c1524ad1 100644 --- a/src/server/handlers/security-handler.ts +++ b/src/server/handlers/security-handler.ts @@ -1,12 +1,20 @@ import type { Response } from "express"; import { BUILD_DATE_ISO8601 } from "../../shared/build-date"; +import { parseISO } from "date-fns"; export default async ({ res }: { res: Response }) => { + const buildDatePlusYear = parseISO(BUILD_DATE_ISO8601); + + // Add a year to the build date + buildDatePlusYear.setFullYear(new Date().getFullYear() + 1); + + const yearFromNow = buildDatePlusYear.toISOString(); + res.setHeader("content-type", "text/plain; charset=utf-8"); res.send( `Contact: https://github.com/LemmyNet/lemmy-ui/security/advisories/new - Expires: ${BUILD_DATE_ISO8601} + Expires: ${yearFromNow} `, ); }; diff --git a/src/shared/build-date.ts b/src/shared/build-date.ts index d0aa547a..1cc3dc4e 100644 --- a/src/shared/build-date.ts +++ b/src/shared/build-date.ts @@ -1 +1 @@ -export const BUILD_DATE_ISO8601 = "2025-01-19T16:08:27Z"; +export const BUILD_DATE_ISO8601 = "2024-01-22T13:58:48Z";