fix(security): close init config and parser-check redaction gaps

Strip model base URLs from viewer-accessible initialization config
responses and merge redacted parser secrets before engine check overrides
so admin test flows keep working after masked GET responses.
This commit is contained in:
wizardchen
2026-07-02 14:38:41 +08:00
committed by lyingbug
parent 1a264e09c1
commit fc64751f4e
6 changed files with 113 additions and 12 deletions
+14 -7
View File
@@ -326,15 +326,22 @@ func (h *SystemHandler) CheckParserEngines(c *gin.Context) {
c.JSON(400, gin.H{"code": 1, "msg": "请求体格式错误"})
return
}
overrides := body.ToOverridesMap()
var existing *types.ParserEngineConfig
var tenant *types.Tenant
if v, exists := c.Get(types.TenantInfoContextKey.String()); exists {
if tenant, ok := v.(*types.Tenant); ok && tenant != nil {
if creds := tenant.Credentials.GetWeKnoraCloud(); creds != nil {
if overrides == nil {
overrides = make(map[string]string)
}
overrides["weknoracloud_app_id"] = creds.AppID
if t, ok := v.(*types.Tenant); ok && t != nil {
tenant = t
existing = t.ParserEngineConfig
}
}
merged := types.MergeParserEngineConfigForUpdate(&body, existing)
overrides := merged.ToOverridesMap()
if tenant != nil {
if creds := tenant.Credentials.GetWeKnoraCloud(); creds != nil {
if overrides == nil {
overrides = make(map[string]string)
}
overrides["weknoracloud_app_id"] = creds.AppID
}
}
reader, docreaderAddr, docreaderTransport := h.resolveDocReader(c.Request.Context(), overrides)