wafris 0.8.1 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a2722b928a9589d9a25292b4116200e428fabfbbc7fa7d15e2eaada1a42927a
4
- data.tar.gz: c3b941f3ed47136b92731e62df8dbb9d47c29d0817bf85e5b974bcd7b01c9ca8
3
+ metadata.gz: db4ac55c07f22ff09c83a0d4a1056eb9bbdd14f28c9704978ac8faef7ba438b9
4
+ data.tar.gz: 8d114c0ca77681e7c9bd20b39a565973a968031980b28fed9964bd0c78213eb1
5
5
  SHA512:
6
- metadata.gz: 8e52e73b5d385e3a81ee4f5845f50dc00cd52683b595db3e5cb4f47ca7e573d49343525b8c2d6de423f9f189752b82f47acb71240d298b509f1da9b72023313e
7
- data.tar.gz: b8cb1ccb52d9edc06756f78b277ff4ca2c2c39c94bea68e1e913b74dd620cf8033342759b232cfa086e6cf55f683729258cbb44488eca08f4d821ee751ab1929
6
+ metadata.gz: 0b5f0d3e83fa9d33874aa21170aa89a0126745cd3f9de4e4a6c2b299c86d519763601a97e4b76fd2675d69cd0fa5529cb5582a741591e5f7d2c57f5ad0fb4743
7
+ data.tar.gz: ecebfb0bb9f7e5b835ddd696af75a35189cd8cc94a0fffb85c3804e309177a068e65049c3ae7245353ee05e87c0e1eb1b5b30eb108b1bed4c173cceed0127acb
@@ -84,8 +84,8 @@ local function increment_partial_hourly_request_counters(unix_time_milliseconds)
84
84
  local timebucket = get_time_bucket_from_timestamp(timebucket_in_milliseconds, true)
85
85
  local key = wafris_prefix .. "hr-ct:" .. timebucket
86
86
  redis.call("INCR", key)
87
- -- Expire the key after 61 minutes if it has no expiry
88
- redis.call("EXPIRE", key, 3660)
87
+ -- Expire the key after 121 minutes if it has no expiry
88
+ redis.call("EXPIRE", key, 7260)
89
89
  end
90
90
  end
91
91
 
@@ -117,17 +117,18 @@ increment_timebucket_for("ua:", current_timebucket, user_agent)
117
117
  increment_timebucket_for("path:", current_timebucket, request_path)
118
118
  increment_timebucket_for("host:", current_timebucket, host)
119
119
 
120
- redis.call("ZRANGEBYSCORE", "blocked_ranges", client_ip_to_decimal, client_ip_to_decimal, "LIMIT", 0, 1)
121
-
122
120
  -- BLOCKING LOGIC
123
121
  -- TODO: ZRANGEBYSCORE is deprecated in Redis 6.2+. Replace with ZRANGE
124
122
  if
125
- -- ZRANGEBYSCORE will always return a lua table, even if empty
126
123
  -- TODO: When we introduce ranges we'll have to do an exact check followed by a range starting with decimal ip to infinity.
127
124
  -- If the first result returned is "END" that means it falls in the range
128
- next(redis.call("ZRANGEBYSCORE", "blocked_ranges", client_ip_to_decimal, client_ip_to_decimal, "LIMIT", 0, 1)) ~= nil
125
+
126
+ -- ZRANGEBYSCORE will always return a lua table, even if empty
127
+ -- This call is checking if the table is empty
128
+ next(redis.call("ZRANGEBYSCORE", "w:blocked-ranges", client_ip_to_decimal, client_ip_to_decimal, "LIMIT", 0, 1))
129
+ ~= nil
129
130
  then
130
- increment_timebucket_for("wafris:blocked:", current_timebucket, client_ip)
131
+ increment_timebucket_for("blk:", current_timebucket, client_ip)
131
132
  return "Blocked"
132
133
  -- No Matches
133
134
  else
@@ -6,20 +6,11 @@ module Wafris
6
6
  attr_accessor :redis_pool_size
7
7
 
8
8
  def initialize
9
- @redis = set_redis
9
+ @redis = Redis.new(
10
+ url: ENV['REDIS_URL'],
11
+ ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
12
+ )
10
13
  @redis_pool_size = 20
11
- set_version
12
- end
13
-
14
- def set_redis
15
- if ENV['REDIS_URL']
16
- Redis.new(
17
- url: ENV['REDIS_URL'],
18
- ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
19
- )
20
- else
21
- Redis.new
22
- end
23
14
  end
24
15
 
25
16
  def connection_pool
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wafris
4
- VERSION = "0.8.1"
4
+ VERSION = "0.8.3"
5
5
  end
data/lib/wafris.rb CHANGED
@@ -13,6 +13,7 @@ module Wafris
13
13
  class << self
14
14
  def configure
15
15
  yield configuration
16
+ configuration.set_version
16
17
  end
17
18
 
18
19
  def configuration
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wafris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micahel Buckbee