mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
fix(vulns): fix various vulnerabilities and enhanced code security (#1611)
* fix(vulns): fix SSRF vulnerabilities * cleanup * cleanup * regen docs * remove unused deps * fix failing tests * cleanup * update deps * regen bun lock
This commit is contained in:
@@ -3,7 +3,19 @@ import type { CanvasLayout } from '@/tools/sharepoint/types'
|
||||
|
||||
const logger = createLogger('SharepointUtils')
|
||||
|
||||
// Extract readable text from SharePoint canvas layout
|
||||
function stripHtmlTags(html: string): string {
|
||||
let text = html
|
||||
let previous: string
|
||||
|
||||
do {
|
||||
previous = text
|
||||
text = text.replace(/<[^>]*>/g, '')
|
||||
text = text.replace(/[<>]/g, '')
|
||||
} while (text !== previous)
|
||||
|
||||
return text.trim()
|
||||
}
|
||||
|
||||
export function extractTextFromCanvasLayout(canvasLayout: CanvasLayout | null | undefined): string {
|
||||
logger.info('Extracting text from canvas layout', {
|
||||
hasCanvasLayout: !!canvasLayout,
|
||||
@@ -37,8 +49,7 @@ export function extractTextFromCanvasLayout(canvasLayout: CanvasLayout | null |
|
||||
})
|
||||
|
||||
if (webpart.innerHtml) {
|
||||
// Extract text from HTML, removing tags
|
||||
const text = webpart.innerHtml.replace(/<[^>]*>/g, '').trim()
|
||||
const text = stripHtmlTags(webpart.innerHtml)
|
||||
if (text) {
|
||||
textParts.push(text)
|
||||
logger.info('Extracted text', { text })
|
||||
@@ -50,7 +61,7 @@ export function extractTextFromCanvasLayout(canvasLayout: CanvasLayout | null |
|
||||
} else if (section.webparts) {
|
||||
for (const webpart of section.webparts) {
|
||||
if (webpart.innerHtml) {
|
||||
const text = webpart.innerHtml.replace(/<[^>]*>/g, '').trim()
|
||||
const text = stripHtmlTags(webpart.innerHtml)
|
||||
if (text) textParts.push(text)
|
||||
}
|
||||
}
|
||||
@@ -67,7 +78,6 @@ export function extractTextFromCanvasLayout(canvasLayout: CanvasLayout | null |
|
||||
return finalContent
|
||||
}
|
||||
|
||||
// Remove OData metadata from objects
|
||||
export function cleanODataMetadata<T>(obj: T): T {
|
||||
if (!obj || typeof obj !== 'object') return obj
|
||||
|
||||
@@ -77,7 +87,6 @@ export function cleanODataMetadata<T>(obj: T): T {
|
||||
|
||||
const cleaned: Record<string, unknown> = {}
|
||||
for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
|
||||
// Skip OData metadata keys
|
||||
if (key.includes('@odata')) continue
|
||||
|
||||
cleaned[key] = cleanODataMetadata(value)
|
||||
|
||||
Reference in New Issue
Block a user