From 02026ec6613a5fbc557d86d272a05df3cd85a811 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 19 Jan 2024 11:15:05 -0500 Subject: [PATCH] Adding an expires date, one year from build date. --- Dockerfile | 1 + dev.dockerfile | 3 ++- src/server/handlers/security-handler.ts | 3 ++- src/shared/build-date.ts | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 src/shared/build-date.ts diff --git a/Dockerfile b/Dockerfile index 54b6cc33..11a6def2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +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 yarn --production --prefer-offline --network-timeout 100000 RUN yarn build:prod diff --git a/dev.dockerfile b/dev.dockerfile index 42d12400..71aa6be6 100644 --- a/dev.dockerfile +++ b/dev.dockerfile @@ -24,6 +24,7 @@ COPY .git .git # Set UI version RUN echo "export const VERSION = 'dev';" > "src/shared/version.ts" +RUN echo "export const BUILD_DATE_ISO8601 = 'dev-build-date';" > "src/shared/build-date.ts" RUN yarn --prefer-offline RUN yarn build:dev @@ -34,4 +35,4 @@ COPY --from=builder /usr/src/app/node_modules /app/node_modules EXPOSE 1234 WORKDIR /app -CMD node dist/js/server.js \ No newline at end of file +CMD node dist/js/server.js diff --git a/src/server/handlers/security-handler.ts b/src/server/handlers/security-handler.ts index 03fcf31a..b9b3bcdb 100644 --- a/src/server/handlers/security-handler.ts +++ b/src/server/handlers/security-handler.ts @@ -1,11 +1,12 @@ import type { Response } from "express"; +import { BUILD_DATE_ISO8601 } from "../../shared/build-date"; export default async ({ res }: { res: Response }) => { res.setHeader("content-type", "text/plain; charset=utf-8"); res.send( `Contact: https://github.com/LemmyNet/lemmy-ui/security/advisories/new - Expires: 2025-01-01T04:59:00.000Z + Expires: ${BUILD_DATE_ISO8601} `, ); }; diff --git a/src/shared/build-date.ts b/src/shared/build-date.ts new file mode 100644 index 00000000..d0aa547a --- /dev/null +++ b/src/shared/build-date.ts @@ -0,0 +1 @@ +export const BUILD_DATE_ISO8601 = "2025-01-19T16:08:27Z";