From be434e07785b1d139cffe0d0b5252385ca2bec50 Mon Sep 17 00:00:00 2001 From: Lin Huiqing <37061143+LinHuiqing@users.noreply.github.com> Date: Thu, 12 Oct 2023 01:04:14 +0800 Subject: [PATCH] fix: add payment data to virus scanner endpoint (#6789) * fix: add payment data to virus scanner endpoint * chore: add missing callback deps * chore: replace stray 2.1s with constants * fix: shared/constants import --- frontend/src/features/public-form/PublicFormProvider.tsx | 9 ++++++++- .../encrypt-submission/encrypt-submission.middleware.ts | 7 +++++-- src/app/modules/submission/receiver/receiver.service.ts | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/src/features/public-form/PublicFormProvider.tsx b/frontend/src/features/public-form/PublicFormProvider.tsx index 82fd8ca277..fc3feeaffb 100644 --- a/frontend/src/features/public-form/PublicFormProvider.tsx +++ b/frontend/src/features/public-form/PublicFormProvider.tsx @@ -559,7 +559,10 @@ export const PublicFormProvider = ({ // TODO (FRM-1413): Move to main return statement once virus scanner has been fully rolled out if (enableEncryptionBoundaryShift && enableVirusScanner) { return submitStorageModeClearFormWithVirusScanningMutation.mutateAsync( - formData, + { + ...formData, + ...formPaymentData, + }, { onSuccess: ({ submissionId, @@ -676,11 +679,15 @@ export const PublicFormProvider = ({ submitEmailModeFormFetchMutation, submitEmailModeFormMutation, enableEncryptionBoundaryShift, + enableVirusScanner, + submitStorageModeClearFormMutation, + submitStorageModeFormMutation, submitStorageModeClearFormFetchMutation, submitStorageModeFormFetchMutation, navigate, formId, storePaymentMemory, + submitStorageModeClearFormWithVirusScanningMutation, ], ) diff --git a/src/app/modules/submission/encrypt-submission/encrypt-submission.middleware.ts b/src/app/modules/submission/encrypt-submission/encrypt-submission.middleware.ts index 5508f370c1..3ae11e7310 100644 --- a/src/app/modules/submission/encrypt-submission/encrypt-submission.middleware.ts +++ b/src/app/modules/submission/encrypt-submission/encrypt-submission.middleware.ts @@ -5,7 +5,10 @@ import { StatusCodes } from 'http-status-codes' import { chain, omit } from 'lodash' import { ok, okAsync, Result, ResultAsync } from 'neverthrow' -import { featureFlags } from '../../../../../shared/constants' +import { + featureFlags, + VIRUS_SCANNER_SUBMISSION_VERSION, +} from '../../../../../shared/constants' import { BasicField, StorageModeAttachment, @@ -317,7 +320,7 @@ export const scanAndRetrieveAttachments = async ( // should have virus scanning enabled. If not, skip this middleware. // Note: Version number is sent by the frontend and should only be >=2.1 if virus scanning is enabled on the frontend. - if (req.body.version < 2.1) { + if (req.body.version < VIRUS_SCANNER_SUBMISSION_VERSION) { logger.warn({ message: 'Virus scanner is not enabled on FE.', meta: logMeta, diff --git a/src/app/modules/submission/receiver/receiver.service.ts b/src/app/modules/submission/receiver/receiver.service.ts index 748038573a..9d50072d98 100644 --- a/src/app/modules/submission/receiver/receiver.service.ts +++ b/src/app/modules/submission/receiver/receiver.service.ts @@ -3,6 +3,7 @@ import { IncomingHttpHeaders } from 'http' import { err, ok, Result, ResultAsync } from 'neverthrow' import { FormResponseMode } from 'shared/types' +import { VIRUS_SCANNER_SUBMISSION_VERSION } from '../../../../../shared/constants' import { MB } from '../../../../../shared/constants/file' import { IAttachmentInfo } from '../../../../types' import { createLoggerWithLabel } from '../../../config/logger' @@ -159,7 +160,7 @@ export const configureMultipartReceiver = ( // TODO (FRM-1413): change to a version existence guardrail when // virus scanning has completed rollout, so that virus scanning // cannot be bypassed on storage mode submissions. - (body.version ?? 0) >= 2.1, + (body.version ?? 0) >= VIRUS_SCANNER_SUBMISSION_VERSION, ) return resolve(body) } else {