From ba352258a9a94aeb18f98528e6558cabbe6bec29 Mon Sep 17 00:00:00 2001 From: Matteo Cargnelutti Date: Tue, 29 Nov 2022 16:44:58 -0500 Subject: [PATCH] Limit "why" to 500 chars --- app/utils/SuccessLog.js | 4 +++- docs/utils/SuccessLog.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/utils/SuccessLog.js b/app/utils/SuccessLog.js index 297b566..2fdd9cc 100644 --- a/app/utils/SuccessLog.js +++ b/app/utils/SuccessLog.js @@ -70,7 +70,7 @@ export class SuccessLog { * - Updates `this.#hashes` (so it doesn't need to reload from file) * * @param {string} identifier - Can be an IP or access key - * @param {string} why - Reason for creating this archive + * @param {string} why - Reason for creating this archive (500 chars max). * @param {Buffer} pdfBytes - Used to store a SHA512 hash of the PDF that was delivered */ add(identifier, why, pdfBytes) { @@ -86,6 +86,8 @@ export class SuccessLog { .replaceAll("{", "") .replaceAll("}", ""); + why = why.substring(0, 500); + // Save entry const entry = `${new Date().toISOString()}\t${identifier}\t${why}\tsha512-${hash}\n`; fs.appendFileSync(SuccessLog.filepath, entry); diff --git a/docs/utils/SuccessLog.md b/docs/utils/SuccessLog.md index 5014a06..f9c69f3 100644 --- a/docs/utils/SuccessLog.md +++ b/docs/utils/SuccessLog.md @@ -53,7 +53,7 @@ Calculates hash of a PDF an: | Param | Type | Description | | --- | --- | --- | | identifier | string | Can be an IP or access key | -| why | string | Reason for creating this archive | +| why | string | Reason for creating this archive (500 chars max). | | pdfBytes | Buffer | Used to store a SHA512 hash of the PDF that was delivered |