* [ruby-core:92633] [Ruby trunk Bug#15847] SecureRandom#gen_random becomes private after first invocation
[not found] <redmine.issue-15847.20190513150725@ruby-lang.org>
@ 2019-05-13 15:07 ` wolf
2019-05-14 2:50 ` [ruby-core:92640] " shyouhei
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: wolf @ 2019-05-13 15:07 UTC (permalink / raw)
To: ruby-core
Issue #15847 has been reported by graywolf (Gray Wolf).
----------------------------------------
Bug #15847: SecureRandom#gen_random becomes private after first invocation
https://bugs.ruby-lang.org/issues/15847
* Author: graywolf (Gray Wolf)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
There seems to be an issue with `SecureRandom#gen_random` becoming private after first invocation:
```
+ $ /tmp/my_ruby/bin/ruby -v
ruby 2.7.0dev (2019-05-13 trunk 082bbdc92e) [x86_64-linux]
```
```
$ /tmp/my_ruby/bin/ruby \
-e 'require "securerandom"' \
-e 'SecureRandom.gen_random(1)'
$ /tmp/my_ruby/bin/ruby \
-e 'require "securerandom"' \
-e 'SecureRandom.gen_random(1)' \
-e 'SecureRandom.gen_random(1)'
Traceback (most recent call last):
-e:3:in `<main>': private method `gen_random' called for SecureRandom:Module (NoMethodError)
```
This is caused by using alias since 2.5 ruby in secure random class. Both
`.gen_random_openssl` and `.gen_random_urandom` are private class method. Using
the `alias` on them does not remove the private property, so new `.gen_random`
is private as well. Patch fixing the issue:
```
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index 37835bf7df..2b0f3753b3 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -84,7 +84,8 @@ def gen_random(n)
@rng_chooser.synchronize do
class << self
remove_method :gen_random
- alias gen_random gen_random_openssl
+ alias_method(:gen_random, :gen_random_openssl)
+ public(:gen_random)
end
end
return gen_random(n)
@@ -93,7 +94,8 @@ class << self
@rng_chooser.synchronize do
class << self
remove_method :gen_random
- alias gen_random gen_random_urandom
+ alias_method(:gen_random, :gen_random_urandom)
+ public(:gen_random)
end
end
return gen_random(n)
```
This bug is not present in 2.4.6. First noticed on 2.5.5. Examples in this
ticket are from current trunk.
--
https://bugs.ruby-lang.org/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [ruby-core:92640] [Ruby trunk Bug#15847] SecureRandom#gen_random becomes private after first invocation
[not found] <redmine.issue-15847.20190513150725@ruby-lang.org>
2019-05-13 15:07 ` [ruby-core:92633] [Ruby trunk Bug#15847] SecureRandom#gen_random becomes private after first invocation wolf
@ 2019-05-14 2:50 ` shyouhei
2019-08-01 13:18 ` [ruby-core:94094] [Ruby master " nagachika00
2019-08-26 15:13 ` [ruby-core:94571] " usa
3 siblings, 0 replies; 4+ messages in thread
From: shyouhei @ 2019-05-14 2:50 UTC (permalink / raw)
To: ruby-core
Issue #15847 has been updated by shyouhei (Shyouhei Urabe).
Thank you for reporting! It was my fault. have just pushed a fix.
----------------------------------------
Bug #15847: SecureRandom#gen_random becomes private after first invocation
https://bugs.ruby-lang.org/issues/15847#change-78003
* Author: graywolf (Gray Wolf)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
There seems to be an issue with `SecureRandom#gen_random` becoming private after first invocation:
```
+ $ /tmp/my_ruby/bin/ruby -v
ruby 2.7.0dev (2019-05-13 trunk 082bbdc92e) [x86_64-linux]
```
```
$ /tmp/my_ruby/bin/ruby \
-e 'require "securerandom"' \
-e 'SecureRandom.gen_random(1)'
$ /tmp/my_ruby/bin/ruby \
-e 'require "securerandom"' \
-e 'SecureRandom.gen_random(1)' \
-e 'SecureRandom.gen_random(1)'
Traceback (most recent call last):
-e:3:in `<main>': private method `gen_random' called for SecureRandom:Module (NoMethodError)
```
This is caused by using alias since 2.5 ruby in secure random class. Both
`.gen_random_openssl` and `.gen_random_urandom` are private class method. Using
the `alias` on them does not remove the private property, so new `.gen_random`
is private as well. Patch fixing the issue:
```
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index 37835bf7df..2b0f3753b3 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -84,7 +84,8 @@ def gen_random(n)
@rng_chooser.synchronize do
class << self
remove_method :gen_random
- alias gen_random gen_random_openssl
+ alias_method(:gen_random, :gen_random_openssl)
+ public(:gen_random)
end
end
return gen_random(n)
@@ -93,7 +94,8 @@ class << self
@rng_chooser.synchronize do
class << self
remove_method :gen_random
- alias gen_random gen_random_urandom
+ alias_method(:gen_random, :gen_random_urandom)
+ public(:gen_random)
end
end
return gen_random(n)
```
This bug is not present in 2.4.6. First noticed on 2.5.5. Examples in this
ticket are from current trunk.
--
https://bugs.ruby-lang.org/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [ruby-core:94094] [Ruby master Bug#15847] SecureRandom#gen_random becomes private after first invocation
[not found] <redmine.issue-15847.20190513150725@ruby-lang.org>
2019-05-13 15:07 ` [ruby-core:92633] [Ruby trunk Bug#15847] SecureRandom#gen_random becomes private after first invocation wolf
2019-05-14 2:50 ` [ruby-core:92640] " shyouhei
@ 2019-08-01 13:18 ` nagachika00
2019-08-26 15:13 ` [ruby-core:94571] " usa
3 siblings, 0 replies; 4+ messages in thread
From: nagachika00 @ 2019-08-01 13:18 UTC (permalink / raw)
To: ruby-core
Issue #15847 has been updated by nagachika (Tomoyuki Chikanaga).
Backport changed from 2.4: DONTNEED, 2.5: REQUIRED, 2.6: REQUIRED to 2.4: DONTNEED, 2.5: REQUIRED, 2.6: DONE
ruby_2_6 r67723 merged revision(s) 5bab1304af25a843728dbcd2f3594913740aecb0.
----------------------------------------
Bug #15847: SecureRandom#gen_random becomes private after first invocation
https://bugs.ruby-lang.org/issues/15847#change-80327
* Author: graywolf (Gray Wolf)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
* Backport: 2.4: DONTNEED, 2.5: REQUIRED, 2.6: DONE
----------------------------------------
There seems to be an issue with `SecureRandom#gen_random` becoming private after first invocation:
```
+ $ /tmp/my_ruby/bin/ruby -v
ruby 2.7.0dev (2019-05-13 trunk 082bbdc92e) [x86_64-linux]
```
```
$ /tmp/my_ruby/bin/ruby \
-e 'require "securerandom"' \
-e 'SecureRandom.gen_random(1)'
$ /tmp/my_ruby/bin/ruby \
-e 'require "securerandom"' \
-e 'SecureRandom.gen_random(1)' \
-e 'SecureRandom.gen_random(1)'
Traceback (most recent call last):
-e:3:in `<main>': private method `gen_random' called for SecureRandom:Module (NoMethodError)
```
This is caused by using alias since 2.5 ruby in secure random class. Both
`.gen_random_openssl` and `.gen_random_urandom` are private class method. Using
the `alias` on them does not remove the private property, so new `.gen_random`
is private as well. Patch fixing the issue:
```
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index 37835bf7df..2b0f3753b3 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -84,7 +84,8 @@ def gen_random(n)
@rng_chooser.synchronize do
class << self
remove_method :gen_random
- alias gen_random gen_random_openssl
+ alias_method(:gen_random, :gen_random_openssl)
+ public(:gen_random)
end
end
return gen_random(n)
@@ -93,7 +94,8 @@ class << self
@rng_chooser.synchronize do
class << self
remove_method :gen_random
- alias gen_random gen_random_urandom
+ alias_method(:gen_random, :gen_random_urandom)
+ public(:gen_random)
end
end
return gen_random(n)
```
This bug is not present in 2.4.6. First noticed on 2.5.5. Examples in this
ticket are from current trunk.
--
https://bugs.ruby-lang.org/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [ruby-core:94571] [Ruby master Bug#15847] SecureRandom#gen_random becomes private after first invocation
[not found] <redmine.issue-15847.20190513150725@ruby-lang.org>
` (2 preceding siblings ...)
2019-08-01 13:18 ` [ruby-core:94094] [Ruby master " nagachika00
@ 2019-08-26 15:13 ` usa
3 siblings, 0 replies; 4+ messages in thread
From: usa @ 2019-08-26 15:13 UTC (permalink / raw)
To: ruby-core
Issue #15847 has been updated by usa (Usaku NAKAMURA).
Backport changed from 2.4: DONTNEED, 2.5: REQUIRED, 2.6: DONE to 2.4: DONTNEED, 2.5: DONE, 2.6: DONE
ruby_2_5 r67762 merged revision(s) 5bab1304af25a843728dbcd2f3594913740aecb0.
----------------------------------------
Bug #15847: SecureRandom#gen_random becomes private after first invocation
https://bugs.ruby-lang.org/issues/15847#change-81029
* Author: graywolf (Gray Wolf)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
* Backport: 2.4: DONTNEED, 2.5: DONE, 2.6: DONE
----------------------------------------
There seems to be an issue with `SecureRandom#gen_random` becoming private after first invocation:
```
+ $ /tmp/my_ruby/bin/ruby -v
ruby 2.7.0dev (2019-05-13 trunk 082bbdc92e) [x86_64-linux]
```
```
$ /tmp/my_ruby/bin/ruby \
-e 'require "securerandom"' \
-e 'SecureRandom.gen_random(1)'
$ /tmp/my_ruby/bin/ruby \
-e 'require "securerandom"' \
-e 'SecureRandom.gen_random(1)' \
-e 'SecureRandom.gen_random(1)'
Traceback (most recent call last):
-e:3:in `<main>': private method `gen_random' called for SecureRandom:Module (NoMethodError)
```
This is caused by using alias since 2.5 ruby in secure random class. Both
`.gen_random_openssl` and `.gen_random_urandom` are private class method. Using
the `alias` on them does not remove the private property, so new `.gen_random`
is private as well. Patch fixing the issue:
```
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index 37835bf7df..2b0f3753b3 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -84,7 +84,8 @@ def gen_random(n)
@rng_chooser.synchronize do
class << self
remove_method :gen_random
- alias gen_random gen_random_openssl
+ alias_method(:gen_random, :gen_random_openssl)
+ public(:gen_random)
end
end
return gen_random(n)
@@ -93,7 +94,8 @@ class << self
@rng_chooser.synchronize do
class << self
remove_method :gen_random
- alias gen_random gen_random_urandom
+ alias_method(:gen_random, :gen_random_urandom)
+ public(:gen_random)
end
end
return gen_random(n)
```
This bug is not present in 2.4.6. First noticed on 2.5.5. Examples in this
ticket are from current trunk.
--
https://bugs.ruby-lang.org/
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-08-26 15:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-15847.20190513150725@ruby-lang.org>
2019-05-13 15:07 ` [ruby-core:92633] [Ruby trunk Bug#15847] SecureRandom#gen_random becomes private after first invocation wolf
2019-05-14 2:50 ` [ruby-core:92640] " shyouhei
2019-08-01 13:18 ` [ruby-core:94094] [Ruby master " nagachika00
2019-08-26 15:13 ` [ruby-core:94571] " usa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).