Odania-IT/odania-gem

View on GitHub

Showing 25 of 25 total issues

OS Command Injection in Rake
Open

    rake (10.5.0)
Severity: Critical
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2020-8130

Criticality: High

URL: https://github.com/advisories/GHSA-jppv-gw3r-w3q8

Solution: upgrade to >= 12.3.3

json Gem for Ruby Unsafe Object Creation Vulnerability (additional fix)
Open

    json (1.8.3)
Severity: Critical
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2020-10663

Criticality: High

URL: https://www.ruby-lang.org/en/news/2020/03/19/json-dos-cve-2020-10663/

Solution: upgrade to >= 2.3.0

Method add_plugin_config has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

            def add_plugin_config(plugin_cfg)
                config_section = plugin_cfg['config']
                group_name = plugin_cfg['plugin-config']['name']

                if $debug
Severity: Minor
Found in lib/odania/config/global_config.rb - About 2 hrs to fix

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

Cyclomatic complexity for add_plugin_config is too high. [9/6]
Open

            def add_plugin_config(plugin_cfg)
                config_section = plugin_cfg['config']
                group_name = plugin_cfg['plugin-config']['name']

                if $debug
Severity: Minor
Found in lib/odania/config/global_config.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for load is too high. [7/6]
Open

            def load(data)
                reset
                @config = data['config'] unless data['config'].nil?
                @plugin_config = data['plugin-config'] unless data['plugin-config'].nil?
                @valid_domains = data['valid_domains'] unless data['valid_domains'].nil?
Severity: Minor
Found in lib/odania/config/plugin_config.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for load_global_config is too high. [7/6]
Open

            def load_global_config(config)
                throw 'Invalid global config!' if config.nil?

                reset
                @default_backend_groups = config['default_backend_groups'] unless config['default_backend_groups'].nil?
Severity: Minor
Found in lib/odania/config/global_config.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for generate_merged_partials is too high. [7/6]
Open

            def generate_merged_partials
                partials = retrieve_hash_path @global_config, %w(partials _general _general default)
                partials = {} if partials.nil?

                # general specific layout

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method load has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

            def load(data)
                reset
                @config = data['config'] unless data['config'].nil?
                @plugin_config = data['plugin-config'] unless data['plugin-config'].nil?
                @valid_domains = data['valid_domains'] unless data['valid_domains'].nil?
Severity: Minor
Found in lib/odania/config/plugin_config.rb - About 1 hr to fix

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

Method generate_merged_partials has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

            def generate_merged_partials
                partials = retrieve_hash_path @global_config, %w(partials _general _general default)
                partials = {} if partials.nil?

                # general specific layout
Severity: Minor
Found in lib/odania/config/subdomain_config.rb - About 1 hr to fix

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

Method add has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

            def add(data, group_name=nil)
                duplicates = super(data, group_name)

                self.config = data['config'] unless data['config'].nil?

Severity: Minor
Found in lib/odania/config/sub_domain.rb - About 1 hr to fix

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

Method load_global_config has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

            def load_global_config(config)
                throw 'Invalid global config!' if config.nil?

                reset
                @default_backend_groups = config['default_backend_groups'] unless config['default_backend_groups'].nil?
Severity: Minor
Found in lib/odania/config/global_config.rb - About 1 hr to fix

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

Method add_plugin_config has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            def add_plugin_config(plugin_cfg)
                config_section = plugin_cfg['config']
                group_name = plugin_cfg['plugin-config']['name']

                if $debug
Severity: Minor
Found in lib/odania/config/global_config.rb - About 1 hr to fix

    Method load_from_consul has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

                def load_from_consul
                    Odania.plugin.get_all.each_pair do |plugin_name, instances|
                        $logger.info "PLUGIN NAME #{plugin_name} - #{instances.count}" if $debug
                        instances.each do |instance|
                            add_backend(instance)
    Severity: Minor
    Found in lib/odania/config/global_config.rb - About 55 mins to fix

    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

    ruby-ffi DDL loading issue on Windows OS
    Open

        ffi (1.9.10)
    Severity: Critical
    Found in Gemfile.lock by bundler-audit

    Advisory: CVE-2018-1000201

    Criticality: High

    URL: https://github.com/ffi/ffi/releases/tag/1.9.24

    Solution: upgrade to >= 1.9.24

    Method dump has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

                def dump
                    result = {}
                    result['group_name'] = self.group_name unless self.group_name.nil?
                    result['plugin_url'] = self.plugin_url unless self.plugin_url.nil?
                    result['cacheable'] = self.cacheable unless self.cacheable.nil?
    Severity: Minor
    Found in lib/odania/config/page.rb - About 45 mins to fix

    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

    Method load has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

                def load(data, group_name=nil)
                    self.group_name = data['group_name'] unless data['group_name'].nil?
                    self.group_name = group_name unless group_name.nil?
                    self.plugin_url = data['plugin_url']
                    self.cacheable = data['cacheable'] unless data['cacheable'].nil?
    Severity: Minor
    Found in lib/odania/config/page.rb - About 45 mins to fix

    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

    Method get_layout_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

                def get_layout_name
                    # subdomain specific layouts
                    result = retrieve_hash_path @global_config, ['domains', @domain, @subdomain, 'config', 'layout']
                    return result unless result.nil?
    
    
    Severity: Minor
    Found in lib/odania/config/subdomain_config.rb - About 45 mins to fix

    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

    Method build_config has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

                def build_config(plugin_name, plugin_instance_name, ip, tags=[], port=80)
    Severity: Minor
    Found in lib/odania/consul.rb - About 35 mins to fix

      Method get_layout_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                  def get_layout_config(layout)
                      # subdomain specific layouts
                      result = retrieve_hash_path @global_config, ['domains', @domain, @subdomain, 'layouts', layout]
                      return result unless result.nil?
      
      
      Severity: Minor
      Found in lib/odania/config/subdomain_config.rb - About 25 mins to fix

      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

      Do not suppress exceptions.
      Open

      rescue LoadError
      Severity: Minor
      Found in tasks/rspec.rake by rubocop

      This cop checks for rescue blocks with no body.

      Example:

      # bad
      
      def some_method
        do_something
      rescue
        # do nothing
      end

      Example:

      # bad
      
      begin
        do_something
      rescue
        # do nothing
      end

      Example:

      # good
      
      def some_method
        do_something
      rescue
        handle_exception
      end

      Example:

      # good
      
      begin
        do_something
      rescue
        handle_exception
      end
      Severity
      Category
      Status
      Source
      Language