Module: OneGadget::Fetcher::ClassMethods

Included in:
OneGadget::Fetcher
Defined in:
lib/one_gadget/fetcher.rb

Overview

Define class methods here.

Instance Method Summary collapse

Instance Method Details

#from_build_id(build_id, remote: true) ⇒ Array<OneGadget::Gadget::Gadget>?

Fetch one-gadget offsets of this build id.


19
20
21
22
# File 'lib/one_gadget/fetcher.rb', line 19

def from_build_id(build_id, remote: true)
  OneGadget::Helper.verify_build_id!(build_id)
  OneGadget::Gadget.builds(build_id, remote: remote)
end

#from_file(file) ⇒ Array<OneGadget::Gadget::Gadget>

Fetch one-gadget offsets from file.


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/one_gadget/fetcher.rb', line 28

def from_file(file)
  arch = OneGadget::Helper.architecture(file)
  klass = {
    aarch64: OneGadget::Fetcher::AArch64,
    amd64: OneGadget::Fetcher::Amd64,
    i386: OneGadget::Fetcher::I386
  }[arch]
  raise Error::UnsupportedArchitectureError, arch if klass.nil?

  trim_gadgets(klass.new(file).find)
end