diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2b14b1b3..bf5c312a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ == ruote - 2.1.12 not yet released +- using Sourcify to store block participant's code as a string - CompositeStorage#delete bug fix (Thanks Claudio) - ParticipantList#register bug fix (Thanks 'sandbox') - StorageHistory#wfids and DefaultHistory#wfids diff --git a/lib/ruote/svc/participant_list.rb b/lib/ruote/svc/participant_list.rb index a271a32e..08e32da9 100644 --- a/lib/ruote/svc/participant_list.rb +++ b/lib/ruote/svc/participant_list.rb @@ -47,15 +47,19 @@ def initialize (context) # def register (name, participant, options, block) + klass = (participant || Ruote::BlockParticipant).to_s + options = options.inject({}) { |h, (k, v)| h[k.to_s] = v.is_a?(Symbol) ? v.to_s : v h } - options['block'] = block.to_source if block - key = (name.is_a?(Regexp) ? name : Regexp.new("^#{name}$")).source + if block + options['block'] = block.to_source + @context.treechecker.block_check(options['block']) + end - klass = (participant || Ruote::BlockParticipant).to_s + key = (name.is_a?(Regexp) ? name : Regexp.new("^#{name}$")).source entry = [ key, [ klass, options ] ] diff --git a/test/functional/ft_24_block_participant.rb b/test/functional/ft_24_block_participant.rb index 6bca7725..4488e739 100644 --- a/test/functional/ft_24_block_participant.rb +++ b/test/functional/ft_24_block_participant.rb @@ -107,5 +107,15 @@ def test_raise_security_error_before_evaluating_rogue_code FileUtils.rm(fn) rescue nil end + + def test_raise_security_error_upon_registering_rogue_block_participant + + assert_raise Rufus::SecurityError do + + @engine.register 'rogue' do |workitem| + workitem.content = File.read('test/nada.txt') + end + end + end end