MCPcopy Index your code
hub / github.com/simstudioai/sim / sanitizeEventData

Function sanitizeEventData

apps/sim/lib/core/security/redaction.ts:167–203  ·  view source on GitHub ↗
(event: any)

Source from the content-addressed store, hash-verified

165 * @returns Sanitized event data safe for external reporting
166 */
167export function sanitizeEventData(event: any): any {
168 if (event === null || event === undefined) {
169 return event
170 }
171
172 if (typeof event === 'string') {
173 return redactSensitiveValues(event)
174 }
175
176 if (typeof event !== 'object') {
177 return event
178 }
179
180 if (Array.isArray(event)) {
181 return event.map((item) => sanitizeEventData(item))
182 }
183
184 const sanitized: Record<string, unknown> = {}
185
186 for (const [key, value] of Object.entries(event)) {
187 if (isSensitiveKey(key)) {
188 continue
189 }
190
191 if (typeof value === 'string') {
192 sanitized[key] = redactSensitiveValues(value)
193 } else if (Array.isArray(value)) {
194 sanitized[key] = value.map((v) => sanitizeEventData(v))
195 } else if (value && typeof value === 'object') {
196 sanitized[key] = sanitizeEventData(value)
197 } else {
198 sanitized[key] = value
199 }
200 }
201
202 return sanitized
203}

Callers 1

redaction.test.tsFile · 0.90

Calls 2

redactSensitiveValuesFunction · 0.85
isSensitiveKeyFunction · 0.85

Tested by

no test coverage detected