-
Notifications
You must be signed in to change notification settings - Fork 767
Open
Milestone
Description
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: ?
Confidence: Medium
Category: Remote Code Execution
Check: UnsafeReflection
Message: Unsafe reflection method `constantize` called on model attribute
Code: Template::ALLOWED_TYPES.find do (t == Template.find_by(:code => code).type) end.constantize
File: app/services/finder.rb
Line: 40
Relevant code:
def template_klass
template_db = Template.find_by(code: code)
return if template_db.blank?
template_type = Template::ALLOWED_TYPES.find { |t| t == template_db.type }
raise UnknownTemplate unless template_type
template_type.constantize
endThis code is not producing any warnings
def template_klass
template_db = Template.find_by(code: code)
return if template_db.blank?
template_type = ['type1', 'type2'].find { |t| t == template_db.type }
raise UnknownTemplate unless template_type
template_type.constantize
endWhy 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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels