paketo-buildpacks / libpak

An opinionated extension to the libcnb Cloud Native Buildpack Library
Apache License 2.0
15 stars 17 forks source link

Obfuscate Credentials in Logs #312

Closed bitgully closed 6 months ago

bitgully commented 6 months ago

Summary

When using HTTP basic authentication credentials in binding URIs, this change obfuscates the username and password in the log entries.

Use Cases

When adding a binding for an artifact hosted in a private registry, it can be necessary to provide HTTP basic authentication credentials with the URI. This already works fine for downloading the desired dependency. However, when doing so, the username and password that are part of the URI, get printed to stdout in plain text at the moment. This PR should solve this issue by obfuscating the credentials. To make sure this change has no adverse side effects in case the provided URI is not well-formed, this implementation uses a regular expression instead of trying to parse the string to a "net/url" object.

Checklist

bitgully commented 6 months ago

Sure, they are okay. Thanks for the review.