Class: Audition::Dynamic::Prober

Inherits:
Object
  • Object
show all
Defined in:
lib/audition/dynamic/prober.rb

Overview

Spawns the harness subprocess per probe mode, parses its JSON, and converts observations into findings.

Constant Summary collapse

HARNESS =
File.expand_path("harness.rb", __dir__)
RUNTIME_WHY =
"Observed on the live object graph after loading the " \
"target; this is ground truth, not a static guess."

Instance Method Summary collapse

Constructor Details

#initialize(ruby: RbConfig.ruby, timeout: 30) ⇒ Prober

Returns a new instance of Prober.

Parameters:

  • ruby (String) (defaults to: RbConfig.ruby)

    Ruby executable for the harness

  • timeout (Integer) (defaults to: 30)

    seconds before a probe subprocess is killed



34
35
36
37
# File 'lib/audition/dynamic/prober.rb', line 34

def initialize(ruby: RbConfig.ruby, timeout: 30)
  @ruby = ruby
  @timeout = timeout
end

Instance Method Details

#probe(entry) ⇒ Result

Runs the probe described by a Target#entry hash.

Parameters:

  • entry (Hash)

    :mode plus mode-specific keys

Returns:

Raises:



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/audition/dynamic/prober.rb', line 44

def probe(entry)
  case (entry[:mode] || entry["mode"]).to_sym
  when :script then probe_script(entry)
  when :require then probe_require(entry)
  when :rack then probe_rack(entry)
  when :rails then probe_rails(entry)
  when :capabilities then probe_capabilities
  else
    raise Error, "unknown dynamic probe mode in #{entry}"
  end
end