rservicebus2 0.2.20 → 0.2.25

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: f586d7a257549f1a8bbac85940e7740bc6927928b75e3254254cf1a945aefa38
4
- data.tar.gz: 3e2352c5ddebf9cb4583a67106e4286a54f0b75f67c0fa1f485b56bd70c1dd94
3
+ metadata.gz: ae906c0d751849d9f4843a7b8ca164398597fd9f7fd88a6673b7d4851e2f1672
4
+ data.tar.gz: e0b563cf71559ff0565af68132bb31035e292098cf9f2716b086b6293daa8481
5
5
  SHA512:
6
- metadata.gz: efbdcb52173f9caff80c659e2aae973deeaef5d9cc5adf31d9d251f8c88ef6cf1b212514ed07a88ab36efb7e5e84b83d1938710e5b50ae50049b0b04907df325
7
- data.tar.gz: 5aeed54b1b619ba5f6b6a2c9221e868770575f88c18f3426ff23ee46abfc7ff62424c5a3a1609e5487bb36e0b0f1b5edfa09ac8cf920b64a4d5a385f3c26434f
6
+ metadata.gz: 69c1d0ff2b0c93f087dd5a9daf57040f132e0d3e513ef591b608c35f7ef350daa7ac0e5640d72e254f5358e12cb09d23c517cc8c61018d53eb2b9beee5c82f45
7
+ data.tar.gz: e26625aa44347b9f604fa6f64f9344cca6509fe952240439092c96252c458d910ac620331554aa93914aaf51d3feb895912e53eb1c3ad2014dc3e7eca8bab33e
data/lib/rservicebus2.rb CHANGED
@@ -23,6 +23,7 @@ require 'rservicebus2/config'
23
23
  require 'rservicebus2/endpointmapping'
24
24
  require 'rservicebus2/statistic_manager'
25
25
  require 'rservicebus2/audit'
26
+ require 'rservicebus2/yaml_safe_loader'
26
27
 
27
28
  require 'rservicebus2/message'
28
29
  require 'rservicebus2/message/subscription'
@@ -140,10 +140,8 @@ module RServiceBus2
140
140
  next if file_path.end_with?('.')
141
141
 
142
142
  msg_name = get_msg_name(file_path)
143
- RServiceBus2.add_to_permitted_classes(
144
- msg_name.gsub(/(?<=_|^)(\w)/) { Regexp.last_match(1).upcase }.gsub(/(?:_)(\w)/, '\1')
145
- )
146
-
143
+ YamlSafeLoader.instance.add_permitted_class(msg_name
144
+ .gsub(/(?<=_|^)(\w)/) { Regexp.last_match(1).upcase }.gsub(/(?:_)(\w)/, '\1'))
147
145
  if File.directory?(file_path)
148
146
  load_handlers_from_second_level_path(msg_name, file_path)
149
147
  next
@@ -4,22 +4,9 @@ require 'csv'
4
4
 
5
5
  # Helper functions
6
6
  module RServiceBus2
7
- DEFAULT_PERMITTED_CLASSES = 'RServiceBus2::Message,Time,UUIDTools::UUID'
8
-
9
- def self.permitted_classes
10
- permitted_classes_string = get_value('PERMITTED_CLASSES', DEFAULT_PERMITTED_CLASSES)
11
- CSV.parse(permitted_classes_string)[0]
12
- end
13
-
14
- def self.add_to_permitted_classes(string)
15
- ENV['PERMITTED_CLASSES'] = permitted_classes
16
- .push(string)
17
- .uniq
18
- .to_csv
19
- end
20
-
21
7
  def self.safe_load(body)
22
- YAML.safe_load(body, permitted_classes: permitted_classes)
8
+ # YAML.safe_load(body, permitted_classes: Module.constants)
9
+ YamlSafeLoader.instance.load(body)
23
10
  end
24
11
 
25
12
  def self.convert_dto_to_hash(obj)
@@ -52,6 +39,8 @@ module RServiceBus2
52
39
  end
53
40
 
54
41
  def self.create_anonymous_class(name_for_class)
42
+ Module.const_get(name_for_class)
43
+ rescue NameError
55
44
  new_anonymous_class = Class.new(Object)
56
45
  Object.const_set(name_for_class, new_anonymous_class)
57
46
  Object.const_get(name_for_class).new
@@ -99,6 +99,7 @@ module RServiceBus2
99
99
 
100
100
  def initialize
101
101
  RServiceBus2.rlog "Current directory: #{Dir.pwd}"
102
+ YamlSafeLoader.instance
102
103
  @config = ConfigFromEnv.new
103
104
  .load_host_section
104
105
  .load_contracts
@@ -146,7 +146,8 @@ module RServiceBus2
146
146
  process_path(file_path)
147
147
 
148
148
  file_processed += 1
149
- RServiceBus2.log "Processed #{file_processed} of #{file_list.length}.\nAllow system tick #{self.class.name}"
149
+ RServiceBus2.log "Processed #{file_processed} of #{file_list.length}."
150
+ RServiceBus2.log "Allow system tick #{self.class.name}"
150
151
 
151
152
  break if file_processed >= max_files_processed
152
153
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'csv'
4
+ require 'singleton'
5
+
6
+ # YamlSafeLoader
7
+ class YamlSafeLoader
8
+ include Singleton
9
+
10
+ DEFAULT_PERMITTED_CLASSES = 'RServiceBus2::Message,RServiceBus2::ErrorMessage,Time,UUIDTools::UUID,YamlSafeLoader,' \
11
+ 'URI::Generic,URI::RFC3986_Parser,Symbol,Regexp'
12
+
13
+ def initialize
14
+ string = "#{RServiceBus2.get_value('PERMITTED_CLASSES_BASE', DEFAULT_PERMITTED_CLASSES)}," \
15
+ "#{RServiceBus2.get_value('PERMITTED_CLASSES', '')}"
16
+ @permitted_classes = CSV.parse(string)[0].reject { |c| c.to_s.rstrip.empty? }
17
+ end
18
+
19
+ def add_permitted_class(string)
20
+ @permitted_classes << string
21
+ @permitted_classes.uniq!
22
+ end
23
+
24
+ def load(body)
25
+ YAML.safe_load(body, permitted_classes: @permitted_classes)
26
+ end
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rservicebus2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.20
4
+ version: 0.2.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Irvine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-31 00:00:00.000000000 Z
11
+ date: 2021-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beanstalk-client
@@ -165,6 +165,7 @@ files:
165
165
  - lib/rservicebus2/test/bus.rb
166
166
  - lib/rservicebus2/transporter.rb
167
167
  - lib/rservicebus2/usermessage/withpayload.rb
168
+ - lib/rservicebus2/yaml_safe_loader.rb
168
169
  homepage: http://rubygems.org/gems/rservicebus2
169
170
  licenses:
170
171
  - LGPL-3.0