Skip to content

Commit 644ce30

Browse files
authored
Release v1.53.2 (#1228)
* fix: stop dd rum when user not logged in * chore: reduce custom API max payload size to 2 MB * chore: copy changes for for-each * chore: raise postman attachment size limit * chore: sanitise invalid chars from postman sms
2 parents 58e6986 + 6a57a01 commit 644ce30

File tree

26 files changed

+442
-35
lines changed

26 files changed

+442
-35
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@
111111
"tsconfig-paths": "^4.2.0",
112112
"type-fest": "4.10.3"
113113
},
114-
"version": "1.53.1"
114+
"version": "1.53.2"
115115
}

packages/backend/src/apps/custom-api/__tests__/common/size-monitor.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ describe('createSizeMonitor', () => {
5050
expect(mocks.warn).not.toHaveBeenCalled()
5151
})
5252

53-
it('errors when total size exceeds 20MB', async () => {
53+
it('errors when total size exceeds 2 MB', async () => {
5454
const monitor = createSizeMonitor()
55-
const overLimit = Buffer.alloc(20 * 1024 * 1024 + 1)
55+
const overLimit = Buffer.alloc(2 * 1024 * 1024 + 1)
5656
await expect(writeBuffers(monitor, [overLimit])).rejects.toMatchObject({
5757
name: 'AxiosError',
5858
isAxiosError: true,

packages/backend/src/apps/custom-api/common/size-monitor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import { Transform } from 'stream'
22

33
import logger from '@/helpers/logger'
44

5-
const MAX_SIZE_IN_MB = 20
5+
/**
6+
* NOTE: we set the limit to 2 MB to prevent abuse and protect frontend performance
7+
* for large JSON payloads
8+
*/
9+
const MAX_SIZE_IN_MB = 2
610
const MB = 1024 * 1024
7-
const MAX_CONTENT_LENGTH = MAX_SIZE_IN_MB * MB // 20MB
11+
const MAX_CONTENT_LENGTH = MAX_SIZE_IN_MB * MB
812
const MAX_COMPRESSION_RATIO = 100 // Maximum compression ratio to prevent gzip bombs
913

1014
const ERROR_RESPONSE = {

packages/backend/src/apps/postman-sms/actions/send-sms/schema.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import z from 'zod'
22

3+
import { replaceInvalidCharacters } from '@/helpers/replace-invalid-characters'
4+
35
// From Postman API docs
46
// https://postman-v2.guides.gov.sg/faq/postman-v2-api-faq/campaign-related-inquiries
57
export const MAX_SMS_CHARS = 1000
@@ -21,7 +23,8 @@ export const fieldSchema = z.object({
2123
.min(1, { message: 'Provide a non-empty message' })
2224
.max(MAX_SMS_CHARS, {
2325
message: `Message cannot exceed ${MAX_SMS_CHARS.toLocaleString()} characters`,
24-
}),
26+
})
27+
.transform((message) => replaceInvalidCharacters(message)),
2528
})
2629

2730
// Subset of the full reply; the other fields are not needed.

packages/backend/src/apps/toolbox/actions/for-each/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,21 @@ const action: IRawAction = {
2626
description: 'Repeat actions for each item',
2727
groupsLaterSteps: true,
2828
isNew: true,
29+
linkToGuide:
30+
'https://guide.plumber.gov.sg/user-guides/actions/for-each-item-coming-soon',
2931
arguments: [
3032
{
3133
label: 'Choose items',
3234
description:
33-
'Supported items include rows in Tiles/M365 Excel and FormSG checkboxes',
35+
'Items you can choose from: Find multiple rows, Find multiple table rows, or checkboxes/table from your form.',
3436
key: 'items',
3537
type: 'string' as const,
3638
required: true,
3739
variables: true,
3840
variableTypes: ['array', 'table'],
3941
singleVariableSelection: true,
42+
noVariablesMessage:
43+
' No variables available - add/check one of the following steps above: Find multiple rows, Find multiple table rows, or include a checkbox/table field in your FormSG.',
4044
},
4145
],
4246

packages/backend/src/graphql/__tests__/mutations/generate-presigned-post.itest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ vi.mock('@/helpers/s3', () => ({
2020
COMMON_S3_BUCKET: 'test-bucket',
2121
COMMON_S3_MOCK_FOLDER_PREFIX: 's3:test-bucket:mock/',
2222
parseS3Id: vi.fn(),
23-
MAX_FILE_SIZE: 1024 * 1024 * 2,
23+
MAX_FILE_SIZE: 1024 * 1024 * 10,
2424
ACCEPTED_FILE_TYPES: ['text/plain'],
2525
validateObjectKey: vi.fn((objectKey) => {
2626
const invalidCharacters = /[\\{}^`%~#<>|[\]]/
@@ -88,10 +88,10 @@ describe('generatePresignedPost', () => {
8888
userId: context.currentUser.id,
8989
})
9090

91-
const tooLargeParams = { ...VALID_PARAMS, size: 2 * 1024 * 1024 + 1 }
91+
const tooLargeParams = { ...VALID_PARAMS, size: 10 * 1024 * 1024 + 1 }
9292
await expect(
9393
generatePresignedPost(null, { input: tooLargeParams }, context),
94-
).rejects.toThrow('Size of attachment exceeds 2MB')
94+
).rejects.toThrow('Size of attachment exceeds 10MB')
9595
})
9696

9797
it.each([

packages/backend/src/graphql/mutations/generate-presigned-post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const generatePresignedPost: MutationResolvers['generatePresignedPost'] =
1717
const { flowId, filename, fileType, size, updatedAt } = params.input
1818

1919
if (size > MAX_FILE_SIZE) {
20-
throw new Error('Size of attachment exceeds 2MB')
20+
throw new Error('Size of attachment exceeds 10MB')
2121
}
2222
if (!ACCEPTED_FILE_TYPES.includes(fileType)) {
2323
throw new Error('Unsupported file type')

packages/backend/src/graphql/schema.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ type Action {
167167
groupsLaterSteps: Boolean
168168
setupMessage: SetupMessage
169169
isNew: Boolean
170+
linkToGuide: String
170171
substeps: [ActionSubstep]
171172
}
172173

@@ -206,6 +207,7 @@ type ActionSubstepArgument {
206207
hiddenIf: FieldVisibilityCondition
207208
addRowButtonText: String
208209
tooltipText: String
210+
noVariablesMessage: String
209211

210212
# Only for string and multiline
211213
singleVariableSelection: Boolean

0 commit comments

Comments
 (0)