-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(virus-scanner): frontend orchestration #6767
Conversation
FRM-1303 FE orchestration for virus scanning
FRM-1292 Set up Frontend / Backend Integration for Virus Scanner
Refer to virus scanning design doc here: https://www.notion.so/opengov/Virus-Scanner-Design-Doc-5464ffd2af88420495209baa6a55e1bf?pvs=4 |
- chore: rm unused URL for clean bucket - fix: broken tests due to CSP change
FRM-1431 Change default behaviour for encryption boundary shift to `/storage`
Description Problem Some submissions are still being served to Solution If my guess regarding the issue is right, swapping default behaviour over to |
src/app/modules/submission/encrypt-submission/encrypt-submission.middleware.ts
Outdated
Show resolved
Hide resolved
src/app/modules/submission/encrypt-submission/encrypt-submission.middleware.ts
Outdated
Show resolved
Hide resolved
src/app/modules/submission/encrypt-submission/encrypt-submission.middleware.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @LinHuiqing ! lgtm other than some minor comments
will approve after we go through the tests 😃
src/app/modules/submission/encrypt-submission/encrypt-submission.middleware.ts
Outdated
Show resolved
Hide resolved
TODO:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! thanks @LinHuiqing
Note: In this PR, the virus scanner does not block submissions! Instead submissions are retried with the storage submission endpoint with fetch. The correct behaviour for when malicious files are part of a submission:
|
Problem
This is the 4th step of a 4-step effort (omg finally) to integrate the virus scanner into storage submission workflow after the encryption boundary shift (FRM-1292). Specifically, this PR implements the frontend orchestration required for the virus scanning flow, as specified in the design document by @tshuli.
Closes FRM-1303, closes FRM-1292
Another problem that this seeks to solve will be the small percentage of users still being directed to our old
/submission/encrypt
endpoint. The hypothesis is that this is due to the delay in instantiating growthbook before the endpoint is decided.Closes FRM-1431
Solution
The implementation is explained under Features below.
Note: if anything on the frontend integration fails, we will fallback to storage submissions using fetch.
Breaking Changes
Features:
PublicFormProvider.tsx
>handleSubmitForm
only triggers the storage submission flow with virus scanning if both encryption boundary shift and virus scanner have been enabled on the FE.mutations.ts
>usePublicFormMutations
>submitStorageModeClearFormWithVirusScanningMutation
orchestrates the whole flow with the following steps:createSubmission.ts
>createClearSubmissionWithVirusScanningFormData
is implemented to:answer
in attachment responses with the quarantine bucket keys.Improvements:
PublicFormProvider.tsx
>handleSubmitForm
: Move the use ofenableVirusScanner
straight to when the point where which mutation is used is decided. This is to address the possibility that the old storage submission endpoint is used because at the point at which the mutation was previously determined, growthbook might not have be instantiated yet, leading to the feature value defaulting to null.syncVirusScanning
was implemented (inencrypt-submission.middleware.ts
) to perform invocations synchronously in dev mode.shared/constants/form.ts
.useFeatureValue
to set the default feature value of the encryption boundary shift flag totrue
.Bug fixes:
virusScannerQuarantineS3BucketUrl
) instead of bucket name.Before & After Screenshots
BEFORE:
Refer to https://linear.app/ogp/issue/FRM-1303/fe-orchestration-for-virus-scanning#comment-f8959aa7
AFTER:
Note:
eicar.com.txt.zip
is a zipped test malicious file from eicar.Screen.Recording.2023-10-04.at.10.00.50.AM.mov
Tests
Preperation
eicar.com.txt
.featureflags
collection, set theencryption-boundary-shift-virus-scanner
flag as{ enabled: true }
.Test that virus scanner works
Test that BE feature flag works
featureflags
collection, set theencryption-boundary-shift-virus-scanner
flag as{ enabled: false }
.featureflags
collection, restore theencryption-boundary-shift-virus-scanner
flag as{ enabled: true }
.Test that the FE feature flag works
Test that FE falls back to submission without virus scan if virus scanning fails
VIRUS_SCANNER_LAMBDA_FUNCTION_NAME
) to an invalid function name and redeploy the app.function
virus-scanner-production-virus-scanner
virus-scanner-staging-virus-scanner
virus-scanner-uat-virus-scanner
Test that
/submission/storage
will be used if growthbook can't be instantiatedGROWTHBOOK_CLIENT_KEY
) to an invalid one.sdk-...
/submissions/storage
endpoint rather than/submissions/encrypt
.GROWTHBOOK_CLIENT_KEY
) to the appropriate one.Regression tests
Deploy Notes
featureflags
collection, set theencryption-boundary-shift-virus-scanner
flag as{ enabled: true }
.New GrowthBook flags:
Make sure that the
encryption-boundary-shift-virus-scanner
flag is disabled for prod before deployment. Rollout to 1% after deployment.encryption-boundary-shift-virus-scanner
: FE flag for virus scanner feature.New AWS configs:
Make sure that the prod quarantine S3 bucket has the right CORS policy as described below.
Quarantine bucket CORS policy: