-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safer loading for translation repositories #97
base: master
Are you sure you want to change the base?
Conversation
- Do not use a relative path for require, as it fails with safe mode enabled. - Check the repository type against a whitelist of existing repositories This fixes the two specs marked as pending on Ruby 2.x
class_name = type.to_s.split('_').map(&:capitalize).join | ||
unless FastGettext::TranslationRepository.constants.map{|c|c.to_s}.include?(class_name) | ||
require "fast_gettext/translation_repository/#{type}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just .untaint
here ?
being able to load any kind of backend was meant as a feature ... |
A I think this may be a bug in rubygems similar to rubygems/rubygems#1265 |
That was merged ... so upgrade rubygems ?
rubygems/rubygems#1268
…On Thu, Aug 17, 2017 at 9:15 AM, Renaud Chaput ***@***.***> wrote:
A SecurityError is raised when using require "fast_gettext/translation_
repository/#{type}".untaint.
I think this may be a bug in rubygems similar to rubygems/rubygems#1265
<rubygems/rubygems#1265>
I need to investigate further why this is happening if relying on
$LOAD_PATH is wanted.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#97 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAsZ9ty2tWuQDVBXwVPVTXK3LhTnUu1ks5sZGcTgaJpZM4O5_C_>
.
|
Yes this one has been merged, but the problem still occurs with a recent Rubygem. |
... silly workaround would be to not allow outside loading if running in
safe mode ?
... should be good enough for the 99% case ...
…On Thu, Aug 17, 2017 at 9:31 AM, Renaud Chaput ***@***.***> wrote:
Yes this one has been merged, but the problem still occurs with a recent
Rubygem.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#97 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAsZzdimS60MlM9ctzmtzkfhzrKwRenks5sZGrtgaJpZM4O5_C_>
.
|
I will try to debug it and find out the real cause |
ddd5db9
to
eb5d893
Compare
This fixes the two specs marked as pending on Ruby 2.x.
I am not 100% sure here about the relative path. Are there some wanted cases where the previous require will require another file when using the
LOAD_PATH
?__dir__
and%i[]
are only available in Ruby 2.x. I do not think this will be a problem.