-
Notifications
You must be signed in to change notification settings - Fork 3
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
Adapt default Rails logs to JSON format #17
Adapt default Rails logs to JSON format #17
Conversation
private | ||
|
||
def current_user(event_payload) | ||
user_klass = defined?(Carto::User) ? Carto::User : User |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows identifying the user to whom the email was sent both in CartoDB + Central
address.length < 8 || | ||
address.split('@').select(&:present?).size != 2 | ||
return '[ADDRESS]' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do a more aggressive obfuscation of email addresses in case they are very short. Check the specs for examples.
subject { Carto::Common::ActionMailerLogSubscriber.new } | ||
|
||
# Mocks CartoDB & Central users as they don't exist in the context of this gem | ||
class User |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this looks weird, but it's the best way I could think of to keep the logger specs in the common repository rather than duplicating it in both repos or adding a dependency to ActiveRecord
@@ -22,7 +22,9 @@ Gem::Specification.new do |spec| | |||
spec.add_dependency 'activesupport', '~> 4.2.11.3' | |||
spec.add_dependency 'argon2', '~> 2.0' | |||
|
|||
spec.add_development_dependency 'actionmailer', '~> 4.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for adding this dependency is that parent log subscriber class ActionMailer::LogSubscriber
is defined there.
@@ -29,13 +30,16 @@ def self.remove_existing_log_subscriptions | |||
unsubscribe(:action_view, subscriber) | |||
when ActionController::LogSubscriber | |||
unsubscribe(:action_controller, subscriber) | |||
when ActionMailer::LogSubscriber | |||
unsubscribe(:action_mailer, subscriber) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dettaches the default log subscriber (no JSON format, no user identification)
@rafatower this is part of a leapfrog. I still have pending some testing in staging before actually including this in CartoDB/Central: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
end | ||
|
||
address.split('@').map do |segment| | ||
segment[0] + '*' * (segment.length - 2) + segment[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when obfuscating, I'd use fixed size always
Story details: https://app.clubhouse.io/cartoteam/story/94485