diff --git a/extras/goRemoteAdmin/goRemoteAdmin.go b/extras/goRemoteAdmin/goRemoteAdmin.go index ac64a74..beb06b5 100644 --- a/extras/goRemoteAdmin/goRemoteAdmin.go +++ b/extras/goRemoteAdmin/goRemoteAdmin.go @@ -16,6 +16,7 @@ import ( "net/mail" "os" "reflect" + "strings" "time" "github.com/earthboundkid/versioninfo/v2" // mostly to get the git version of this build! @@ -27,6 +28,31 @@ import ( // No harm is done having just one context, which is simoly the background. var ctx = context.Background() +func redactXMLRPCPassword(requestBody string) string { + const startTag = "password" + startIdx := strings.Index(requestBody, startTag) + if startIdx == -1 { + return requestBody + } + + const openValueTag = "" + const closeValueTag = "" + + valueStart := strings.Index(requestBody[startIdx:], openValueTag) + if valueStart == -1 { + return requestBody + } + valueStart += startIdx + len(openValueTag) + + valueEnd := strings.Index(requestBody[valueStart:], closeValueTag) + if valueEnd == -1 { + return requestBody + } + valueEnd += valueStart + + return requestBody[:valueStart] + "***REDACTED***" + requestBody[valueEnd:] +} + type XmlRpcParameter struct { Parameter string `xmlrpc:"parameter"` Value string `xmlrpc:"string"` @@ -285,7 +311,7 @@ known to OpenSimulator. You can get a copy from