mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/flagutil: do not expose sensitive info (passwords, keys and urls) at /flags page
This commit is contained in:
parent
8ad95f0db7
commit
8991c8b589
1 changed files with 5 additions and 0 deletions
|
@ -4,12 +4,17 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WriteFlags writes all the explicitly set flags to w.
|
// WriteFlags writes all the explicitly set flags to w.
|
||||||
func WriteFlags(w io.Writer) {
|
func WriteFlags(w io.Writer) {
|
||||||
flag.Visit(func(f *flag.Flag) {
|
flag.Visit(func(f *flag.Flag) {
|
||||||
|
lname := strings.ToLower(f.Name)
|
||||||
value := f.Value.String()
|
value := f.Value.String()
|
||||||
|
if IsSecretFlag(lname) {
|
||||||
|
value = "secret"
|
||||||
|
}
|
||||||
fmt.Fprintf(w, "-%s=%q\n", f.Name, value)
|
fmt.Fprintf(w, "-%s=%q\n", f.Name, value)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue