Skip to content

Commit

Permalink
checking block participant code when registering
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Jan 30, 2011
1 parent 3003306 commit 9f4b6c9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions lib/ruote/svc/participant_list.rb
Expand Up @@ -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 ] ]

Expand Down
10 changes: 10 additions & 0 deletions test/functional/ft_24_block_participant.rb
Expand Up @@ -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

0 comments on commit 9f4b6c9

Please sign in to comment.