From 8f02ef7e50f709ecb1b7ab55f1dfc867e41c6662 Mon Sep 17 00:00:00 2001 From: Ken Date: Wed, 3 Apr 2024 23:22:55 +0800 Subject: [PATCH 1/2] chore: bump version to v6.115.0 --- CHANGELOG.md | 20 ++++++++++++++++++-- frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81d3e1218d..7ea5b98785 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,27 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [v6.115.0](https://github.com/opengovsg/FormSG/compare/v6.114.1...v6.115.0) + +- fix: correct date validation for disabled fields [`#7240`](https://github.com/opengovsg/FormSG/pull/7240) +- build: merge release v6.114.1 back to develop [`#7228`](https://github.com/opengovsg/FormSG/pull/7228) +- chore(mrf): add announcement content [`#7229`](https://github.com/opengovsg/FormSG/pull/7229) +- chore(mrf): remove flags [`#7230`](https://github.com/opengovsg/FormSG/pull/7230) +- fix(mrf): workflow email UI cleanup [`#7215`](https://github.com/opengovsg/FormSG/pull/7215) +- fix: add secret key input mask [`#7227`](https://github.com/opengovsg/FormSG/pull/7227) +- fix: correcting submission button bug for MRF [`#7232`](https://github.com/opengovsg/FormSG/pull/7232) +- fix(mrf): handling for incorrect submission secret key in url query params [`#7219`](https://github.com/opengovsg/FormSG/pull/7219) +- chore(deps-dev): bump @types/json-stringify-safe from 5.0.0 to 5.0.3 [`#7235`](https://github.com/opengovsg/FormSG/pull/7235) +- fix(deps): bump nan from 2.17.0 to 2.19.0 [`#7212`](https://github.com/opengovsg/FormSG/pull/7212) +- chore(deps-dev): bump @types/express from 4.17.17 to 4.17.21 [`#7233`](https://github.com/opengovsg/FormSG/pull/7233) + #### [v6.114.1](https://github.com/opengovsg/FormSG/compare/v6.114.0...v6.114.1) +> 3 April 2024 + - build: release v6.114.0 [`#7226`](https://github.com/opengovsg/FormSG/pull/7226) -- fix: correcting submission button bug for MRF [`7342138`](https://github.com/opengovsg/FormSG/commit/73421387daf8f3a33c0030a43c81bb11190ee198) -- ref: genericize EndPageBlock [`017cfb3`](https://github.com/opengovsg/FormSG/commit/017cfb36457cbe293360c963f3d66257e5172907) +- chore: bump version to 6.114.1 [`c1c7ac2`](https://github.com/opengovsg/FormSG/commit/c1c7ac29e6bd8e2c3ab80b2fde22f84b778f1b4f) +- fix: correcting submission button bug for MRF [`96628aa`](https://github.com/opengovsg/FormSG/commit/96628aa3b4dd5abae00b429486139431a8b3bf05) #### [v6.114.0](https://github.com/opengovsg/FormSG/compare/v6.113.0...v6.114.0) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 7c218095f9..4e9b2b84af 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "form-frontend", - "version": "6.114.1", + "version": "6.115.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "form-frontend", - "version": "6.114.1", + "version": "6.115.0", "hasInstallScript": true, "dependencies": { "@chakra-ui/react": "^1.8.6", diff --git a/frontend/package.json b/frontend/package.json index 8923259d69..e05d4a5176 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "form-frontend", - "version": "6.114.1", + "version": "6.115.0", "homepage": ".", "private": true, "dependencies": { diff --git a/package-lock.json b/package-lock.json index 0c18280bc3..8902df59c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "FormSG", - "version": "6.114.1", + "version": "6.115.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "FormSG", - "version": "6.114.1", + "version": "6.115.0", "hasInstallScript": true, "dependencies": { "@aws-sdk/client-cloudwatch-logs": "^3.536.0", diff --git a/package.json b/package.json index 6c0662b5e3..adebd4a541 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "FormSG", "description": "Form Manager for Government", - "version": "6.114.1", + "version": "6.115.0", "homepage": "https://form.gov.sg", "authors": [ "FormSG " From 5a631f5591d279a8d527f469943dfec9e9fc4715 Mon Sep 17 00:00:00 2001 From: Ken Lee Shu Ming Date: Fri, 5 Apr 2024 13:48:18 +0800 Subject: [PATCH 2/2] fix(mrf): webhook be validation (#7247) * fix: add check to block webhooks updates on mrf fix: switch form to original form test: add test cases for mrf webhook blocks chore: update comments for clarity * chore: bump version to 6.115.1 --- CHANGELOG.md | 8 ++++ frontend/package-lock.json | 4 +- frontend/package.json | 2 +- package-lock.json | 4 +- package.json | 2 +- .../__tests__/admin-form.service.spec.ts | 42 +++++++++++++++++++ .../form/admin-form/admin-form.service.ts | 10 +++++ 7 files changed, 66 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ea5b98785..e9c65fbc99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,15 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [v6.115.1](https://github.com/opengovsg/FormSG/compare/v6.115.0...v6.115.1) + +- * chore(deps-dev): bump @types/express from 4.17.17 to 4.17.21 (#7233) [`#7241`](https://github.com/opengovsg/FormSG/pull/7241) +- fix: add check to block webhooks updates on mrf [`71ab0c5`](https://github.com/opengovsg/FormSG/commit/71ab0c592c15de5fddbffc9970a424af7a31d4ab) + #### [v6.115.0](https://github.com/opengovsg/FormSG/compare/v6.114.1...v6.115.0) +> 3 April 2024 + - fix: correct date validation for disabled fields [`#7240`](https://github.com/opengovsg/FormSG/pull/7240) - build: merge release v6.114.1 back to develop [`#7228`](https://github.com/opengovsg/FormSG/pull/7228) - chore(mrf): add announcement content [`#7229`](https://github.com/opengovsg/FormSG/pull/7229) @@ -17,6 +24,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - chore(deps-dev): bump @types/json-stringify-safe from 5.0.0 to 5.0.3 [`#7235`](https://github.com/opengovsg/FormSG/pull/7235) - fix(deps): bump nan from 2.17.0 to 2.19.0 [`#7212`](https://github.com/opengovsg/FormSG/pull/7212) - chore(deps-dev): bump @types/express from 4.17.17 to 4.17.21 [`#7233`](https://github.com/opengovsg/FormSG/pull/7233) +- chore: bump version to v6.115.0 [`8f02ef7`](https://github.com/opengovsg/FormSG/commit/8f02ef7e50f709ecb1b7ab55f1dfc867e41c6662) #### [v6.114.1](https://github.com/opengovsg/FormSG/compare/v6.114.0...v6.114.1) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 4e9b2b84af..3ccb61af8c 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "form-frontend", - "version": "6.115.0", + "version": "6.115.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "form-frontend", - "version": "6.115.0", + "version": "6.115.1", "hasInstallScript": true, "dependencies": { "@chakra-ui/react": "^1.8.6", diff --git a/frontend/package.json b/frontend/package.json index e05d4a5176..d854b2d7a3 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "form-frontend", - "version": "6.115.0", + "version": "6.115.1", "homepage": ".", "private": true, "dependencies": { diff --git a/package-lock.json b/package-lock.json index 8902df59c1..09486581fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "FormSG", - "version": "6.115.0", + "version": "6.115.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "FormSG", - "version": "6.115.0", + "version": "6.115.1", "hasInstallScript": true, "dependencies": { "@aws-sdk/client-cloudwatch-logs": "^3.536.0", diff --git a/package.json b/package.json index adebd4a541..97a10500a0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "FormSG", "description": "Form Manager for Government", - "version": "6.115.0", + "version": "6.115.1", "homepage": "https://form.gov.sg", "authors": [ "FormSG " diff --git a/src/app/modules/form/admin-form/__tests__/admin-form.service.spec.ts b/src/app/modules/form/admin-form/__tests__/admin-form.service.spec.ts index 2d78ff912f..2572faad4b 100644 --- a/src/app/modules/form/admin-form/__tests__/admin-form.service.spec.ts +++ b/src/app/modules/form/admin-form/__tests__/admin-form.service.spec.ts @@ -20,6 +20,7 @@ import { DatabaseError, DatabasePayloadSizeError, DatabaseValidationError, + MalformedParametersError, } from 'src/app/modules/core/core.errors' import { MissingUserError } from 'src/app/modules/user/user.errors' import * as UserService from 'src/app/modules/user/user.service' @@ -1419,6 +1420,47 @@ describe('admin-form.service', () => { ) expect(MOCK_UPDATED_FORM.getSettings).toHaveBeenCalledTimes(0) }) + + it('should not allow webhooks updates for MRF', async () => { + const MOCK_MULTIRESPONDENT_FORM = jest.mocked({ + _id: new ObjectId(), + status: FormStatus.Public, + responseMode: FormResponseMode.Multirespondent, + } as unknown as IPopulatedForm) + const settingsToUpdate: SettingsUpdateDto = { + webhook: { + url: 'does not matter', + }, + } + + // Act + const actualResult = await AdminFormService.updateFormSettings( + MOCK_MULTIRESPONDENT_FORM, + settingsToUpdate, + ) + + // Assert + expect(actualResult._unsafeUnwrapErr()).toBeInstanceOf( + MalformedParametersError, + ) + }) + + it('should allow webhooks updates for encrypt form', async () => { + const settingsToUpdate: SettingsUpdateDto = { + webhook: { + url: 'does not matter', + }, + } + + // Act + const actualResult = await AdminFormService.updateFormSettings( + MOCK_ENCRYPT_FORM, + settingsToUpdate, + ) + + // Assert + expect(actualResult.isOk()).toBeTrue() + }) }) describe('updateFormField', () => { diff --git a/src/app/modules/form/admin-form/admin-form.service.ts b/src/app/modules/form/admin-form/admin-form.service.ts index a2466c32b3..2263553309 100644 --- a/src/app/modules/form/admin-form/admin-form.service.ts +++ b/src/app/modules/form/admin-form/admin-form.service.ts @@ -1041,6 +1041,7 @@ export const updateFormCollaborators = ( * @param body the subset of form settings to update * @returns ok(updated form settings) on success * @returns err(MalformedParametersError) if auth type update is attempted for a multi-respondent form + * @returns err(MalformedParametersError) if webhook update is attempted for a multi-respondent form * @returns err(database errors) if db error is thrown during form setting update */ export const updateFormSettings = ( @@ -1063,6 +1064,15 @@ export const updateFormSettings = ( return errAsync(new MalformedParametersError('Invalid authentication type')) } + if ( + originalForm.responseMode === FormResponseMode.Multirespondent && + Boolean(body.webhook?.url) + ) { + return errAsync( + new MalformedParametersError('Webhooks not supported on MRF'), + ) + } + const dotifiedSettingsToUpdate = dotifyObject(body) const ModelToUse = getFormModelByResponseMode(originalForm.responseMode)