strongmind-platform-sdk 3.27.0 → 3.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/platform_sdk/sentry/pii_scrubber.rb +72 -0
- data/lib/platform_sdk/sentry.rb +23 -0
- data/lib/platform_sdk/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86fe0c35c4207ef1d50c8dd075adbcc03b2565fd92ae8674117659671a1ac7db
|
|
4
|
+
data.tar.gz: eb012bca4d3cecac88a9c0f1858414f8363c0eb907dd6c593146c8df0706fea6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da6fb6510b8a2e86704b1837de5aa0998869bed9b49e45d8562bfddd867fcf5e219829336d695117f32b439a3fbd3a5b6cd890ad3361d41182cadd0062a6d3dd
|
|
7
|
+
data.tar.gz: 4513cc43b5a6b4420998a50aa4cdc2c2b9012915b7fb4e9591b7e702052ef9d2b5e5620ae42299ff3e03a2d34f45ae9386abe55427cfad58dbc924921218583d
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'active_support/parameter_filter'
|
|
4
|
+
|
|
5
|
+
module PlatformSdk
|
|
6
|
+
module Sentry
|
|
7
|
+
class PiiScrubber
|
|
8
|
+
DEFAULT_PII_FIELDS = [
|
|
9
|
+
:email, /\Aname\z/i, :first_name, :last_name, :student_name, :username,
|
|
10
|
+
:phone, :phone_number, :address, :street, :city, :zip, :postal_code,
|
|
11
|
+
:ssn, :social_security, :date_of_birth, :dob, :birthday,
|
|
12
|
+
:ip_address, /\Aip\z/i, :remote_ip,
|
|
13
|
+
:password, :password_confirmation, :token, :secret, :api_key, :authorization
|
|
14
|
+
].freeze
|
|
15
|
+
|
|
16
|
+
FILTERED = '[FILTERED]'
|
|
17
|
+
|
|
18
|
+
attr_reader :filter
|
|
19
|
+
|
|
20
|
+
def initialize(additional_fields: [])
|
|
21
|
+
fields = DEFAULT_PII_FIELDS + additional_fields
|
|
22
|
+
@filter = ActiveSupport::ParameterFilter.new(fields, mask: FILTERED)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def scrub_hash(hash)
|
|
26
|
+
return {} unless hash.is_a?(Hash)
|
|
27
|
+
|
|
28
|
+
filter.filter(hash)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def scrub_event(event)
|
|
32
|
+
event.user = scrub_user(event.user) if event.user.is_a?(Hash)
|
|
33
|
+
event.extra = scrub_hash(event.extra) if event.extra.is_a?(Hash)
|
|
34
|
+
event.contexts = scrub_hash(event.contexts) if event.contexts.is_a?(Hash)
|
|
35
|
+
|
|
36
|
+
scrub_request(event.request) if event.request
|
|
37
|
+
|
|
38
|
+
event
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
EMAIL_REGEX = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/
|
|
42
|
+
|
|
43
|
+
def scrub_breadcrumb(breadcrumb)
|
|
44
|
+
breadcrumb.data = scrub_hash(breadcrumb.data) if breadcrumb.data.is_a?(Hash)
|
|
45
|
+
breadcrumb.message = scrub_message(breadcrumb.message) if breadcrumb.message
|
|
46
|
+
|
|
47
|
+
breadcrumb
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
def scrub_message(message)
|
|
53
|
+
message.gsub(EMAIL_REGEX, FILTERED)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def scrub_user(user_hash)
|
|
57
|
+
id = user_hash[:id] || user_hash['id']
|
|
58
|
+
scrubbed = scrub_hash(user_hash)
|
|
59
|
+
scrubbed[:id] = id if user_hash.key?(:id)
|
|
60
|
+
scrubbed['id'] = id if user_hash.key?('id')
|
|
61
|
+
scrubbed
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def scrub_request(request)
|
|
65
|
+
request.data = scrub_hash(request.data) if request.data.is_a?(Hash)
|
|
66
|
+
request.headers = scrub_hash(request.headers) if request.headers.is_a?(Hash)
|
|
67
|
+
request.query_string = FILTERED if request.query_string
|
|
68
|
+
request.cookies = FILTERED if request.cookies
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
data/lib/platform_sdk/sentry.rb
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative 'sentry/pii_scrubber'
|
|
4
|
+
|
|
3
5
|
module PlatformSdk
|
|
4
6
|
module Sentry
|
|
7
|
+
def self.apply_pii_protection(config, additional_fields: [])
|
|
8
|
+
config.send_default_pii = false
|
|
9
|
+
config.include_local_variables = false
|
|
10
|
+
|
|
11
|
+
scrubber = PiiScrubber.new(additional_fields: additional_fields)
|
|
12
|
+
|
|
13
|
+
config.before_send = lambda do |event, _hint|
|
|
14
|
+
scrubber.scrub_event(event)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
config.before_breadcrumb = lambda do |breadcrumb, _hint|
|
|
18
|
+
scrubber.scrub_breadcrumb(breadcrumb)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
config.before_send_transaction = lambda do |event, _hint|
|
|
22
|
+
return nil if sentry_ignored(event)
|
|
23
|
+
|
|
24
|
+
scrubber.scrub_event(event)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
5
28
|
def self.sentry_ignored(event, ignored_urls = sentry_ignored_urls)
|
|
6
29
|
return false if event.transaction_info[:source] != :url
|
|
7
30
|
return true if ignored_urls.any? { |url| event.transaction.match?(url) }
|
data/lib/platform_sdk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: strongmind-platform-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.27.
|
|
4
|
+
version: 3.27.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Platform Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -297,6 +297,7 @@ files:
|
|
|
297
297
|
- lib/platform_sdk/power_school/client.rb
|
|
298
298
|
- lib/platform_sdk/power_school/special_program.rb
|
|
299
299
|
- lib/platform_sdk/sentry.rb
|
|
300
|
+
- lib/platform_sdk/sentry/pii_scrubber.rb
|
|
300
301
|
- lib/platform_sdk/sidekiq.rb
|
|
301
302
|
- lib/platform_sdk/sidekiq/ecs_task_protection_middleware.rb
|
|
302
303
|
- lib/platform_sdk/spec_support.rb
|