Module: Selenium::WebDriver::Tor::LibxulPatchable

Included in:
Driver
Defined in:
lib/tor/libxul_patchable.rb

Overview

methods to patch/unpatch libxul.so

Constant Summary collapse

THIS_REPO =
'https://gitlab.com/matzfan/selenium-tor'
LIBXUL_CHECKSUMS_FILE =
'libxul_checksums.yml'
REPO_LIBXUL_CHECKSUMS =
"#{THIS_REPO}/-/raw/master/lib/tor/#{LIBXUL_CHECKSUMS_FILE}".freeze
PATCH_REPO_URL =
'https://gitlab.com/matzfan/keymaster'
PATCH_REPO_PATCHES_URL =
"#{PATCH_REPO_URL}/-/raw/master/patches/tor-browser".freeze
ISSUES_URL =
"#{PATCH_REPO_URL}/-/issues".freeze
NO_PATCH_MSG =
"No patch for #{Tor::TBB_VERSION}, please raise an issue at #{ISSUES_URL}".freeze
INVALID =
"Invalid patch for #{Tor::TBB_VERSION}, please raise an issue at #{ISSUES_URL}".freeze

Instance Method Summary collapse

Instance Method Details

#libxul_patched?Boolean

Returns:

  • (Boolean)

Raises:



28
29
30
31
32
33
34
# File 'lib/tor/libxul_patchable.rb', line 28

def libxul_patched?
  libxul_checksum = checksum_for Tor::TBB_LIBXUL
  return true if libxul_checksums['patched_libxul'] == libxul_checksum
  return false if libxul_checksums['unpatched_libxul'] == libxul_checksum

  raise Tor::LibxulPatchableError, 'Unrecognized libxul.so'
end

#patch_libxulObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/tor/libxul_patchable.rb', line 36

def patch_libxul
  return if libxul_patched?

  patchfile = fetch_patchfile
  valid? patchfile
  FileUtils.mv Tor::TBB_LIBXUL, libxul_original # rename libxul.so
  execute_patch patchfile
  FileUtils.cp libxul_patched, Tor::TBB_LIBXUL
rescue OpenURI::HTTPError
  raise Tor::LibxulPatchableError, NO_PATCH_MSG
end

#unpatch_libxulObject



48
49
50
51
52
# File 'lib/tor/libxul_patchable.rb', line 48

def unpatch_libxul
  return unless libxul_patched?

  FileUtils.mv libxul_original, Tor::TBB_LIBXUL
end