notable 0.6.0 → 0.7.0
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/CHANGELOG.md +10 -0
- data/LICENSE.txt +1 -1
- data/README.md +0 -2
- data/lib/notable/engine.rb +3 -2
- data/lib/notable/job_extensions.rb +1 -2
- data/lib/notable/middleware.rb +13 -6
- data/lib/notable/throttle.rb +5 -1
- data/lib/notable/unpermitted_parameters.rb +1 -1
- data/lib/notable/version.rb +1 -1
- data/lib/notable.rb +2 -1
- metadata +8 -9
- data/lib/notable/debug_exceptions.rb +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ee82589dc34dfe74acd8795e2c089121c53eb41a00287f716ac52ea2ced317cc
|
|
4
|
+
data.tar.gz: c17132eb0b6332e7a48aa6a9618a40f838ccb21cd241da502f52621a2324ee73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9844579f84fa695a6f5333e279d3b51b2872dc915e2dd116250b6c9950a0b4dfe5cf0849120d0fbd4d2bb58990f07a168eedbe2959391bb925b7bf3b68d228e9
|
|
7
|
+
data.tar.gz: 44597e910a31f9c6c9d4905c428663d3b64c9c03b7bdb18cc300487d067b2171acda11eb70d1f7548e0b2aea413902342450fe95df7983a0ecd2d7156b5857cf
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 0.7.0 (2026-04-15)
|
|
2
|
+
|
|
3
|
+
- Enabled `scrub_invalid_utf8` by default
|
|
4
|
+
- Dropped support for Ruby < 3.3 and Rails < 7.2
|
|
5
|
+
|
|
6
|
+
## 0.6.1 (2026-02-07)
|
|
7
|
+
|
|
8
|
+
- Added `scrub_invalid_utf8` option
|
|
9
|
+
- Improved handling of invalid parameters
|
|
10
|
+
|
|
1
11
|
## 0.6.0 (2025-04-03)
|
|
2
12
|
|
|
3
13
|
- Dropped support for Ruby < 3.2 and Rails < 7.1
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# Notable
|
|
2
2
|
|
|
3
|
-
:star2: :star2: :star2:
|
|
4
|
-
|
|
5
3
|
Notable tracks notable requests and background jobs and stores them in your database. What makes a request or job notable? There are a number of default situations, but ultimately you decide what interests you.
|
|
6
4
|
|
|
7
5
|
By default, Notable tracks:
|
data/lib/notable/engine.rb
CHANGED
|
@@ -6,8 +6,9 @@ module Notable
|
|
|
6
6
|
if Notable.requests_enabled?
|
|
7
7
|
# insert in same place as request_store
|
|
8
8
|
app.config.middleware.insert_after ActionDispatch::RequestId, Notable::Middleware
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
ActionDispatch::DebugExceptions.register_interceptor do |request, exception|
|
|
10
|
+
request.env["action_dispatch.exception"] = exception
|
|
11
|
+
end
|
|
11
12
|
end
|
|
12
13
|
end
|
|
13
14
|
end
|
|
@@ -4,8 +4,7 @@ module Notable
|
|
|
4
4
|
|
|
5
5
|
included do
|
|
6
6
|
around_perform do |job, block|
|
|
7
|
-
|
|
8
|
-
Notable.track_job(job.class.name, job.job_id, job.queue_name, job.try(:enqueued_at), try(:notable_slow_job_threshold)) do
|
|
7
|
+
Notable.track_job(job.class.name, job.job_id, job.queue_name, job.enqueued_at, try(:notable_slow_job_threshold)) do
|
|
9
8
|
block.call
|
|
10
9
|
end
|
|
11
10
|
end
|
data/lib/notable/middleware.rb
CHANGED
|
@@ -10,8 +10,7 @@ module Notable
|
|
|
10
10
|
request_time = Notable.monotonic_time - start_time
|
|
11
11
|
|
|
12
12
|
Safely.safely do
|
|
13
|
-
if env["action_dispatch.exception"]
|
|
14
|
-
e = env["action_dispatch.exception"]
|
|
13
|
+
if (e = env["action_dispatch.exception"]) && (!defined?(ActionController::TooManyRequests) || !e.is_a?(ActionController::TooManyRequests))
|
|
15
14
|
message =
|
|
16
15
|
case status.to_i
|
|
17
16
|
when 404
|
|
@@ -37,11 +36,19 @@ module Notable
|
|
|
37
36
|
url = request.original_url
|
|
38
37
|
|
|
39
38
|
controller = env["action_controller.instance"]
|
|
40
|
-
action = controller && "#{controller.
|
|
41
|
-
params = controller && controller.request.filtered_parameters.except("controller", "action")
|
|
39
|
+
action = controller && "#{controller.controller_path}##{controller.action_name}"
|
|
40
|
+
params = controller && (controller.request.filtered_parameters.except("controller", "action") rescue nil)
|
|
42
41
|
|
|
43
42
|
user = Notable.user_method.call(env)
|
|
44
43
|
|
|
44
|
+
user_agent = request.user_agent
|
|
45
|
+
referrer = request.referer
|
|
46
|
+
|
|
47
|
+
if Notable.scrub_invalid_utf8
|
|
48
|
+
user_agent = user_agent&.scrub
|
|
49
|
+
referrer = referrer&.scrub
|
|
50
|
+
end
|
|
51
|
+
|
|
45
52
|
notes.each do |note|
|
|
46
53
|
ip = request.remote_ip
|
|
47
54
|
if ip && Notable.mask_ips
|
|
@@ -57,9 +64,9 @@ module Notable
|
|
|
57
64
|
params: params,
|
|
58
65
|
request_id: request.uuid,
|
|
59
66
|
ip: ip,
|
|
60
|
-
user_agent:
|
|
67
|
+
user_agent: user_agent,
|
|
61
68
|
url: url,
|
|
62
|
-
referrer:
|
|
69
|
+
referrer: referrer,
|
|
63
70
|
request_time: request_time
|
|
64
71
|
}
|
|
65
72
|
Notable.track_request_method.call(data, env)
|
data/lib/notable/throttle.rb
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
ActiveSupport::Notifications.subscribe "rack.attack" do |
|
|
1
|
+
ActiveSupport::Notifications.subscribe "rack.attack" do |_, _, _, _, req|
|
|
2
2
|
request = req.is_a?(Hash) ? req[:request] : req
|
|
3
3
|
|
|
4
4
|
if [:blacklist, :blocklist, :throttle].include?(request.env["rack.attack.match_type"])
|
|
5
5
|
Notable.track "Throttle", request.env["rack.attack.matched"]
|
|
6
6
|
end
|
|
7
7
|
end
|
|
8
|
+
|
|
9
|
+
ActiveSupport::Notifications.subscribe "rate_limit.action_controller" do |_, _, _, _, _|
|
|
10
|
+
Notable.track "Throttle", "throttle note"
|
|
11
|
+
end
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
ActiveSupport::Notifications.subscribe "unpermitted_parameters.action_controller" do |
|
|
1
|
+
ActiveSupport::Notifications.subscribe "unpermitted_parameters.action_controller" do |_, _, _, _, payload|
|
|
2
2
|
Notable.track "Unpermitted Parameters", payload[:keys].join(", ")
|
|
3
3
|
end
|
data/lib/notable/version.rb
CHANGED
data/lib/notable.rb
CHANGED
|
@@ -3,7 +3,6 @@ require "active_support"
|
|
|
3
3
|
require "safely/core"
|
|
4
4
|
|
|
5
5
|
# modules
|
|
6
|
-
require_relative "notable/debug_exceptions"
|
|
7
6
|
require_relative "notable/middleware"
|
|
8
7
|
require_relative "notable/throttle"
|
|
9
8
|
require_relative "notable/unpermitted_parameters"
|
|
@@ -22,6 +21,7 @@ module Notable
|
|
|
22
21
|
attr_accessor :user_method
|
|
23
22
|
attr_accessor :slow_request_threshold
|
|
24
23
|
attr_accessor :mask_ips
|
|
24
|
+
attr_accessor :scrub_invalid_utf8
|
|
25
25
|
|
|
26
26
|
# jobs
|
|
27
27
|
attr_accessor :track_job_method
|
|
@@ -31,6 +31,7 @@ module Notable
|
|
|
31
31
|
self.requests_enabled = true
|
|
32
32
|
self.jobs_enabled = true
|
|
33
33
|
self.mask_ips = false
|
|
34
|
+
self.scrub_invalid_utf8 = true
|
|
34
35
|
|
|
35
36
|
def self.requests_enabled?
|
|
36
37
|
enabled && requests_enabled
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: notable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -15,28 +15,28 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '7.
|
|
18
|
+
version: '7.2'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '7.
|
|
25
|
+
version: '7.2'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: safely_block
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '1'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
39
|
+
version: '1'
|
|
40
40
|
email: andrew@ankane.org
|
|
41
41
|
executables: []
|
|
42
42
|
extensions: []
|
|
@@ -52,7 +52,6 @@ files:
|
|
|
52
52
|
- lib/generators/notable/templates/create_jobs.rb.tt
|
|
53
53
|
- lib/generators/notable/templates/create_requests.rb.tt
|
|
54
54
|
- lib/notable.rb
|
|
55
|
-
- lib/notable/debug_exceptions.rb
|
|
56
55
|
- lib/notable/engine.rb
|
|
57
56
|
- lib/notable/job_extensions.rb
|
|
58
57
|
- lib/notable/middleware.rb
|
|
@@ -72,14 +71,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
72
71
|
requirements:
|
|
73
72
|
- - ">="
|
|
74
73
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '3.
|
|
74
|
+
version: '3.3'
|
|
76
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
76
|
requirements:
|
|
78
77
|
- - ">="
|
|
79
78
|
- !ruby/object:Gem::Version
|
|
80
79
|
version: '0'
|
|
81
80
|
requirements: []
|
|
82
|
-
rubygems_version:
|
|
81
|
+
rubygems_version: 4.0.6
|
|
83
82
|
specification_version: 4
|
|
84
83
|
summary: Track notable requests and background jobs
|
|
85
84
|
test_files: []
|