forked from knyar/prometheus-remote-backfill
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
promdump: redact passwords if specified in the --url flag
Parsing the URL into a net/url object gets us password redaction for free. Added a variable "parsedURL" to hold the parsed URL so we don't have to parse it twice. This was a choice between global variable ick and copy and pasting code ick. I opted for the global since they're used all over the place already anyway. Modified the "setupPromAPI" function to accept a URL instead of relying on the global "baseURL" string pointer. The Prometheus HTTP API still requires the URL to be passed in as a string, so the received URL is converted back into a string when instantiating the API. Added a second handler to the flag logger that parses the URL flag into a URL object, saves the URL to the global variable "parsedURL", then prints the flag to the log with any password specified in the userinfo component of the URL redacted using parsedURL.Redacted(). Updated all instances where the URL is logged to use parsedURL.Redacted().
- Loading branch information
1 parent
45e67b9
commit a45e4ba
Showing
1 changed file
with
30 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters