app/controllers/variables_controller.rb
Unsafe reflection method constantize called with parameter value Open
Open
@source ||= params[:other][:class].constantize.send(:find, params[:other][:id]) rescue nil
- Read upRead up
- Create a ticketCreate a ticket
- 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 add_sources
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def add_sources
head :bad_request if params[:sources].nil?
params[:sources] = JSON.parse(params[:sources]) if params[:sources].is_a?(String)
- Read upRead up
- Create a ticketCreate a ticket
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"