selenium_tor 2.0.0 → 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 +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +5 -6
- data/lib/selenium_tor.rb +2 -1
- data/lib/tor/driver.rb +6 -5
- data/lib/tor/libxul_checksums.yml +4 -0
- data/lib/tor/libxul_patchable.rb +21 -29
- data/lib/tor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bb9b5a97f55ceb2d55b2940a6475c2ef9175759a17e938e9b1d1d1b51517df3
|
4
|
+
data.tar.gz: e232a3b3ad7c3afff9221c08977743f39040e5adbd33813f6fe3b6b07c425b83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cd45536c48760c84936bd4cb26b8b495f65d5b6dd488b7af3e312ed9b725143ea0a56508021cef889f6aef14daca1ccfe6c11681a1ccaecb118c0b6a62d8237
|
7
|
+
data.tar.gz: f81ee65b98ccdc460816f1647cfc738dc31a7b529ea235e2fb5065c90379d5f2e0d9f46dd2edbb1c62bb75eb0d3b33a4cfe1518c24027a82b313a09c17683761
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
## master (unreleased)
|
2
2
|
|
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
|
15
|
+
|
16
|
+
* fix bug loading selenium-webdriver in IRB
|
17
|
+
|
3
18
|
## [2.0.0] - 2025-05-31
|
4
19
|
|
5
20
|
### New features
|
data/README.md
CHANGED
@@ -77,7 +77,7 @@ In addition to the regular Firefox options, a `:tor_opts` key may be passed to a
|
|
77
77
|
|
78
78
|
### Multiple driver instances
|
79
79
|
|
80
|
-
Running multiple tor processes requires that each uses different ports for SocksPort (and ControlPort, if used). From version 2.0 the SocksPort is auto selected, so no
|
80
|
+
Running multiple tor processes requires that each uses different ports for SocksPort (and ControlPort, if used). From version 2.0 the SocksPort is auto selected, so no configuration is required. An example using the [Parallel gem](https://rubygems.org/gems/parallel):
|
81
81
|
```ruby
|
82
82
|
require 'parallel'
|
83
83
|
|
@@ -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)
|
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
|
@@ -157,7 +156,7 @@ The patcher uses the [Bsdiff](https://gitlab.com/matzfan/bsdiff) gem.
|
|
157
156
|
|
158
157
|
### Exceptions
|
159
158
|
|
160
|
-
Tor-specific webdriver
|
159
|
+
Tor-specific webdriver functionality raises `Tor::Error` or a subclass. `Tor::Error` itself subclasses `WebDriver::Error::WebDriverError`
|
161
160
|
|
162
161
|
## Known issues
|
163
162
|
|
data/lib/selenium_tor.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
ENV['SE_OFFLINE'] = 'true' # we don't want selenium-manager getting & using firefox in error
|
4
4
|
ENV['SE_AVOID_STATS'] = 'true' # no telemetry thanks!
|
5
5
|
|
6
|
-
|
6
|
+
require 'selenium-webdriver'
|
7
|
+
load $LOADED_FEATURES.last # force load to ensure env vars are applied
|
7
8
|
|
8
9
|
require_relative 'driver'
|
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
|
-
|
62
|
-
|
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
|
-
|
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::
|
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
|
data/lib/tor/libxul_patchable.rb
CHANGED
@@ -14,15 +14,21 @@ module Selenium
|
|
14
14
|
module Tor
|
15
15
|
# methods to patch/unpatch libxul.so
|
16
16
|
module LibxulPatchable
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
25
|
-
return false if
|
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
|
-
|
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 ||=
|
69
|
-
|
73
|
+
@libxul_checksums ||= local_checksums&.merge repo_checksums
|
74
|
+
raise Tor::LibxulPatchableError, NO_PATCH_MSG unless @libxul_checksums
|
70
75
|
|
71
|
-
|
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
|
80
|
-
libxul_checksums[
|
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
|
88
|
-
|
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
|
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