Module: Evilution::Parallel::WorkQueue::Channel::Frame

Defined in:
lib/evilution/parallel/work_queue/channel/frame.rb

Class Method Summary collapse

Class Method Details

.decode(header, payload) ⇒ Object

Marshal.load is safe here: payload originates from a sibling worker the parent itself forked, transferred over a private pipe inside our process tree. No external/untrusted input ever reaches this code. See .rubocop.yml (Security/MarshalLoad) for the full rationale.



17
18
19
20
21
22
23
24
# File 'lib/evilution/parallel/work_queue/channel/frame.rb', line 17

def decode(header, payload)
  return nil if header.nil? || header.bytesize < 4

  length = header.unpack1("N")
  return nil if payload.nil? || payload.bytesize < length

  Marshal.load(payload)
end

.encode(object) ⇒ Object



8
9
10
11
# File 'lib/evilution/parallel/work_queue/channel/frame.rb', line 8

def encode(object)
  payload = Marshal.dump(object)
  [payload.bytesize].pack("N") + payload
end