reputable 0.1.11 → 0.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 342aa90209deb951c9e527396dfc48b1609603ac305bac088c6d20846c1a6dee
4
- data.tar.gz: 65a4a67057b29ee2c787788393e7803302e958397974b53685a792cdc668718a
3
+ metadata.gz: '09fa87a88ec9b2c8b0cf010e6291c7386f32ed2ceaf55b80c34cd831a75b07f4'
4
+ data.tar.gz: ab4eb854a090b4c971722932fffe097ae1f52a8feaf1525b8bf2ed6fc9462411
5
5
  SHA512:
6
- metadata.gz: f410554eaf31c3386094003f72665d9b7b6020b68c91d67ef4626589708ea1fe47bb01f975971a282f0e7e08dadc9384ae8babf816dec1ee1a8febbc0668ecc9
7
- data.tar.gz: 244d984492e5a91987e17ceadfe5e67e88beba0280c5a56057cf112768f9c981738ae72b63c91da93dce80c92c56c86a7ad9af220f914a791c6dc86844915af6
6
+ metadata.gz: 45143f6b28ebc3e70810a0a58830b6136c1575a6c4888ad5a680dfc1d3cf09ec9e619ef104873883ecc083324cd083dbe769648494701eedc3f488c5215eb7e6
7
+ data.tar.gz: b1c8722bc5e7c4c9cc4080fb922a0a245c0a42996e5ab4abd6e984e33943f50da0d7d8f55873096630bafd93ec53bc7a703049ab36fc63c8fd68af9cf8f23f43
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- reputable (0.1.11)
4
+ reputable (0.1.12)
5
5
  connection_pool (~> 2.2)
6
6
  redis (>= 4.0, < 6.0)
7
7
 
data/README.md CHANGED
@@ -271,6 +271,10 @@ config.middleware.use Reputable::Middleware,
271
271
  # Async mode (default: true) - tracking runs in background thread
272
272
  async: true,
273
273
 
274
+ # Request tracking (default: false) - push request context to Redis
275
+ # Falls back to ENV REPUTABLE_TRACK_REQUEST if not set
276
+ track_request: true,
277
+
274
278
  # Expose reputation flags in request env for views/controllers (default: true)
275
279
  # Sets request.env['reputable.ignore_analytics'] when status is untrusted_ignore
276
280
  expose_reputation: true
@@ -565,6 +569,11 @@ The gem is designed with resilience as the top priority:
565
569
  REPUTABLE_ENABLED=false
566
570
  ```
567
571
 
572
+ ```bash
573
+ # Enable request tracking (push request context to Redis)
574
+ REPUTABLE_TRACK_REQUEST=true
575
+ ```
576
+
568
577
  ```ruby
569
578
  # Check in code
570
579
  if Reputable.enabled?
@@ -653,7 +662,7 @@ expect(Reputable.lookup_ip('1.2.3.4')).to be_nil
653
662
 
654
663
  ## How It Works
655
664
 
656
- 1. **Request Tracking**: Your Rails app pushes request data to Redis buffers
665
+ 1. **Request Tracking**: Your Rails app pushes request data to Redis buffers (enable with `track_request: true` or `REPUTABLE_TRACK_REQUEST=true`)
657
666
  2. **Async Processing**: Reputable API processes buffers asynchronously
658
667
  3. **Behavioral Analysis**: Requests go through classification and pattern analysis
659
668
  4. **Reputation Storage**: Scores stored in Redis for O(1) lookups
@@ -44,6 +44,7 @@ module Reputable
44
44
  @skip_if = options[:skip_if]
45
45
  @tag_builder = options[:tag_builder]
46
46
  @async = options.fetch(:async, true)
47
+ @track_request = options.key?(:track_request) ? options[:track_request] : nil
47
48
  @reputation_gate = options.fetch(:reputation_gate, false)
48
49
  @expose_reputation = options.fetch(:expose_reputation, true)
49
50
  @challenge_action = options.fetch(:challenge_action, :verify)
@@ -118,6 +119,9 @@ module Reputable
118
119
  def safe_track_request(env)
119
120
  # Skip if disabled globally
120
121
  return unless Reputable.enabled?
122
+
123
+ # Skip unless explicitly enabled
124
+ return unless track_request_enabled?
121
125
 
122
126
  # Skip if this request should be skipped
123
127
  return if skip_request?(env)
@@ -128,6 +132,17 @@ module Reputable
128
132
  Reputable.logger&.debug("Reputable middleware: #{e.class} - #{e.message}")
129
133
  end
130
134
 
135
+ def track_request_enabled?
136
+ return @track_request unless @track_request.nil?
137
+
138
+ env_value = ENV["REPUTABLE_TRACK_REQUEST"]
139
+ return false if env_value.nil?
140
+
141
+ !%w[0 false no off disabled].include?(env_value.to_s.downcase)
142
+ rescue StandardError
143
+ false
144
+ end
145
+
131
146
  def handle_verification_return(env)
132
147
  request = Rack::Request.new(env)
133
148
  # Quick check to avoid overhead
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Reputable
4
- VERSION = "0.1.11"
4
+ VERSION = "0.1.12"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reputable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reputable