chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,36 @@
|
||||
package mcp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"academy/internal/types"
|
||||
secutils "academy/internal/utils"
|
||||
)
|
||||
|
||||
// ValidateServiceOutboundURLs validates every URL that the MCP transport or
|
||||
// OAuth discovery flow may contact. It is intentionally called both at
|
||||
// persistence boundaries and immediately before client construction so stale
|
||||
// or imported rows cannot bypass the current SSRF policy.
|
||||
func ValidateServiceOutboundURLs(service *types.MCPService) error {
|
||||
if service == nil {
|
||||
return fmt.Errorf("MCP service is required")
|
||||
}
|
||||
if service.URL != nil {
|
||||
serviceURL := strings.TrimSpace(*service.URL)
|
||||
if serviceURL != "" {
|
||||
if err := secutils.ValidateURLForSSRF(serviceURL); err != nil {
|
||||
return fmt.Errorf("MCP service URL failed SSRF validation: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
if service.AuthConfig != nil {
|
||||
metadataURL := strings.TrimSpace(service.AuthConfig.AuthServerMetadataURL)
|
||||
if metadataURL != "" {
|
||||
if err := secutils.ValidateURLForSSRF(metadataURL); err != nil {
|
||||
return fmt.Errorf("MCP OAuth metadata URL failed SSRF validation: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user