Unsafe reflection method constantize called with parameter value Open
@relationable = params[:relationable_klass].singularize.camelize.constantize.find_by(id: params[:relationable_id])
- Read upRead up
- Exclude checks
Brakeman reports on several cases of remote code execution, in which a user is able to control and execute code in ways unintended by application authors.
The obvious form of this is the use of eval
with user input.
However, Brakeman also reports on dangerous uses of send
, constantize
, and other methods which allow creation of arbitrary objects or calling of arbitrary methods.
Unsafe reflection method constantize called with parameter value Open
@related = related_klass.singularize.camelize.constantize.find_by(id: related_id)
- Read upRead up
- Exclude checks
Brakeman reports on several cases of remote code execution, in which a user is able to control and execute code in ways unintended by application authors.
The obvious form of this is the use of eval
with user input.
However, Brakeman also reports on dangerous uses of send
, constantize
, and other methods which allow creation of arbitrary objects or calling of arbitrary methods.
Method create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create
if relationable_object && related_object
if relationable_object.url != related_object.url
RelatedContent.create(parent_relationable: @relationable, child_relationable: @related, author: current_user)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Line is too long. [118/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
@relationable = params[:relationable_klass].singularize.camelize.constantize.find_by(id: params[:relationable_id])
- Exclude checks
Line is too long. [117/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits) Open
RelatedContent.create(parent_relationable: @relationable, child_relationable: @related, author: current_user)
- Exclude checks