reputable 0.1.0 → 0.1.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/reputable/rails.rb +26 -29
- data/lib/reputable/reputation.rb +4 -2
- data/lib/reputable/version.rb +1 -1
- data/lib/reputable.rb +2 -4
- metadata +17 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58cd625b57ec78df69ca3a6f46e810f3870d30d2c708c61ded9c028737eef1e8
|
|
4
|
+
data.tar.gz: b73a0ad0cfffead0089d870bfd51dee53b3ee4af4305992ec9285f37f0e18e4b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e99d9b81e8fe4ee5594ad30637eac3387a89e4073644ae8a54a25c211e6c2a0cae9dcf38b03a6767474845f0b63437e719a2f9bc4748b208afe617c3d43a9e5
|
|
7
|
+
data.tar.gz: 5e6e0d1a50150f7e5acec89be721be877ee17e1a1bb9f388c5ab4c70b14e9b2a6efcd816087e4a177e712723081550d7af704cc8f212961131f92cfdc8063de8
|
data/lib/reputable/rails.rb
CHANGED
|
@@ -3,30 +3,6 @@
|
|
|
3
3
|
module Reputable
|
|
4
4
|
# Rails-specific integration
|
|
5
5
|
module Rails
|
|
6
|
-
# Railtie for automatic Rails integration
|
|
7
|
-
class Railtie < ::Rails::Railtie
|
|
8
|
-
initializer "reputable.configure_rails_initialization" do
|
|
9
|
-
# Auto-configure from Rails credentials or ENV
|
|
10
|
-
Reputable.configure do |config|
|
|
11
|
-
# Try Rails credentials first
|
|
12
|
-
if defined?(::Rails.application.credentials)
|
|
13
|
-
creds = ::Rails.application.credentials.reputable rescue nil
|
|
14
|
-
if creds
|
|
15
|
-
config.redis_url = creds[:redis_url] if creds[:redis_url]
|
|
16
|
-
config.tenant_id = creds[:tenant_id] if creds[:tenant_id]
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
initializer "reputable.insert_middleware" do |app|
|
|
23
|
-
# Only insert middleware if explicitly enabled
|
|
24
|
-
if ENV["REPUTABLE_AUTO_MIDDLEWARE"] == "true"
|
|
25
|
-
app.middleware.use Reputable::Middleware
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
6
|
# Helper methods for controllers
|
|
31
7
|
module ControllerHelpers
|
|
32
8
|
extend ActiveSupport::Concern
|
|
@@ -142,10 +118,31 @@ module Reputable
|
|
|
142
118
|
Reputable::Reputation.trusted_session?(session.id.to_s)
|
|
143
119
|
end
|
|
144
120
|
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
121
|
|
|
148
|
-
#
|
|
149
|
-
if defined?(::Rails::Railtie)
|
|
150
|
-
|
|
122
|
+
# Railtie for automatic Rails integration (only defined when Rails is present)
|
|
123
|
+
if defined?(::Rails::Railtie)
|
|
124
|
+
class Railtie < ::Rails::Railtie
|
|
125
|
+
initializer "reputable.configure_rails_initialization" do
|
|
126
|
+
# Auto-configure from Rails credentials or ENV
|
|
127
|
+
Reputable.configure do |config|
|
|
128
|
+
# Try Rails credentials first
|
|
129
|
+
if defined?(::Rails.application.credentials)
|
|
130
|
+
creds = ::Rails.application.credentials.reputable rescue nil
|
|
131
|
+
if creds
|
|
132
|
+
config.redis_url = creds[:redis_url] if creds[:redis_url]
|
|
133
|
+
config.tenant_id = creds[:tenant_id] if creds[:tenant_id]
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
initializer "reputable.insert_middleware" do |app|
|
|
140
|
+
# Only insert middleware if explicitly enabled
|
|
141
|
+
if ENV["REPUTABLE_AUTO_MIDDLEWARE"] == "true"
|
|
142
|
+
app.middleware.use Reputable::Middleware
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
151
148
|
end
|
data/lib/reputable/reputation.rb
CHANGED
|
@@ -198,7 +198,7 @@ module Reputable
|
|
|
198
198
|
# Check if an IP is trusted (any trusted_* status)
|
|
199
199
|
#
|
|
200
200
|
# @param ip [String] IP address
|
|
201
|
-
# @return [Boolean]
|
|
201
|
+
# @return [Boolean] Returns false if disabled, nil lookup, or not trusted
|
|
202
202
|
#
|
|
203
203
|
# @example
|
|
204
204
|
# if Reputable::Reputation.trusted_ip?("203.0.113.45")
|
|
@@ -206,7 +206,9 @@ module Reputable
|
|
|
206
206
|
# end
|
|
207
207
|
def trusted_ip?(ip)
|
|
208
208
|
status = lookup_ip(ip)
|
|
209
|
-
status
|
|
209
|
+
return false if status.nil?
|
|
210
|
+
|
|
211
|
+
status.start_with?("trusted")
|
|
210
212
|
end
|
|
211
213
|
|
|
212
214
|
# Check if an IP should be blocked
|
data/lib/reputable/version.rb
CHANGED
data/lib/reputable.rb
CHANGED
|
@@ -7,11 +7,9 @@ require_relative "reputable/tracker"
|
|
|
7
7
|
require_relative "reputable/reputation"
|
|
8
8
|
require_relative "reputable/middleware"
|
|
9
9
|
|
|
10
|
-
# Optional Rails integration
|
|
11
|
-
|
|
10
|
+
# Optional Rails integration (only load if Rails is defined)
|
|
11
|
+
if defined?(::Rails)
|
|
12
12
|
require_relative "reputable/rails"
|
|
13
|
-
rescue LoadError
|
|
14
|
-
# Rails not available, skip
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
# Reputable - Bot detection and reputation scoring client
|
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.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Reputable
|
|
@@ -78,14 +78,28 @@ dependencies:
|
|
|
78
78
|
requirements:
|
|
79
79
|
- - "~>"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '3.
|
|
81
|
+
version: '3.12'
|
|
82
82
|
type: :development
|
|
83
83
|
prerelease: false
|
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
|
86
86
|
- - "~>"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '3.
|
|
88
|
+
version: '3.12'
|
|
89
|
+
- !ruby/object:Gem::Dependency
|
|
90
|
+
name: rack
|
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '2.0'
|
|
96
|
+
type: :development
|
|
97
|
+
prerelease: false
|
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '2.0'
|
|
89
103
|
- !ruby/object:Gem::Dependency
|
|
90
104
|
name: rubocop
|
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|