From b5dc59474b4617a3bce2e697314bce6959e0d9b8 Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Tue, 19 Nov 2024 17:35:08 -0700 Subject: [PATCH 1/8] remove trivy ignore not needed --- .trivyignore | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .trivyignore diff --git a/.trivyignore b/.trivyignore deleted file mode 100644 index 4cda780..0000000 --- a/.trivyignore +++ /dev/null @@ -1,7 +0,0 @@ -# See https://aquasecurity.github.io/trivy/v0.35/docs/vulnerability/examples/filter/ -# for more details -# e.g. -# CVE-2022-3996 - -# https://atlassian.thetradedesk.com/jira/browse/UID2-3953 -CVE-2022-25883 From fe4bd2d3038020bbeec1e1d4d5cf4a71ee486caa Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Mon, 25 Nov 2024 14:44:29 -0700 Subject: [PATCH 2/8] changes to not hardcode internal server error --- public/locales_euid/en.json | 2 ++ src/app.ts | 16 +++++++++++++++- views_uid2/error.hbs | 4 +++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/public/locales_euid/en.json b/public/locales_euid/en.json index cab02a8..5281c30 100644 --- a/public/locales_euid/en.json +++ b/public/locales_euid/en.json @@ -19,6 +19,8 @@ "Enter your verification code": "Enter your verification code", "Powered by": "Powered by", "Internal Server Error": "Internal Server Error", + "Page Not Found": "Page Not Found", + "Unknown Error": "Unknown Error", "euid-exit": "EXIT", "Welcome!": "Hello,", "Opt-Out": "Opt-Out", diff --git a/src/app.ts b/src/app.ts index 0f43de0..be5eb24 100644 --- a/src/app.ts +++ b/src/app.ts @@ -45,6 +45,7 @@ app.use(helmet()); app.use(i18n.init); app.use((req, _res, next) => { const locale = req.acceptsLanguages()[0] || LanguagesUID2.English; + console.log(locale) i18n.setLocale(locale); next(); }); @@ -75,7 +76,19 @@ app.use((err: any, req: Request, res: Response, _next: NextFunction) => { // render the error page res.status(err.status || 500); - res.render('error'); + + let errorPageMessage; + if (err.status === 404) { + errorPageMessage = res.__("Page Not Found") + } + else if (err.status === 500) { + errorPageMessage = res.__("Internal Server Error") + } + else { + errorPageMessage = res.__("Unknown Error") + } + + res.render('error', { errorPageMessage }); }); logger.log('info', `Using locales from ${LOCALE_FOLDER}`); @@ -100,6 +113,7 @@ Handlebars.registerHelper('__n', (s, count) => { return i18n.__n(s, count); }); + Handlebars.registerPartials(layoutPath); export default app; diff --git a/views_uid2/error.hbs b/views_uid2/error.hbs index e9910bb..f500d31 100644 --- a/views_uid2/error.hbs +++ b/views_uid2/error.hbs @@ -1 +1,3 @@ -

{{__ "Internal Server Error"}}

\ No newline at end of file +

+ {{errorPageMessage}} +

From 2371bddc2c4912b9585cbd07bc41c5e8b9a6950e Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Mon, 25 Nov 2024 14:45:56 -0700 Subject: [PATCH 3/8] added other json variables --- public/locales_uid2/en.json | 2 ++ public/locales_uid2/ja.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/public/locales_uid2/en.json b/public/locales_uid2/en.json index 3b7271a..0b469f0 100644 --- a/public/locales_uid2/en.json +++ b/public/locales_uid2/en.json @@ -16,6 +16,8 @@ "Enter your verification code": "Enter your verification code", "Powered by": "Powered by", "Internal Server Error": "Internal Server Error", + "Page Not Found": "Page Not Found", + "Unknown Error": "Unknown Error", "EXIT": "EXIT", "Welcome!": "Hello,", "Opt-Out": "Opt-Out", diff --git a/public/locales_uid2/ja.json b/public/locales_uid2/ja.json index bf3701e..41d8074 100644 --- a/public/locales_uid2/ja.json +++ b/public/locales_uid2/ja.json @@ -16,6 +16,8 @@ "Enter your verification code": "認証コードを入力してください", "Powered by": "Powered by", "Internal Server Error": "内部サーバーエラー", + "Page Not Found": "ページが見つかりません", + "Unknown Error": "不明なエラー", "EXIT": "終了", "Welcome!": "こんにちは", "Opt-Out": "オプトアウト", From e5ceab1c07fa4bce3840e474b101c6297656f44e Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Mon, 25 Nov 2024 14:46:21 -0700 Subject: [PATCH 4/8] remove log --- src/app.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app.ts b/src/app.ts index be5eb24..6b09486 100644 --- a/src/app.ts +++ b/src/app.ts @@ -45,7 +45,6 @@ app.use(helmet()); app.use(i18n.init); app.use((req, _res, next) => { const locale = req.acceptsLanguages()[0] || LanguagesUID2.English; - console.log(locale) i18n.setLocale(locale); next(); }); @@ -87,7 +86,7 @@ app.use((err: any, req: Request, res: Response, _next: NextFunction) => { else { errorPageMessage = res.__("Unknown Error") } - + res.render('error', { errorPageMessage }); }); From 0f3968ab6adeb6a7ccdb3e31bc1ee706d6514fec Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Mon, 25 Nov 2024 14:47:24 -0700 Subject: [PATCH 5/8] changed euid view --- src/app.ts | 1 - views_euid/error.hbs | 2 +- views_uid2/error.hbs | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/app.ts b/src/app.ts index 6b09486..338d60a 100644 --- a/src/app.ts +++ b/src/app.ts @@ -112,7 +112,6 @@ Handlebars.registerHelper('__n', (s, count) => { return i18n.__n(s, count); }); - Handlebars.registerPartials(layoutPath); export default app; diff --git a/views_euid/error.hbs b/views_euid/error.hbs index e9910bb..5a6022e 100644 --- a/views_euid/error.hbs +++ b/views_euid/error.hbs @@ -1 +1 @@ -

{{__ "Internal Server Error"}}

\ No newline at end of file +

{{errorPageMessage}}

diff --git a/views_uid2/error.hbs b/views_uid2/error.hbs index f500d31..5a6022e 100644 --- a/views_uid2/error.hbs +++ b/views_uid2/error.hbs @@ -1,3 +1 @@ -

- {{errorPageMessage}} -

+

{{errorPageMessage}}

From cb1621997440a3ab8f4fd866d84b2d20dd16fd59 Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Mon, 25 Nov 2024 14:51:35 -0700 Subject: [PATCH 6/8] fix lint errors --- src/app.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/app.ts b/src/app.ts index 338d60a..d961e14 100644 --- a/src/app.ts +++ b/src/app.ts @@ -78,13 +78,11 @@ app.use((err: any, req: Request, res: Response, _next: NextFunction) => { let errorPageMessage; if (err.status === 404) { - errorPageMessage = res.__("Page Not Found") - } - else if (err.status === 500) { - errorPageMessage = res.__("Internal Server Error") - } - else { - errorPageMessage = res.__("Unknown Error") + errorPageMessage = res.__('Page Not Found'); + } else if (err.status === 500) { + errorPageMessage = res.__('Internal Server Error'); + } else { + errorPageMessage = res.__('Unknown Error'); } res.render('error', { errorPageMessage }); From 9eec5ad1fe89e68c90b7cebc5dda9242928e6ab2 Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Mon, 25 Nov 2024 16:31:10 -0700 Subject: [PATCH 7/8] changed 500 to 400 errros --- src/routes/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/index.ts b/src/routes/index.ts index 0a039b6..68246f3 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -59,7 +59,7 @@ const handleEmailPromptSubmission: RequestHandler<{}, z.infer Date: Mon, 25 Nov 2024 18:45:54 -0700 Subject: [PATCH 8/8] change one error back to 500 --- src/routes/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/index.ts b/src/routes/index.ts index 68246f3..76279e5 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -158,7 +158,7 @@ const defaultRouteHandler: RequestHandler<{}, {}, z.infer