Skip to content

Commit

Permalink
Do Not Log Message Body (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
cassiascheffer authored Feb 6, 2024
1 parent 88a06bf commit 8bbf6e9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 5.2.14 - 2024-02-05
### Changed
- Do not log message body when publishing. Message bodies may have PII like email addresses in them.

## 5.2.13 - 2024-01-26
### Changed
- Updated dependencies
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
pheme (5.2.13)
pheme (5.2.14)
activesupport (>= 4)
aws-sdk-sns (~> 1.1)
aws-sdk-sqs (~> 1.3)
Expand Down
3 changes: 2 additions & 1 deletion lib/pheme/topic_publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def publish(message,
publisher: self.class.to_s,
topic_arn: topic_arn,
}
Pheme.logger.info(payload.to_json)

Pheme.logger.info(payload.except(:body).to_json)

sns_client.publish(
topic_arn: topic_arn,
Expand Down
2 changes: 1 addition & 1 deletion lib/pheme/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Pheme
VERSION = '5.2.13'.freeze
VERSION = '5.2.14'.freeze
end
27 changes: 27 additions & 0 deletions spec/topic_publisher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@
message_deduplication_id: nil,
message_group_id: nil,
})
expect(Pheme.logger).to(
receive(:info).with(
{
message: "ExamplePublisher publishing message to arn:aws:sns:whatever",
publisher: "ExamplePublisher",
topic_arn: "arn:aws:sns:whatever",
}.to_json,
).twice,
)
subject.publish_events
end

Expand All @@ -64,6 +73,15 @@
message_deduplication_id: nil,
message_group_id: nil,
})
expect(Pheme.logger).to(
receive(:info).with(
{
message: "Pheme::TopicPublisher publishing message to #{topic_arn}",
publisher: "Pheme::TopicPublisher",
topic_arn: topic_arn,
}.to_json,
),
)
subject.publish(message)
end

Expand All @@ -78,6 +96,15 @@
message_deduplication_id: nil,
message_group_id: nil,
})
expect(Pheme.logger).to(
receive(:info).with(
{
message: "Pheme::TopicPublisher publishing message to #{topic_arn}",
publisher: "Pheme::TopicPublisher",
topic_arn: topic_arn,
}.to_json,
),
)
subject.publish(message, sns_client: sns_client)
end
end
Expand Down

0 comments on commit 8bbf6e9

Please sign in to comment.