Skip to content

Commit 532067d

Browse files
committed
Handle possibly malicious inputs
1 parent d4c6d06 commit 532067d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/core/src/v3/isomorphic/duration.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
export function parseNaturalLanguageDuration(duration: string): Date | undefined {
2+
// Handle Code scanning alert #44 (https://github.com/triggerdotdev/trigger.dev/security/code-scanning/44) by limiting the length of the input string
3+
if (duration.length > 100) {
4+
return undefined;
5+
}
6+
27
// More flexible regex that captures all units individually regardless of order
38
const weekMatch = duration.match(/(\d+)w/);
49
const dayMatch = duration.match(/(\d+)d/);
@@ -73,6 +78,11 @@ export function safeParseNaturalLanguageDuration(duration: string): Date | undef
7378
// ... existing code ...
7479

7580
export function parseNaturalLanguageDurationAgo(duration: string): Date | undefined {
81+
// Handle Code scanning alert #44 (https://github.com/triggerdotdev/trigger.dev/security/code-scanning/44) by limiting the length of the input string
82+
if (duration.length > 100) {
83+
return undefined;
84+
}
85+
7686
// More flexible regex that captures all units individually regardless of order
7787
const weekMatch = duration.match(/(\d+)w/);
7888
const dayMatch = duration.match(/(\d+)d/);

0 commit comments

Comments
 (0)