From c011fe86b0fd020aec02d265d8dfb7a1c4020491 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 28 Nov 2025 11:16:11 -0800 Subject: [PATCH 1/4] fix(permissions): add client-side permissions validation to prevent unauthorized actions, upgraded custom tool modal --- apps/docs/components/icons.tsx | 2 +- apps/docs/content/docs/en/tools/zendesk.mdx | 1 + apps/sim/app/api/tools/custom/route.ts | 3 +- .../components/code-editor/code-editor.tsx | 92 +++---------- .../custom-tool-modal/custom-tool-modal.tsx | 126 +++++------------- .../components/context-menu/context-menu.tsx | 52 ++++++-- .../workspace-header/workspace-header.tsx | 4 + .../workspace-selector/workspace-selector.tsx | 12 +- apps/sim/components/icons.tsx | 2 +- 9 files changed, 118 insertions(+), 176 deletions(-) diff --git a/apps/docs/components/icons.tsx b/apps/docs/components/icons.tsx index 9c9f00984a..3c70935669 100644 --- a/apps/docs/components/icons.tsx +++ b/apps/docs/components/icons.tsx @@ -4330,7 +4330,7 @@ export function PylonIcon(props: SVGProps) { viewBox='0 0 26 26' fill='none' > - + resizeObserver.disconnect() }, [code]) - // Calculate the number of lines to determine gutter width const lineCount = code.split('\n').length const gutterWidth = calculateGutterWidth(lineCount) - // Render helpers const renderLineNumbers = () => { const numbers: ReactElement[] = [] let lineNumber = 1 @@ -127,88 +125,40 @@ export function CodeEditor({ return numbers } - // Custom highlighter that highlights environment variables and tags const customHighlight = (code: string) => { if (!highlightVariables || language !== 'javascript') { - // Use default Prism highlighting for non-JS or when variable highlighting is off return highlight(code, languages[language], language) } - // First, get the default Prism highlighting - let highlighted = highlight(code, languages[language], language) + const placeholders: Array<{ placeholder: string; original: string; type: 'env' | 'param' }> = [] + let processedCode = code - // Collect all syntax highlights to apply in a single pass - type SyntaxHighlight = { - start: number - end: number - replacement: string - } - const highlights: SyntaxHighlight[] = [] - - // Find environment variables with {{var_name}} syntax - let match - const envVarRegex = /\{\{([^}]+)\}\}/g - while ((match = envVarRegex.exec(highlighted)) !== null) { - highlights.push({ - start: match.index, - end: match.index + match[0].length, - replacement: `${match[0]}`, - }) - } - - // Find tags with syntax (not in HTML context) - if (!language.includes('html')) { - const tagRegex = /<([^>\s/]+)>/g - while ((match = tagRegex.exec(highlighted)) !== null) { - // Skip HTML comments and closing tags - if (!match[0].startsWith('