This is an automated email from the ASF dual-hosted git repository.

hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-gateway.git


The following commit(s) were added to refs/heads/master by this push:
     new 1d7236e  fix(agents): align agent config listing with other endpoints
1d7236e is described below

commit 1d7236ee7a3bd623c06ad37653c0e4b00329975e
Author: Yang Luo <[email protected]>
AuthorDate: Sat Oct 10 02:19:05 2026 +0800

    fix(agents): align agent config listing with other endpoints
---
 agentconfig/mcp_item.go     | 23 ++++++++++++++++++++---
 controllers/agent_config.go |  4 ++++
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/agentconfig/mcp_item.go b/agentconfig/mcp_item.go
index f51c45c..3f37c1a 100644
--- a/agentconfig/mcp_item.go
+++ b/agentconfig/mcp_item.go
@@ -99,12 +99,29 @@ func commandOf(entry map[string]any) string {
        arguments, _ := entry["args"].([]any)
        parts := make([]string, 0, len(arguments)+1)
        parts = append(parts, command)
+       redactNext := false
        for _, argument := range arguments {
-               if text, ok := argument.(string); ok {
-                       parts = append(parts, text)
+               text, ok := argument.(string)
+               if !ok {
+                       continue
                }
+               if redactNext {
+                       redactNext = false
+                       parts = append(parts, "[REDACTED]")
+                       continue
+               }
+
+               flag, _, hasValue := strings.Cut(text, "=")
+               if strings.HasPrefix(flag, "-") && auditutil.SensitiveKey(flag) 
{
+                       if hasValue {
+                               text = flag + "=[REDACTED]"
+                       } else {
+                               redactNext = true
+                       }
+               }
+               parts = append(parts, text)
        }
-       return strings.Join(parts, " ")
+       return auditutil.SanitizeString(strings.Join(parts, " "))
 }
 
 func stringField(entry map[string]any, keys ...string) string {
diff --git a/controllers/agent_config.go b/controllers/agent_config.go
index 880cca8..6a28dc3 100644
--- a/controllers/agent_config.go
+++ b/controllers/agent_config.go
@@ -41,6 +41,10 @@ type agentConfigView struct {
 // GetAgentConfigs lists the skills, MCP servers and instructions of every 
agent
 // on this host whose configuration layout Gateway knows.
 func (c *ApiController) GetAgentConfigs() {
+       if c.RequireAdmin() {
+               return
+       }
+
        views, err := agentConfigViews(c.GetString("refresh") == "true")
        if err != nil {
                c.ResponseError(err.Error())


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to