-
Notifications
You must be signed in to change notification settings - Fork 734
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
UnsafeReflection requires array to be defined with values strictly in the context of the execution #1816
Comments
it is even allowing such construction ALLOWED_TYPES = Template::ALLOWED_TYPES.freeze
def template_klass
template_db = Template.find_by(code: code)
return if template_db.blank?
template_type = ALLOWED_TYPES.find { |t| t == template_db.type }
raise UnknownTemplate unless template_type
template_type.constantize
end imo it is a bug |
🤔 Yes, sounds like a bug if using Replicating Ruby's constant lookup is challenging, so this isn't terribly surprising to me. How is class Template
ALLOWED_TYPES = [...] ? |
@presidentbeef yes, it is defined like you've mentioned class Template
ALLOWED_TYPES = ['type1', 'type2'].freeze
# ...
end do you have any guesses/propositions where to look? I can handle PR with your support |
I believe it comes down to this method that adds in constants. Note the That parameter includes information about the module/class/method where the constant is defined - you can see where the info is passed in here. So the solution will likely involve converting that information into a more accurate constant name in this method. |
Background
Brakeman version: 5.4.0
Rails version: 6.1.7.1
Ruby version: 3.0.3
Link to Rails application code: ?
False Positive
Full warning from Brakeman:
?
Relevant code:
This code is not producing any warnings
Why might this be a false positive?
Why is it forcing to duplicate constants for the codebase, it should allow constants from other classes and not to be so much verbose. What do you think?
The text was updated successfully, but these errors were encountered: