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

Redact logging of SMTP authentication data #338

Merged
merged 4 commits into from
Oct 15, 2024
Merged

Conversation

wneessen
Copy link
Owner

This PR updates the smtp.Client to redact any kind of SMTP authentication data when debug logging is enabled. This will be the new default, since we want to offer sane defaults. If the user needs to see the authentication data anyways, two new Client options have been added to enable the logging of auth data: WithLogAuthData() and Client.SetLogAuthData(bool).

Add a boolean flag `authIsActive` to manage redaction of sensitive authentication information in debug logs. When this flag is true, authentication details are replaced with `<auth redacted>`.
Added the `logAuthData` flag to enable conditional logging of SMTP authentication data. Introduced the `SetLogAuthData` method for clients to toggle this flag. Adjusted existing logging logic to respect this new configuration.
Added a new option and methods to enable logging of SMTP authentication data. Updated documentation to indicate caution when using this feature due to potential data protection risks.
Introduced TestClient_SetLogAuthData to verify the proper behavior of the SetLogAuthData method in both client and SMTP tests. This ensures that logAuthData is enabled or disabled as expected, increasing code reliability.
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 86.93%. Comparing base (8faac3d) to head (3234c13).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
client.go 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #338      +/-   ##
==========================================
+ Coverage   86.85%   86.93%   +0.08%     
==========================================
  Files          26       26              
  Lines        2350     2380      +30     
==========================================
+ Hits         2041     2069      +28     
- Misses        179      180       +1     
- Partials      130      131       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wneessen wneessen merged commit bb2fd0f into main Oct 15, 2024
32 checks passed
@wneessen wneessen deleted the feature/no_auth_logging branch October 15, 2024 18:26
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.

1 participant