Skip to content

Commit 28f3401

Browse files
committed
fix(security): exclude trailing-dot refs and hoist tag pattern to module level
1 parent 6073770 commit 28f3401

File tree

1 file changed

+6
-5
lines changed
  • apps/sim/app/api/function/execute

1 file changed

+6
-5
lines changed

apps/sim/app/api/function/execute/route.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export const MAX_DURATION = 210
2727

2828
const logger = createLogger('FunctionExecuteAPI')
2929

30+
const TAG_PATTERN = new RegExp(
31+
`${REFERENCE.START}([a-zA-Z_](?:\\${REFERENCE.PATH_DELIMITER}[a-zA-Z0-9_]+|[a-zA-Z0-9_])*)${REFERENCE.END}`,
32+
'g'
33+
)
34+
3035
const E2B_JS_WRAPPER_LINES = 3
3136
const E2B_PYTHON_WRAPPER_LINES = 1
3237

@@ -493,11 +498,7 @@ function resolveTagVariables(
493498
let resolvedCode = code
494499
const undefinedLiteral = language === 'python' ? 'None' : 'undefined'
495500

496-
const tagPattern = new RegExp(
497-
`${REFERENCE.START}([a-zA-Z_][a-zA-Z0-9_${REFERENCE.PATH_DELIMITER}]*)${REFERENCE.END}`,
498-
'g'
499-
)
500-
const tagMatches = resolvedCode.match(tagPattern) || []
501+
const tagMatches = resolvedCode.match(TAG_PATTERN) || []
501502

502503
for (const match of tagMatches) {
503504
const tagName = match.slice(REFERENCE.START.length, -REFERENCE.END.length).trim()

0 commit comments

Comments
 (0)