bizside 2.3.8 → 2.3.10

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: 31a2944a9db2b20cadfe18a6367f9cbcd5c04f5dcf6259e1fd6f5639ac056915
4
- data.tar.gz: 70dcd0e7746a040d1a60494406b4bedbdfb1b51bccbdcd86d3d54f0bee4844e2
3
+ metadata.gz: 68f86e96f8a12ef1c7f2f3621bd5f3f5bfbd91793c22f69cef1931bec3afaaa1
4
+ data.tar.gz: 9b57e4ee3d7149f04d9bfd6c75b1bbf4ff0c5a70340ddfbecdf717c31d134c50
5
5
  SHA512:
6
- metadata.gz: a06ec66efb74b3c4ed9d34293e4db7b019df45737314135eea676da367f9a7d264bed92bcacd3be13f7835549303fac04b63ab0bdc37ef7a21daf9987ac392f7
7
- data.tar.gz: cafbf3686937f4b507d57699783d66afe98cd2ad28d9e93711f7ee2009cb3cda2a9a8cd2f1a7ba94892ef870d4343ca56572553c59d5694f89d5e557d45b005a
6
+ metadata.gz: 4401fe930807b9a5bdc446d2caf1757d52b3424ec70feaf7a460f31790581fe817583013af85f0449a01d8ee5c7aaaf32073885a113322ea25cad48eb5a1138c
7
+ data.tar.gz: dcf8446560af38e5436d67852dbfe45c19d48c6f77350bb2b0bafc2ad58a522a3d9fe084cfa94410c4f0dab7c9d3029cc9b76230d37e8d7db2f2686bbf238e21
@@ -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,33 +1,35 @@
1
1
  module Bizside
2
- class CoverageLaunch
2
+ module Coverage
3
+ class Launch
3
4
 
4
- def self.load
5
- if ENV["COVERAGE"].to_s.downcase == 'true' and ENV['ACCEPTANCE_TEST'].to_s.downcase == 'true'
6
- setup()
5
+ def self.load
6
+ if ENV["COVERAGE"].to_s.downcase == 'true' and ENV['ACCEPTANCE_TEST'].to_s.downcase == 'true'
7
+ setup()
7
8
 
8
- SimpleCov.start 'rails' do
9
- SimpleCov.command_name(ENV['COMMAND_NAME']) if ENV['COMMAND_NAME']
10
- SimpleCov.merge_timeout(7200)
9
+ SimpleCov.start 'rails' do
10
+ SimpleCov.command_name(ENV['COMMAND_NAME']) if ENV['COMMAND_NAME']
11
+ SimpleCov.merge_timeout(7200)
12
+ end
11
13
  end
12
14
  end
13
- end
14
15
 
15
- def self.load_from_test_helper
16
- if ENV["COVERAGE"] == 'true'
17
- setup()
18
- SimpleCov.start 'rails'
16
+ def self.load_from_test_helper
17
+ if ENV["COVERAGE"] == 'true'
18
+ setup()
19
+ SimpleCov.start 'rails'
20
+ end
19
21
  end
20
- end
21
22
 
22
- def self.setup
23
- require 'simplecov'
24
- require 'simplecov-rcov'
25
- require_relative 'rcov_formatter'
26
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
27
- SimpleCov::Formatter::HTMLFormatter,
28
- Coverage::RcovFormatter
29
- ])
23
+ def self.setup
24
+ require 'simplecov'
25
+ require 'simplecov-rcov'
26
+ require_relative 'rcov_formatter'
27
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
28
+ SimpleCov::Formatter::HTMLFormatter,
29
+ Bizside::Coverage::RcovFormatter
30
+ ])
31
+ end
32
+ private_class_method :setup
30
33
  end
31
- private_class_method :setup
32
34
  end
33
35
  end
@@ -1,12 +1,14 @@
1
- module Coverage
2
- class RcovFormatter < SimpleCov::Formatter::RcovFormatter
1
+ module Bizside
2
+ module Coverage
3
+ class RcovFormatter < SimpleCov::Formatter::RcovFormatter
3
4
 
4
- private
5
+ private
5
6
 
6
- def write_file(template, output_filename, binding)
7
- rcov_result = template.result( binding ).force_encoding('UTF-8')
8
- File.open( output_filename, "w" ) do |file_result|
9
- file_result.write rcov_result
7
+ def write_file(template, output_filename, binding)
8
+ rcov_result = template.result( binding ).force_encoding('UTF-8')
9
+ File.open( output_filename, "w" ) do |file_result|
10
+ file_result.write rcov_result
11
+ end
10
12
  end
11
13
  end
12
14
  end
@@ -121,7 +121,7 @@ module Bizside
121
121
  # config/itamae.yml:: 設定ファイル-2(*2)
122
122
  # /etc/bizside/hanaita.yml:: 設定ファイル-3
123
123
  #
124
- # (*1) RAISL_ENV に該当する部分のみ 'db' エントリの下に読み込みます。
124
+ # (*1) RAILS_ENV に該当する部分のみ 'db' エントリの下に読み込みます。
125
125
  # (*2) 指定された ROLE のみ読み込みます。
126
126
  class ItamaeConf < ItamaeConfSub
127
127
  class OverWriteError < StandardError; end
@@ -1,5 +1,5 @@
1
1
  require_relative 'coverage/launch'
2
- Bizside::CoverageLaunch.load()
2
+ Bizside::Coverage::Launch.load()
3
3
 
4
4
  module Bizside
5
5
  class Railtie < ::Rails::Railtie
@@ -159,3 +159,39 @@ end
159
159
  Resque::Failure::Multiple.configure do |multi|
160
160
  multi.classes = [Resque::Failure::Redis, Resque::Failure::LogOutput, Resque::Failure::JobAuditLog]
161
161
  end
162
+
163
+ # resque-scheduler
164
+ if defined? Resque::Scheduler
165
+ module Bizside
166
+ module ResqueScheduler
167
+ class FailureHandler
168
+ def self.on_enqueue_failure(payload, exception)
169
+ ::Resque::Scheduler::FailureHandler.on_enqueue_failure(payload, exception)
170
+
171
+ return if Bizside.rails_env&.test?
172
+
173
+ ::Bizside.logger.error [
174
+ "[FATAL] Resque::Scheduler",
175
+ "#{payload}",
176
+ "#{exception.class} #{exception.to_s}",
177
+ "#{Array(exception.backtrace).join("\n")}"
178
+ ].join("\n")
179
+
180
+ @hostname ||= (`hostname`.chomp rescue '(unknown)')
181
+ info = {
182
+ time: Time.now.strftime('%Y-%m-%dT%H:%M:%S.%3N%z'),
183
+ add_on_name: Bizside.config.add_on_name,
184
+ server_address: @hostname,
185
+ class: payload['class'],
186
+ args: payload['args'].to_s,
187
+ exception: exception.class,
188
+ exception_message: exception.to_s,
189
+ exception_backtrace: Array(exception.backtrace)[0..10].join("\n") # Get only the top 10 because there are many traces.
190
+ }
191
+ ::Bizside::Audit::JobLogger.logger.record(info)
192
+ end
193
+ end
194
+ end
195
+ end
196
+ Resque::Scheduler.failure_handler = Bizside::ResqueScheduler::FailureHandler
197
+ end
@@ -1,7 +1,7 @@
1
1
  require 'minitest/reporters'
2
2
 
3
3
  require_relative 'coverage/launch'
4
- Bizside::CoverageLaunch.load_from_test_helper()
4
+ Bizside::Coverage::Launch.load_from_test_helper()
5
5
 
6
6
  case ENV['CI'].to_s.downcase
7
7
  when 'jenkins'
@@ -1,3 +1,3 @@
1
1
  module Bizside
2
- VERSION = '2.3.8'
2
+ VERSION = '2.3.10'
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: 2.3.8
4
+ version: 2.3.10
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: 2025-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -368,7 +368,7 @@ dependencies:
368
368
  version: 1.5.0
369
369
  description: Bizside is an utilities to assist building web application.
370
370
  email:
371
- - bizside-developers@lab.acs-jp.com
371
+ - bizside-developers@bizside.biz
372
372
  executables: []
373
373
  extensions: []
374
374
  extra_rdoc_files: []
@@ -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.