reputable 0.1.10 → 0.1.11
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/Gemfile.lock +1 -1
- data/README.md +10 -1
- data/lib/reputable/middleware.rb +34 -2
- data/lib/reputable/rails.rb +12 -1
- data/lib/reputable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 342aa90209deb951c9e527396dfc48b1609603ac305bac088c6d20846c1a6dee
|
|
4
|
+
data.tar.gz: 65a4a67057b29ee2c787788393e7803302e958397974b53685a792cdc668718a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f410554eaf31c3386094003f72665d9b7b6020b68c91d67ef4626589708ea1fe47bb01f975971a282f0e7e08dadc9384ae8babf816dec1ee1a8febbc0668ecc9
|
|
7
|
+
data.tar.gz: 244d984492e5a91987e17ceadfe5e67e88beba0280c5a56057cf112768f9c981738ae72b63c91da93dce80c92c56c86a7ad9af220f914a791c6dc86844915af6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -269,7 +269,11 @@ config.middleware.use Reputable::Middleware,
|
|
|
269
269
|
},
|
|
270
270
|
|
|
271
271
|
# Async mode (default: true) - tracking runs in background thread
|
|
272
|
-
async: true
|
|
272
|
+
async: true,
|
|
273
|
+
|
|
274
|
+
# Expose reputation flags in request env for views/controllers (default: true)
|
|
275
|
+
# Sets request.env['reputable.ignore_analytics'] when status is untrusted_ignore
|
|
276
|
+
expose_reputation: true
|
|
273
277
|
```
|
|
274
278
|
|
|
275
279
|
### Optional Reputation Gate
|
|
@@ -328,6 +332,11 @@ if current_ip_trusted?
|
|
|
328
332
|
# Skip CAPTCHA, higher rate limits
|
|
329
333
|
end
|
|
330
334
|
|
|
335
|
+
# View/helper flag for untrusted_ignore
|
|
336
|
+
if reputable_ignore_analytics?
|
|
337
|
+
# Skip analytics / tracking in views
|
|
338
|
+
end
|
|
339
|
+
|
|
331
340
|
if current_ip_blocked?
|
|
332
341
|
render status: 403
|
|
333
342
|
return
|
data/lib/reputable/middleware.rb
CHANGED
|
@@ -45,6 +45,7 @@ module Reputable
|
|
|
45
45
|
@tag_builder = options[:tag_builder]
|
|
46
46
|
@async = options.fetch(:async, true)
|
|
47
47
|
@reputation_gate = options.fetch(:reputation_gate, false)
|
|
48
|
+
@expose_reputation = options.fetch(:expose_reputation, true)
|
|
48
49
|
@challenge_action = options.fetch(:challenge_action, :verify)
|
|
49
50
|
@block_action = options.fetch(:block_action, :blocked_page_remote)
|
|
50
51
|
@challenge_redirect_status = options.fetch(:challenge_redirect_status, 302)
|
|
@@ -72,6 +73,9 @@ module Reputable
|
|
|
72
73
|
return gate_response
|
|
73
74
|
end
|
|
74
75
|
|
|
76
|
+
# Optional: expose reputation context for views/controllers
|
|
77
|
+
safe_apply_reputation_context(env) if @expose_reputation
|
|
78
|
+
|
|
75
79
|
# ALWAYS process the request first - tracking must never block
|
|
76
80
|
status, headers, response = @app.call(env)
|
|
77
81
|
|
|
@@ -96,9 +100,9 @@ module Reputable
|
|
|
96
100
|
end
|
|
97
101
|
|
|
98
102
|
def enforce_reputation_gate(env)
|
|
99
|
-
|
|
100
|
-
status = Reputable::Reputation.lookup_ip(ip)
|
|
103
|
+
status = reputation_status(env)
|
|
101
104
|
return nil if status.nil?
|
|
105
|
+
ip = env["reputable.ip"] || extract_ip(env)
|
|
102
106
|
|
|
103
107
|
case status
|
|
104
108
|
when "untrusted_block"
|
|
@@ -133,6 +137,10 @@ module Reputable
|
|
|
133
137
|
|
|
134
138
|
if Reputable.verify_redirect_return(request.params)
|
|
135
139
|
env["reputable.verified"] = true
|
|
140
|
+
ignore_analytics = request.params["reputable_ignore_analytics"]
|
|
141
|
+
unless ignore_analytics.nil?
|
|
142
|
+
env["reputable.ignore_analytics"] = ignore_analytics.to_s == "true"
|
|
143
|
+
end
|
|
136
144
|
|
|
137
145
|
# Store in session if available
|
|
138
146
|
if env["rack.session"]
|
|
@@ -255,6 +263,30 @@ module Reputable
|
|
|
255
263
|
Reputable::BlockedPage.response(**options)
|
|
256
264
|
end
|
|
257
265
|
|
|
266
|
+
def safe_apply_reputation_context(env)
|
|
267
|
+
return unless Reputable.enabled?
|
|
268
|
+
return if skip_request?(env)
|
|
269
|
+
|
|
270
|
+
reputation_status(env)
|
|
271
|
+
rescue StandardError => e
|
|
272
|
+
Reputable.logger&.debug("Reputable reputation context: #{e.class} - #{e.message}")
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def reputation_status(env)
|
|
276
|
+
return env["reputable.reputation_status"] if env.key?("reputable.reputation_status")
|
|
277
|
+
|
|
278
|
+
ip = extract_ip(env)
|
|
279
|
+
env["reputable.ip"] = ip
|
|
280
|
+
status = Reputable::Reputation.lookup_ip(ip)
|
|
281
|
+
env["reputable.reputation_status"] = status
|
|
282
|
+
env["reputable.ignore_analytics"] = (status == "untrusted_ignore")
|
|
283
|
+
status
|
|
284
|
+
rescue StandardError
|
|
285
|
+
env["reputable.reputation_status"] = nil
|
|
286
|
+
env["reputable.ignore_analytics"] = false
|
|
287
|
+
nil
|
|
288
|
+
end
|
|
289
|
+
|
|
258
290
|
def blocked_page_options
|
|
259
291
|
config = Reputable.configuration
|
|
260
292
|
defaults = {
|
data/lib/reputable/rails.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Reputable
|
|
|
8
8
|
extend ActiveSupport::Concern
|
|
9
9
|
|
|
10
10
|
included do
|
|
11
|
-
helper_method :reputable_verified? if respond_to?(:helper_method)
|
|
11
|
+
helper_method :reputable_verified?, :reputable_ignore_analytics? if respond_to?(:helper_method)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
# Track the current request with optional extra tags
|
|
@@ -88,6 +88,17 @@ module Reputable
|
|
|
88
88
|
Reputable::Reputation.lookup_ip(request.remote_ip)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
+
# Check if analytics should be ignored for this request
|
|
92
|
+
# Uses middleware-populated flag when available, falls back to lookup.
|
|
93
|
+
def reputable_ignore_analytics?
|
|
94
|
+
value = request.env["reputable.ignore_analytics"]
|
|
95
|
+
return value unless value.nil?
|
|
96
|
+
|
|
97
|
+
current_ip_status == "untrusted_ignore"
|
|
98
|
+
rescue StandardError
|
|
99
|
+
false
|
|
100
|
+
end
|
|
101
|
+
|
|
91
102
|
# ========================================
|
|
92
103
|
# Verification redirect helpers
|
|
93
104
|
# ========================================
|
data/lib/reputable/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: reputable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Reputable
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-12-
|
|
11
|
+
date: 2025-12-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: redis
|