selenium_tor 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a9593a60ababf45d1e54bf5583d46bb778b4e34c86559189eda2f855436acb8
4
- data.tar.gz: c8e3250798ac2b5b1be3d61d1971e155bc648d0882f5998cf8fc9f7818157ba0
3
+ metadata.gz: 3bb9b5a97f55ceb2d55b2940a6475c2ef9175759a17e938e9b1d1d1b51517df3
4
+ data.tar.gz: e232a3b3ad7c3afff9221c08977743f39040e5adbd33813f6fe3b6b07c425b83
5
5
  SHA512:
6
- metadata.gz: edc94603c8979106bde423b38e00465c7038168742060c2a3e4880eb870a4910727b14701398a409d305273f3eb7547769ad5610d89d18c806edc76d5e61c706
7
- data.tar.gz: 3f3157dde56b05f7046df3364a49a8f5d57586828dce22697b9fbe5d3e86d0b866ba60b20124da4635eb7aa4457589b2f4be9daac94139321d5aa16405f015ed
6
+ metadata.gz: 5cd45536c48760c84936bd4cb26b8b495f65d5b6dd488b7af3e312ed9b725143ea0a56508021cef889f6aef14daca1ccfe6c11681a1ccaecb118c0b6a62d8237
7
+ data.tar.gz: f81ee65b98ccdc460816f1647cfc738dc31a7b529ea235e2fb5065c90379d5f2e0d9f46dd2edbb1c62bb75eb0d3b33a4cfe1518c24027a82b313a09c17683761
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  ## master (unreleased)
2
2
 
3
- ## [2.0.0] - 2025-05-31
3
+ ## [2.1.0] - 2025-06-24
4
+
5
+ ### New features
6
+
7
+ * Support the [UX security level changes](https://gitlab.torproject.org/tpo/applications/tor-browser/-/issues/43783) introduced in 14.5.4
8
+ * libxul.so patch checksums are now derived from a repo file, not the copy bundled with the gem [#21](https://gitlab.com/matzfan/selenium-tor/-/issues/21)
9
+
10
+ ### Bug fixes
11
+
12
+ * Fix bug in Tor::Driver rescuing from TorProcessError
13
+
14
+ ## [2.0.1] - 2025-06-02
4
15
 
5
16
  * fix bug loading selenium-webdriver in IRB
6
17
 
data/README.md CHANGED
@@ -100,14 +100,13 @@ Each Driver instance uses a separate data directory for `torrc` and other files.
100
100
 
101
101
  ### Tor Browser specific functionality
102
102
 
103
- You can get and set the security level (shield icon in TB) as follows. 4 is 'Standard', 2 is 'Safer', 1 is 'Safest'.
103
+ You can get ~~and set~~ the security level (shield icon in TB) with the `Driver#security_level` method. 4 is 'Standard', 2 is 'Safer', 1 is 'Safest'.
104
104
  ```ruby
105
105
  @driver.security_level
106
106
  # => 4
107
- @driver.security_level = 2
108
- @driver.security_level
109
- # => 2
110
107
  ```
108
+ With the [14.5.4 release](https://forum.torproject.org/t/new-release-tor-browser-14-5-4/19562) the ability the change the security level within a session was removed. To start a browser with a non-default security level (which is 4) set the preference "browser.security_level.security_slider" value in `Tor::Options` - e.g: `options.add_preference('browser.security_level.security_slider', 1)`.
109
+
111
110
  You can get a new circuit for the current page ('New Tor circuit for this site' on TB's application menu):
112
111
  ```ruby
113
112
  @driver.new_circuit_for_site # new circuit for the current page domain
data/lib/tor/driver.rb CHANGED
@@ -58,11 +58,12 @@ module Selenium
58
58
  pref[PREF_BROWSER_SECURITY_LEVEL]
59
59
  end
60
60
 
61
- def security_level=(int)
62
- raise(ArgumentError, "Valid security levels are: #{TB_SEC_LEVELS.values}") unless TB_SEC_LEVELS.value?(int)
61
+ # DEPRECATED in 14.5.4
62
+ # def security_level=(int)
63
+ # raise(ArgumentError, "Valid security levels are: #{TB_SEC_LEVELS.values}") unless TB_SEC_LEVELS.value?(int)
63
64
 
64
- pref[PREF_BROWSER_SECURITY_LEVEL] = int
65
- end
65
+ # pref[PREF_BROWSER_SECURITY_LEVEL] = int
66
+ # end
66
67
 
67
68
  def new_circuit_for_site
68
69
  execute_script_in_chrome_context es6_function_call(es6: DOMAIN_ISOLATOR, func: NEW_CIRCUIT, args: domain)
@@ -84,7 +85,7 @@ module Selenium
84
85
  timeout = opts.delete :timeout
85
86
  @tor_process = create_tor_process(opts)
86
87
  @tor_process.start_tor(timeout: timeout)
87
- rescue Tor::TorProcess::TorProcessError => e
88
+ rescue Tor::TorProcessError => e
88
89
  instance_variable_get(:@instance)&.quit # avoids hanging firefox.real process
89
90
  raise Error::WebDriverError, e
90
91
  end
@@ -1,4 +1,8 @@
1
1
  ---
2
+ 14.5.4:
3
+ unpatched_libxul: e2b89720c2a168ab948a329569d34495bdce18744b8c2f79a8dddb9d120a6aed
4
+ patched_libxul: a687d91f0314fcc194b71e10b85a2a3be267ee2302feb0d72ed0db790af2dffa
5
+ patch_checksum: 2c250375f54ee4f072a4259e691e0790d1190e1027159593b863a3a8b93daa11
2
6
  14.5.3:
3
7
  unpatched_libxul: 88c9aef61ca0df4c617a8c7c589194bd8ff31d1d7a6360512e1ab1cfc81390a8
4
8
  patched_libxul: 18e6f350a2a8983395ffac984aac1a7a431d2acb0c97faa69d6f965199b67e2c
@@ -14,15 +14,21 @@ module Selenium
14
14
  module Tor
15
15
  # methods to patch/unpatch libxul.so
16
16
  module LibxulPatchable
17
- PATCH_REPO_URL = 'https://gitlab.com/matzfan/keymaster/-/raw/master/patches/tor-browser'
18
- ISSUES_URL = 'https://gitlab.com/matzfan/keymaster/-/issues'
19
- NO_PATCH_MSG = "No patch for #{Tor::TBB_VERSION}, please raise an issue at #{ISSUES_URL}".freeze
20
- UNDEF_REGEXP = /undefined method (`|')\[\]' for nil/
17
+ THIS_REPO = 'https://gitlab.com/matzfan/selenium-tor'
18
+ LIBXUL_CHECKSUMS_FILE = 'libxul_checksums.yml'
19
+ REPO_LIBXUL_CHECKSUMS = "#{THIS_REPO}/-/raw/master/lib/tor/#{LIBXUL_CHECKSUMS_FILE}".freeze
20
+
21
+ PATCH_REPO_URL = 'https://gitlab.com/matzfan/keymaster'
22
+ PATCH_REPO_PATCHES_URL = "#{PATCH_REPO_URL}/-/raw/master/patches/tor-browser".freeze
23
+ ISSUES_URL = "#{PATCH_REPO_URL}/-/issues".freeze
24
+
25
+ NO_PATCH_MSG = "No patch for #{Tor::TBB_VERSION}, please raise an issue at #{ISSUES_URL}".freeze
26
+ INVALID = "Invalid patch for #{Tor::TBB_VERSION}, please raise an issue at #{ISSUES_URL}".freeze
21
27
 
22
28
  def libxul_patched?
23
29
  libxul_checksum = checksum_for Tor::TBB_LIBXUL
24
- return true if patched_libxul_checksum_for_version == libxul_checksum
25
- return false if unpatched_libxul_checksum_for_version == libxul_checksum
30
+ return true if libxul_checksums['patched_libxul'] == libxul_checksum
31
+ return false if libxul_checksums['unpatched_libxul'] == libxul_checksum
26
32
 
27
33
  raise Tor::LibxulPatchableError, 'Unrecognized libxul.so'
28
34
  end
@@ -56,8 +62,7 @@ module Selenium
56
62
  end
57
63
 
58
64
  def valid?(patchfile)
59
- msg = "Invalid patch for #{Tor::TBB_VERSION}, please raise an issue at #{ISSUES_URL}"
60
- raise Tor::LibxulPatchableError, msg unless patch_checksum_for_version == checksum_for(patchfile)
65
+ raise Tor::LibxulPatchableError, INVALID unless libxul_checksums['patch_checksum'] == checksum_for(patchfile)
61
66
  end
62
67
 
63
68
  def execute_patch(patchfile)
@@ -65,31 +70,18 @@ module Selenium
65
70
  end
66
71
 
67
72
  def libxul_checksums
68
- @libxul_checksums ||= YAML.load_file(File.join(__dir__, 'libxul_checksums.yml'))[Tor::TBB_VERSION]
69
- end
73
+ @libxul_checksums ||= local_checksums&.merge repo_checksums
74
+ raise Tor::LibxulPatchableError, NO_PATCH_MSG unless @libxul_checksums
70
75
 
71
- def unpatched_libxul_checksum_for_version
72
- libxul_checksums['unpatched_libxul']
73
- rescue NoMethodError => e
74
- raise Tor::LibxulPatchableError, NO_PATCH_MSG if e.message.match UNDEF_REGEXP
75
-
76
- raise e
76
+ @libxul_checksums
77
77
  end
78
78
 
79
- def patched_libxul_checksum_for_version
80
- libxul_checksums['patched_libxul']
81
- rescue NoMethodError => e
82
- raise Tor::LibxulPatchableError, NO_PATCH_MSG if e.message.match UNDEF_REGEXP
83
-
84
- raise e
79
+ def local_checksums
80
+ YAML.load_file(File.join(__dir__, 'libxul_checksums.yml'))[Tor::TBB_VERSION]
85
81
  end
86
82
 
87
- def patch_checksum_for_version
88
- libxul_checksums['patch_checksum']
89
- rescue NoMethodError => e
90
- raise Tor::LibxulPatchableError, NO_PATCH_MSG if e.message.match UNDEF_REGEXP
91
-
92
- raise e
83
+ def repo_checksums
84
+ YAML.load(URI(REPO_LIBXUL_CHECKSUMS).read)[Tor::TBB_VERSION]
93
85
  end
94
86
 
95
87
  def checksum_for(file)
@@ -106,7 +98,7 @@ module Selenium
106
98
  end
107
99
 
108
100
  def patch_url
109
- File.join PATCH_REPO_URL, "#{Tor::TBB_VERSION}.patch"
101
+ File.join PATCH_REPO_PATCHES_URL, "#{Tor::TBB_VERSION}.patch"
110
102
  end
111
103
  end
112
104
  end
data/lib/tor/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Selenium
4
4
  module WebDriver
5
5
  module Tor
6
- VERSION = '2.0.1'
6
+ VERSION = '2.1.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium_tor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MatzFan