fix: masking value MCP env field (#5276)

This commit is contained in:
Faisal Amir 2025-06-15 16:18:43 +07:00 committed by GitHub
parent 9ab69b157b
commit d131752419
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,6 +22,13 @@ import { useToolApproval } from '@/hooks/useToolApproval'
import { toast } from 'sonner' import { toast } from 'sonner'
import { invoke } from '@tauri-apps/api/core' import { invoke } from '@tauri-apps/api/core'
// Function to mask sensitive values
const maskSensitiveValue = (value: string) => {
if (!value) return value
if (value.length <= 8) return '*'.repeat(value.length)
return value.slice(0, 4) + '*'.repeat(value.length - 8) + value.slice(-4)
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export const Route = createFileRoute(route.settings.mcp_servers as any)({ export const Route = createFileRoute(route.settings.mcp_servers as any)({
component: MCPServers, component: MCPServers,
@ -322,7 +329,10 @@ function MCPServers() {
<div className="break-all"> <div className="break-all">
Env:{' '} Env:{' '}
{Object.entries(config.env) {Object.entries(config.env)
.map(([key, value]) => `${key}=${value}`) .map(
([key, value]) =>
`${key}=${maskSensitiveValue(value)}`
)
.join(', ')} .join(', ')}
</div> </div>
)} )}