Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement custom log fmter to strip APIKey #15

Merged
merged 1 commit into from
Sep 26, 2022
Merged

Conversation

wbollock
Copy link
Collaborator

NagiosXI seems to only support using an API key as a URL parameter, which leads to leakage on errors stemming from HTTP requests, such as the scrape.uri not being a Nagios endpoint.

This implements a custom logrus log formatter to strips the API key and replaces it with junk indicating the API key has been redacted - and therefore, keeping this keys out of logs.

Output:

/usr/local/bin/prometheus-nagios-exporter --nagios.scrape-uri google.com
INFO[0000] Using connection endpoint: google.com
FATA[0003] Get
"google.com/nagiosxi/api/v1/system/status?apikey=<redactedAPIKey>":
unsupported protocol scheme ""

Resolves #12

NagiosXI seems to only support using an API key as a URL parameter,
which leads to leakage on errors stemming from HTTP requests, such as
the scrape.uri not being a Nagios endpoint.

This implmenets a custom logrus log formatter to strips the API key and
replaces it with junk indicating the API key has been redacted - and
therefore, keeping this keys out of logs.

Output:
```
/usr/local/bin/prometheus-nagios-exporter --nagios.scrape-uri google.com
INFO[0000] Using connection endpoint: google.com
FATA[0003] Get
"google.com/nagiosxi/api/v1/system/status?apikey=<redactedAPIKey>":
unsupported protocol scheme ""
```
@wbollock wbollock merged commit 358859a into main Sep 26, 2022
@wbollock wbollock deleted the fix/api_leak branch September 26, 2022 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nagios API Key gets leaked in log messages
1 participant