memcached.go 856 B

12345678910111213141516171819
  1. // Unless explicitly stated otherwise all files in this repository are licensed
  2. // under the Apache License Version 2.0.
  3. // This product includes software developed at Datadog (https://www.datadoghq.com/).
  4. // Copyright 2016-present Datadog, Inc.
  5. package obfuscate
  6. import "strings"
  7. // ObfuscateMemcachedString obfuscates the Memcached command cmd.
  8. func (*Obfuscator) ObfuscateMemcachedString(cmd string) string {
  9. // All memcached commands end with new lines [1]. In the case of storage
  10. // commands, key values follow after. Knowing this, all we have to do
  11. // to obfuscate sensitive information is to remove everything that follows
  12. // a new line. For non-storage commands, this will have no effect.
  13. // [1]: https://github.com/memcached/memcached/blob/master/doc/protocol.txt
  14. out := strings.SplitN(cmd, "\r\n", 2)[0]
  15. return strings.TrimSpace(out)
  16. }