Skip to content

Commit

Permalink
add bytes check on jsonarray
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Dec 17, 2024
1 parent 63251dc commit c1de940
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ export const MAX_DOCS = 1000;
export const MAX_STRING_LENGTH = 100;
export const MAX_JSON_STRING_LENGTH = 10000;
export const MAX_TEMPLATE_STRING_LENGTH = 10000;
export const MAX_BYTES = 1048576; // OSD REST request payload size limit
export const MAX_WORKFLOW_NAME_TO_DISPLAY = 40;
export const WORKFLOW_NAME_REGEXP = RegExp('^[a-zA-Z0-9_-]*$');
export const EMPTY_MAP_ENTRY = { key: '', value: '' } as MapEntry;
Expand Down
11 changes: 10 additions & 1 deletion public/utils/config_to_schema_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
MAX_JSON_STRING_LENGTH,
MAX_TEMPLATE_STRING_LENGTH,
TRANSFORM_TYPE,
MAX_BYTES,
} from '../../common';

/*
Expand Down Expand Up @@ -173,7 +174,15 @@ export function getFieldSchema(
return false;
}
}
);
)
.test('jsonArray', `Too large`, (value) => {
try {
// @ts-ignore
return new TextEncoder().encode(value)?.length < MAX_BYTES;
} catch (error) {
return false;
}
});
break;
}
case 'jsonString': {
Expand Down

0 comments on commit c1de940

Please sign in to comment.