notable 0.2.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +26 -3
- data/LICENSE.txt +1 -1
- data/README.md +46 -42
- data/app/models/notable/request.rb +1 -1
- data/lib/generators/notable/jobs_generator.rb +3 -20
- data/lib/generators/notable/requests_generator.rb +3 -20
- data/lib/generators/notable/templates/{create_jobs.rb → create_jobs.rb.tt} +2 -2
- data/lib/generators/notable/templates/{create_requests.rb → create_requests.rb.tt} +2 -5
- data/lib/notable.rb +39 -18
- data/lib/notable/engine.rb +3 -2
- data/lib/notable/job_extensions.rb +2 -2
- data/lib/notable/middleware.rb +8 -3
- data/lib/notable/throttle.rb +5 -3
- data/lib/notable/unpermitted_parameters.rb +1 -1
- data/lib/notable/unverified_request.rb +1 -3
- data/lib/notable/validation_errors.rb +0 -2
- data/lib/notable/version.rb +1 -1
- metadata +103 -25
- data/.gitignore +0 -14
- data/Gemfile +0 -4
- data/Rakefile +0 -1
- data/notable.gemspec +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dffa6e740a343d9d94cb914e52fa0627c33e42eaa20c9d9600365ff9fc70a4bf
|
4
|
+
data.tar.gz: 7928839098511ba32cb90106f5aa771e64886284f833da98eade40b5fa8637f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80f40eecda17a03ad548ac6faa75b049b83c3e57121a65418dbc0bc2508ad1a0c04424cfe551feb2283d0e366c44968732cd9e00d5df01faa23d1c02f663946f
|
7
|
+
data.tar.gz: 1a931594bca9c6c5907592542c40e1f87b3f92731086403c04ca7e486dcf7390a46a4d886b44cd00e9a0b19fed1f6882dbd5de6b7736ad9a7d34c8f11b5c699a
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,35 @@
|
|
1
|
-
## 0.
|
1
|
+
## 0.3.3 (2020-07-26)
|
2
|
+
|
3
|
+
- Added support for `queued_time` for Active Job 6
|
4
|
+
|
5
|
+
## 0.3.2 (2020-07-24)
|
6
|
+
|
7
|
+
- Added support for Rails API
|
8
|
+
- Fixed blocked requests with Rack::Attack
|
9
|
+
|
10
|
+
## 0.3.1 (2020-05-20)
|
11
|
+
|
12
|
+
- Fixed deprecation warning in Ruby 2.7
|
13
|
+
|
14
|
+
## 0.3.0 (2019-05-28)
|
15
|
+
|
16
|
+
- Added support for Rack::Attack 6
|
17
|
+
- Added job-specific slow job threshold
|
18
|
+
- Dropped support for Rails 4.2
|
19
|
+
|
20
|
+
## 0.2.2 (2018-05-18)
|
21
|
+
|
22
|
+
- Added `mask_ips` option
|
23
|
+
|
24
|
+
## 0.2.1 (2017-05-01)
|
2
25
|
|
3
26
|
- Added support for Rails 5.1
|
4
27
|
|
5
|
-
## 0.2.0
|
28
|
+
## 0.2.0 (2017-01-16)
|
6
29
|
|
7
30
|
- Switched to ActiveJob for jobs
|
8
31
|
- Fixed deprecation warnings
|
9
32
|
|
10
|
-
## 0.1.0
|
33
|
+
## 0.1.0 (2016-02-20)
|
11
34
|
|
12
35
|
- Launched
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
# Notable
|
2
2
|
|
3
|
-
:star2:
|
3
|
+
:star2: :star2: :star2:
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
#### Introducing Notable
|
8
|
-
|
9
|
-
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.
|
5
|
+
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.
|
10
6
|
|
11
7
|
By default, Notable tracks:
|
12
8
|
|
@@ -23,6 +19,8 @@ You can track custom notes as well.
|
|
23
19
|
|
24
20
|
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
|
25
21
|
|
22
|
+
[![Build Status](https://travis-ci.org/ankane/notable.svg?branch=master)](https://travis-ci.org/ankane/notable)
|
23
|
+
|
26
24
|
## Installation
|
27
25
|
|
28
26
|
Add this line to your application’s Gemfile:
|
@@ -36,31 +34,23 @@ And run:
|
|
36
34
|
```sh
|
37
35
|
rails generate notable:requests
|
38
36
|
rails generate notable:jobs
|
39
|
-
|
37
|
+
rails db:migrate
|
40
38
|
```
|
41
39
|
|
42
|
-
|
40
|
+
To explore the data, check out [Blazer](https://github.com/ankane/blazer).
|
43
41
|
|
44
|
-
##
|
42
|
+
## How It Works
|
45
43
|
|
46
44
|
A `Notable::Request` is created for:
|
47
45
|
|
48
46
|
- errors
|
49
47
|
- 404s
|
50
48
|
- slow requests
|
51
|
-
- timeouts
|
49
|
+
- timeouts from [Slowpoke](https://github.com/ankane/slowpoke)
|
52
50
|
- validation failures
|
53
|
-
- [CSRF failures](
|
51
|
+
- [CSRF failures](https://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf)
|
54
52
|
- unpermitted parameters
|
55
|
-
- blocked and throttled requests
|
56
|
-
|
57
|
-
For timeouts, use [Slowpoke](https://github.com/ankane/slowpoke).
|
58
|
-
|
59
|
-
For blocked and throttled requests, use [Rack Attack](https://github.com/kickstarter/rack-attack).
|
60
|
-
|
61
|
-
## Jobs
|
62
|
-
|
63
|
-
Wouldn’t it be great to have a record of exact jobs that fail?
|
53
|
+
- blocked and throttled requests from [Rack Attack](https://github.com/kickstarter/rack-attack)
|
64
54
|
|
65
55
|
A `Notable::Job` is created for:
|
66
56
|
|
@@ -68,19 +58,13 @@ A `Notable::Job` is created for:
|
|
68
58
|
- slow jobs
|
69
59
|
- validation failures
|
70
60
|
|
71
|
-
|
61
|
+
Create a custom note inside a request or job with:
|
72
62
|
|
73
63
|
```ruby
|
74
|
-
Notable.track(
|
64
|
+
Notable.track("Note Type", "Optional extra info")
|
75
65
|
```
|
76
66
|
|
77
|
-
|
78
|
-
|
79
|
-
```ruby
|
80
|
-
Notable.track("Auth Event", "Signed In")
|
81
|
-
```
|
82
|
-
|
83
|
-
## Customize
|
67
|
+
## Customization
|
84
68
|
|
85
69
|
Disable tracking in certain environments
|
86
70
|
|
@@ -93,23 +77,23 @@ Notable.enabled = Rails.env.production?
|
|
93
77
|
Set slow threshold
|
94
78
|
|
95
79
|
```ruby
|
96
|
-
Notable.slow_request_threshold = 5
|
80
|
+
Notable.slow_request_threshold = 5.seconds
|
97
81
|
```
|
98
82
|
|
99
83
|
Custom user method
|
100
84
|
|
101
85
|
```ruby
|
102
|
-
Notable.user_method =
|
86
|
+
Notable.user_method = lambda do |env|
|
103
87
|
env["warden"].try(:user) || env["action_controller.instance"].try(:current_visit)
|
104
|
-
|
88
|
+
end
|
105
89
|
```
|
106
90
|
|
107
91
|
Custom track method
|
108
92
|
|
109
93
|
```ruby
|
110
|
-
Notable.track_request_method =
|
94
|
+
Notable.track_request_method = lambda do |data, env|
|
111
95
|
Notable::Request.create!(data)
|
112
|
-
|
96
|
+
end
|
113
97
|
```
|
114
98
|
|
115
99
|
Skip tracking CSRF failures
|
@@ -118,26 +102,37 @@ Skip tracking CSRF failures
|
|
118
102
|
skip_before_action :track_unverified_request
|
119
103
|
```
|
120
104
|
|
105
|
+
Anonymize IP addresses
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
Notable.mask_ips = true
|
109
|
+
```
|
110
|
+
|
121
111
|
### Jobs
|
122
112
|
|
123
113
|
Set slow threshold
|
124
114
|
|
125
115
|
```ruby
|
126
|
-
Notable.slow_job_threshold = 60
|
116
|
+
Notable.slow_job_threshold = 60.seconds
|
127
117
|
```
|
128
118
|
|
129
|
-
|
119
|
+
To set a threshold for a specific job, use:
|
130
120
|
|
131
121
|
```ruby
|
132
|
-
|
133
|
-
|
134
|
-
|
122
|
+
class CustomJob < ApplicationJob
|
123
|
+
def notable_slow_job_threshold
|
124
|
+
5.minutes
|
125
|
+
end
|
126
|
+
end
|
135
127
|
```
|
136
128
|
|
137
|
-
|
129
|
+
Custom track method
|
138
130
|
|
139
|
-
|
140
|
-
|
131
|
+
```ruby
|
132
|
+
Notable.track_job_method = lambda do |data|
|
133
|
+
Notable::Job.create!(data)
|
134
|
+
end
|
135
|
+
```
|
141
136
|
|
142
137
|
## Contributing
|
143
138
|
|
@@ -147,3 +142,12 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
|
|
147
142
|
- Fix bugs and [submit pull requests](https://github.com/ankane/notable/pulls)
|
148
143
|
- Write, clarify, or fix documentation
|
149
144
|
- Suggest or add new features
|
145
|
+
|
146
|
+
To get started with development:
|
147
|
+
|
148
|
+
```sh
|
149
|
+
git clone https://github.com/ankane/notable.git
|
150
|
+
cd notable
|
151
|
+
bundle install
|
152
|
+
bundle exec rake test
|
153
|
+
```
|
@@ -2,7 +2,7 @@ module Notable
|
|
2
2
|
class Request < ActiveRecord::Base
|
3
3
|
self.table_name = "notable_requests"
|
4
4
|
|
5
|
-
belongs_to :user,
|
5
|
+
belongs_to :user, polymorphic: true, optional: true
|
6
6
|
serialize :params, JSON
|
7
7
|
end
|
8
8
|
end
|
@@ -1,34 +1,17 @@
|
|
1
|
-
# taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb
|
2
|
-
require "rails/generators"
|
3
|
-
require "rails/generators/migration"
|
4
|
-
require "active_record"
|
5
1
|
require "rails/generators/active_record"
|
6
2
|
|
7
3
|
module Notable
|
8
4
|
module Generators
|
9
5
|
class JobsGenerator < Rails::Generators::Base
|
10
|
-
include
|
11
|
-
|
12
|
-
source_root File.expand_path("../templates", __FILE__)
|
13
|
-
|
14
|
-
# Implement the required interface for Rails::Generators::Migration.
|
15
|
-
def self.next_migration_number(dirname) #:nodoc:
|
16
|
-
next_migration_number = current_migration_number(dirname) + 1
|
17
|
-
if ActiveRecord::Base.timestamped_migrations
|
18
|
-
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
19
|
-
else
|
20
|
-
"%.3d" % next_migration_number
|
21
|
-
end
|
22
|
-
end
|
6
|
+
include ActiveRecord::Generators::Migration
|
7
|
+
source_root File.join(__dir__, "templates")
|
23
8
|
|
24
9
|
def copy_migration
|
25
10
|
migration_template "create_jobs.rb", "db/migrate/create_notable_jobs.rb", migration_version: migration_version
|
26
11
|
end
|
27
12
|
|
28
13
|
def migration_version
|
29
|
-
|
30
|
-
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
31
|
-
end
|
14
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
32
15
|
end
|
33
16
|
end
|
34
17
|
end
|
@@ -1,34 +1,17 @@
|
|
1
|
-
# taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb
|
2
|
-
require "rails/generators"
|
3
|
-
require "rails/generators/migration"
|
4
|
-
require "active_record"
|
5
1
|
require "rails/generators/active_record"
|
6
2
|
|
7
3
|
module Notable
|
8
4
|
module Generators
|
9
5
|
class RequestsGenerator < Rails::Generators::Base
|
10
|
-
include
|
11
|
-
|
12
|
-
source_root File.expand_path("../templates", __FILE__)
|
13
|
-
|
14
|
-
# Implement the required interface for Rails::Generators::Migration.
|
15
|
-
def self.next_migration_number(dirname) #:nodoc:
|
16
|
-
next_migration_number = current_migration_number(dirname) + 1
|
17
|
-
if ActiveRecord::Base.timestamped_migrations
|
18
|
-
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
19
|
-
else
|
20
|
-
"%.3d" % next_migration_number
|
21
|
-
end
|
22
|
-
end
|
6
|
+
include ActiveRecord::Generators::Migration
|
7
|
+
source_root File.join(__dir__, "templates")
|
23
8
|
|
24
9
|
def copy_migration
|
25
10
|
migration_template "create_requests.rb", "db/migrate/create_notable_requests.rb", migration_version: migration_version
|
26
11
|
end
|
27
12
|
|
28
13
|
def migration_version
|
29
|
-
|
30
|
-
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
31
|
-
end
|
14
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
32
15
|
end
|
33
16
|
end
|
34
17
|
end
|
@@ -6,8 +6,8 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
|
|
6
6
|
t.text :job
|
7
7
|
t.string :job_id
|
8
8
|
t.string :queue
|
9
|
-
t.
|
10
|
-
t.
|
9
|
+
t.float :runtime
|
10
|
+
t.float :queued_time
|
11
11
|
t.timestamp :created_at
|
12
12
|
end
|
13
13
|
end
|
@@ -3,8 +3,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
|
|
3
3
|
create_table :notable_requests do |t|
|
4
4
|
t.string :note_type
|
5
5
|
t.text :note
|
6
|
-
t.
|
7
|
-
t.string :user_type
|
6
|
+
t.references :user, polymorphic: true
|
8
7
|
t.text :action
|
9
8
|
t.integer :status
|
10
9
|
t.text :url
|
@@ -13,10 +12,8 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
|
|
13
12
|
t.text :user_agent
|
14
13
|
t.text :referrer
|
15
14
|
t.text :params
|
16
|
-
t.
|
15
|
+
t.float :request_time
|
17
16
|
t.timestamp :created_at
|
18
17
|
end
|
19
|
-
|
20
|
-
add_index :notable_requests, [:user_id, :user_type]
|
21
18
|
end
|
22
19
|
end
|
data/lib/notable.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require "request_store"
|
1
|
+
# dependencies
|
2
|
+
require "active_support"
|
4
3
|
require "safely/core"
|
5
|
-
require "action_dispatch/middleware/debug_exceptions"
|
6
|
-
|
7
|
-
# middleware
|
8
|
-
require "notable/middleware"
|
9
|
-
require "notable/engine" if defined?(Rails)
|
10
4
|
|
11
|
-
#
|
12
|
-
require "notable/unpermitted_parameters"
|
13
|
-
require "notable/unverified_request"
|
14
|
-
require "notable/validation_errors"
|
5
|
+
# modules
|
15
6
|
require "notable/debug_exceptions"
|
7
|
+
require "notable/middleware"
|
16
8
|
require "notable/throttle"
|
9
|
+
require "notable/unpermitted_parameters"
|
10
|
+
require "notable/version"
|
11
|
+
|
12
|
+
require "notable/engine" if defined?(Rails)
|
17
13
|
|
18
14
|
module Notable
|
19
15
|
class << self
|
@@ -25,6 +21,7 @@ module Notable
|
|
25
21
|
attr_accessor :track_request_method
|
26
22
|
attr_accessor :user_method
|
27
23
|
attr_accessor :slow_request_threshold
|
24
|
+
attr_accessor :mask_ips
|
28
25
|
|
29
26
|
# jobs
|
30
27
|
attr_accessor :track_job_method
|
@@ -33,6 +30,7 @@ module Notable
|
|
33
30
|
self.enabled = true
|
34
31
|
self.requests_enabled = true
|
35
32
|
self.jobs_enabled = true
|
33
|
+
self.mask_ips = false
|
36
34
|
|
37
35
|
def self.requests_enabled?
|
38
36
|
enabled && requests_enabled
|
@@ -43,7 +41,7 @@ module Notable
|
|
43
41
|
end
|
44
42
|
|
45
43
|
# requests
|
46
|
-
self.track_request_method = -> (data,
|
44
|
+
self.track_request_method = -> (data, _) { Notable::Request.create!(data) }
|
47
45
|
self.user_method = -> (env) { env["warden"].user if env["warden"] }
|
48
46
|
self.slow_request_threshold = 5
|
49
47
|
|
@@ -52,7 +50,7 @@ module Notable
|
|
52
50
|
self.slow_job_threshold = 60
|
53
51
|
|
54
52
|
def self.track(note_type, note = nil)
|
55
|
-
|
53
|
+
notes << {note_type: note_type, note: note}
|
56
54
|
end
|
57
55
|
|
58
56
|
def self.track_error(e)
|
@@ -60,17 +58,19 @@ module Notable
|
|
60
58
|
end
|
61
59
|
|
62
60
|
def self.notes
|
63
|
-
|
61
|
+
Thread.current[:notable_notes] ||= []
|
64
62
|
end
|
65
63
|
|
66
64
|
def self.clear_notes
|
67
|
-
|
65
|
+
Thread.current[:notable_notes] = nil
|
68
66
|
end
|
69
67
|
|
70
|
-
def self.track_job(job, job_id, queue, created_at)
|
68
|
+
def self.track_job(job, job_id, queue, created_at, slow_job_threshold = nil)
|
69
|
+
slow_job_threshold ||= Notable.slow_job_threshold
|
71
70
|
exception = nil
|
72
71
|
notes = nil
|
73
72
|
start_time = Time.now
|
73
|
+
created_at = Time.parse(created_at) if created_at.is_a?(String)
|
74
74
|
queued_time = created_at ? start_time - created_at : nil
|
75
75
|
begin
|
76
76
|
yield
|
@@ -84,7 +84,7 @@ module Notable
|
|
84
84
|
runtime = Time.now - start_time
|
85
85
|
|
86
86
|
Safely.safely do
|
87
|
-
notes << {note_type: "Slow Job"} if runtime >
|
87
|
+
notes << {note_type: "Slow Job"} if runtime > slow_job_threshold
|
88
88
|
|
89
89
|
notes.each do |note|
|
90
90
|
data = {
|
@@ -103,6 +103,27 @@ module Notable
|
|
103
103
|
|
104
104
|
raise exception if exception
|
105
105
|
end
|
106
|
+
|
107
|
+
def self.mask_ip(ip)
|
108
|
+
addr = IPAddr.new(ip)
|
109
|
+
if addr.ipv4?
|
110
|
+
# set last octet to 0
|
111
|
+
addr.mask(24).to_s
|
112
|
+
else
|
113
|
+
# set last 80 bits to zeros
|
114
|
+
addr.mask(48).to_s
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
ActiveSupport.on_load(:action_controller) do
|
120
|
+
require "notable/unverified_request"
|
121
|
+
include Notable::UnverifiedRequest
|
122
|
+
end
|
123
|
+
|
124
|
+
ActiveSupport.on_load(:active_record) do
|
125
|
+
require "notable/validation_errors"
|
126
|
+
include Notable::ValidationErrors
|
106
127
|
end
|
107
128
|
|
108
129
|
ActiveSupport.on_load(:active_job) do
|
data/lib/notable/engine.rb
CHANGED
@@ -4,8 +4,9 @@ module Notable
|
|
4
4
|
|
5
5
|
initializer "notable" do |app|
|
6
6
|
if Notable.requests_enabled?
|
7
|
-
|
8
|
-
ActionDispatch::
|
7
|
+
# insert in same place as request_store
|
8
|
+
app.config.middleware.insert_after ActionDispatch::RequestId, Notable::Middleware
|
9
|
+
ActionDispatch::DebugExceptions.prepend Notable::DebugExceptions
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -4,8 +4,8 @@ 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,
|
7
|
+
# enqueued_at is only available in Active Job 6+
|
8
|
+
Notable.track_job(job.class.name, job.job_id, job.queue_name, job.try(:enqueued_at), try(:notable_slow_job_threshold)) do
|
9
9
|
block.call
|
10
10
|
end
|
11
11
|
end
|
data/lib/notable/middleware.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Notable
|
2
2
|
class Middleware
|
3
|
-
|
4
3
|
def initialize(app)
|
5
4
|
@app = app
|
6
5
|
end
|
@@ -44,6 +43,11 @@ module Notable
|
|
44
43
|
user = Notable.user_method.call(env)
|
45
44
|
|
46
45
|
notes.each do |note|
|
46
|
+
ip = request.remote_ip
|
47
|
+
if ip && Notable.mask_ips
|
48
|
+
ip = Notable.mask_ip(ip)
|
49
|
+
end
|
50
|
+
|
47
51
|
data = {
|
48
52
|
note_type: note[:note_type],
|
49
53
|
note: note[:note],
|
@@ -52,7 +56,7 @@ module Notable
|
|
52
56
|
status: status,
|
53
57
|
params: params,
|
54
58
|
request_id: request.uuid,
|
55
|
-
ip:
|
59
|
+
ip: ip,
|
56
60
|
user_agent: request.user_agent,
|
57
61
|
url: url,
|
58
62
|
referrer: request.referer,
|
@@ -64,7 +68,8 @@ module Notable
|
|
64
68
|
end
|
65
69
|
|
66
70
|
[status, headers, body]
|
71
|
+
ensure
|
72
|
+
Notable.clear_notes
|
67
73
|
end
|
68
|
-
|
69
74
|
end
|
70
75
|
end
|
data/lib/notable/throttle.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
ActiveSupport::Notifications.subscribe "rack.attack" do |
|
2
|
-
|
3
|
-
|
1
|
+
ActiveSupport::Notifications.subscribe "rack.attack" do |_name, _start, _finish, _request_id, req|
|
2
|
+
request = req.is_a?(Hash) ? req[:request] : req
|
3
|
+
|
4
|
+
if [:blacklist, :blocklist, :throttle].include?(request.env["rack.attack.match_type"])
|
5
|
+
Notable.track "Throttle", request.env["rack.attack.matched"]
|
4
6
|
end
|
5
7
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
ActiveSupport::Notifications.subscribe "unpermitted_parameters.action_controller" do |
|
1
|
+
ActiveSupport::Notifications.subscribe "unpermitted_parameters.action_controller" do |_name, _start, _finish, _id, payload|
|
2
2
|
Notable.track "Unpermitted Parameters", payload[:keys].join(", ")
|
3
3
|
end
|
@@ -7,7 +7,7 @@ module Notable
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def track_unverified_request
|
10
|
-
if !verified_request?
|
10
|
+
if respond_to?(:verified_request?, true) && !verified_request?
|
11
11
|
expected = form_authenticity_token
|
12
12
|
actual = form_authenticity_param || request.headers["X-CSRF-Token"]
|
13
13
|
Notable.track "Unverified Request", "#{actual || "nil"} != #{expected}"
|
@@ -15,5 +15,3 @@ module Notable
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
19
|
-
ActionController::Base.send(:include, Notable::UnverifiedRequest)
|
data/lib/notable/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: safely_block
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,49 +42,129 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: combustion
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
89
|
+
version: '0'
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- - "
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
67
102
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
-
|
70
|
-
|
71
|
-
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rack-attack
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: slowpoke
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description:
|
154
|
+
email: andrew@chartkick.com
|
72
155
|
executables: []
|
73
156
|
extensions: []
|
74
157
|
extra_rdoc_files: []
|
75
158
|
files:
|
76
|
-
- ".gitignore"
|
77
159
|
- CHANGELOG.md
|
78
|
-
- Gemfile
|
79
160
|
- LICENSE.txt
|
80
161
|
- README.md
|
81
|
-
- Rakefile
|
82
162
|
- app/models/notable/job.rb
|
83
163
|
- app/models/notable/request.rb
|
84
164
|
- lib/generators/notable/jobs_generator.rb
|
85
165
|
- lib/generators/notable/requests_generator.rb
|
86
|
-
- lib/generators/notable/templates/create_jobs.rb
|
87
|
-
- lib/generators/notable/templates/create_requests.rb
|
166
|
+
- lib/generators/notable/templates/create_jobs.rb.tt
|
167
|
+
- lib/generators/notable/templates/create_requests.rb.tt
|
88
168
|
- lib/notable.rb
|
89
169
|
- lib/notable/debug_exceptions.rb
|
90
170
|
- lib/notable/engine.rb
|
@@ -95,7 +175,6 @@ files:
|
|
95
175
|
- lib/notable/unverified_request.rb
|
96
176
|
- lib/notable/validation_errors.rb
|
97
177
|
- lib/notable/version.rb
|
98
|
-
- notable.gemspec
|
99
178
|
homepage: https://github.com/ankane/notable
|
100
179
|
licenses:
|
101
180
|
- MIT
|
@@ -108,15 +187,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
187
|
requirements:
|
109
188
|
- - ">="
|
110
189
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
190
|
+
version: '2.4'
|
112
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
192
|
requirements:
|
114
193
|
- - ">="
|
115
194
|
- !ruby/object:Gem::Version
|
116
195
|
version: '0'
|
117
196
|
requirements: []
|
118
|
-
|
119
|
-
rubygems_version: 2.6.11
|
197
|
+
rubygems_version: 3.1.2
|
120
198
|
signing_key:
|
121
199
|
specification_version: 4
|
122
200
|
summary: Track notable requests and background jobs
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/notable.gemspec
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "notable/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "notable"
|
8
|
-
spec.version = Notable::VERSION
|
9
|
-
spec.authors = ["Andrew Kane"]
|
10
|
-
spec.email = ["andrew@chartkick.com"]
|
11
|
-
spec.summary = "Track notable requests and background jobs"
|
12
|
-
spec.description = "Track notable requests and background jobs"
|
13
|
-
spec.homepage = "https://github.com/ankane/notable"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_dependency "request_store"
|
22
|
-
spec.add_dependency "safely_block", ">= 0.1.1"
|
23
|
-
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
end
|