This file is indexed.

/usr/share/gocode/src/github.com/influxdata/influxdb/influxql/sanitize.go is in golang-github-influxdb-influxdb-dev 1.1.1+dfsg1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package influxql

import (
	"bytes"
	"regexp"
)

var (
	sanitizeSetPassword = regexp.MustCompile(`(?i)password\s+for[^=]*=\s+(["']?[^\s"]+["']?)`)

	sanitizeCreatePassword = regexp.MustCompile(`(?i)with\s+password\s+(["']?[^\s"]+["']?)`)
)

// Sanitize attempts to sanitize passwords out of a raw query.
// It looks for patterns that may be related to the SET PASSWORD and CREATE USER
// statements and will redact the password that should be there. It will attempt
// to redact information from common invalid queries too, but it's not guaranteed
// to succeed on improper queries.
//
// This function works on the raw query and attempts to retain the original input
// as much as possible.
func Sanitize(query string) string {
	if matches := sanitizeSetPassword.FindAllStringSubmatchIndex(query, -1); matches != nil {
		var buf bytes.Buffer
		i := 0
		for _, match := range matches {
			buf.WriteString(query[i:match[2]])
			buf.WriteString("[REDACTED]")
			i = match[3]
		}
		buf.WriteString(query[i:])
		query = buf.String()
	}

	if matches := sanitizeCreatePassword.FindAllStringSubmatchIndex(query, -1); matches != nil {
		var buf bytes.Buffer
		i := 0
		for _, match := range matches {
			buf.WriteString(query[i:match[2]])
			buf.WriteString("[REDACTED]")
			i = match[3]
		}
		buf.WriteString(query[i:])
		query = buf.String()
	}
	return query
}