bizside 3.0.2 → 3.0.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: 3252985492fd4c1d9d071dcc563ed42a46381d3decfc818c7f8ec23e3dc6216c
4
- data.tar.gz: 736dc39d2df0a2c801796dee3e3d4fa1289a95e36f7731beb607f94b04ff0e74
3
+ metadata.gz: 73521110af0354af6ab7be8aeecf81c4b7a51003eba151398a4769981436a528
4
+ data.tar.gz: fa0cc7ea9e2b39716154c69ccdc0e736e6b827eba54b060fc1e105a593fd682d
5
5
  SHA512:
6
- metadata.gz: 5e09f18238981afe43cff1bc25416521e822f8442a0cdbd3bdc5842792493edd4a1a86baabfef4f518d603304184cb675c00800e6adb3005a3a61d2c95951acb
7
- data.tar.gz: d7a20214bdc6fd9c43ff7663e875e2eefb1083491794c0ca51caa5d75c553264b165da661628d160cd29ec3b7edadefae32e164918ffe9be1dad08db1101cf93
6
+ metadata.gz: 89243ceb64e24a815373006c4ce1d16cc5e5ffdadac4669cad7858b3501bc3e41e0a903c401d82baa734ad15c4f6c518128e51bf55fad0be751d8f9226b387ca
7
+ data.tar.gz: e82df91dffd5f633b9ba3b5987aad540fe256079295b3dafeb441fe04a3ad9ee01cff71d9b5bf455a4997a339a99bf1c4a43e9fe2bc8e1e05e12a6c569f772b0
@@ -1,15 +1,23 @@
1
+ require 'ipaddr'
1
2
  require_relative 'audit/logger'
2
3
 
3
4
  module Bizside
4
5
  class AuditLog
5
6
 
6
7
  @@ignore_paths = []
8
+ @@trusted_proxy_cidrs = []
9
+ @@trusted_proxy_cidr_objects = {}
7
10
  @@truncate_length = 8192
8
11
 
9
12
  def self.ignore_paths
10
13
  @@ignore_paths
11
14
  end
12
15
 
16
+ # 192.168.0.0/24 といったCIDR表記の文字列を複数指定可能
17
+ def self.trusted_proxy_cidrs
18
+ @@trusted_proxy_cidrs
19
+ end
20
+
13
21
  def self.truncate_length
14
22
  @@truncate_length
15
23
  end
@@ -25,7 +33,7 @@ module Bizside
25
33
  def call(env)
26
34
  start = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%3N%z')
27
35
  status, headers, response = @app.call(env)
28
- stop = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%3N%z')
36
+ stop = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%3N%z')
29
37
  exception = env[Bizside::ShowExceptions::BIZSIDE_EXCEPTION_ENV_KEY]
30
38
 
31
39
  if env['BIZSIDE_SUPPRESS_AUDIT']
@@ -180,10 +188,23 @@ module Bizside
180
188
  exception.backtrace.join("\n")[0...truncate_length]
181
189
  end
182
190
 
183
- # 信頼のおけるロードバランサーがプロキシーになっている前提で、各HTTPヘッダの先頭のIPをクライアントIPとして取得する
191
+ # 信頼のおけるロードバランサーがプロキシーになっている前提で、各HTTPヘッダの最後のIPをクライアントIPとして取得する
184
192
  def to_client_ip(header_value)
185
193
  ips = header_value ? header_value.strip.split(/[,\s]+/) : []
186
- ips.first
194
+ ips.reverse.each do |ip|
195
+ return ip unless proxy?(ip)
196
+ end
197
+
198
+ nil
199
+ end
200
+
201
+ def proxy?(ip)
202
+ @@trusted_proxy_cidrs.each do |cidr|
203
+ cidr_obj = @@trusted_proxy_cidr_objects[cidr] ||= IPAddr.new(cidr)
204
+ return true if cidr_obj.include?(ip)
205
+ end
206
+
207
+ false
187
208
  end
188
209
 
189
210
  end
@@ -1,3 +1,3 @@
1
1
  module Bizside
2
- VERSION = '3.0.2'
2
+ VERSION = '3.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bizside
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bizside-developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-16 00:00:00.000000000 Z
11
+ date: 2024-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -475,7 +475,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
475
475
  - !ruby/object:Gem::Version
476
476
  version: '0'
477
477
  requirements: []
478
- rubygems_version: 3.4.22
478
+ rubygems_version: 3.3.26
479
479
  signing_key:
480
480
  specification_version: 4
481
481
  summary: Bizside is an utilities for web application.