3scale/porta

View on GitHub

Showing 5,267 of 5,597 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  module Drops
    class ReferrerFilter < Drops::Base

      allowed_names :referrer_filter, :referrer_filters

Severity: Minor
Found in lib/developer_portal/lib/liquid/drops/referrer_filter.rb and 1 other location - About 30 mins to fix
lib/developer_portal/lib/liquid/drops/application_key.rb on lines 2..24

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  module Drops
    class ApplicationKey < Drops::Base

      allowed_names :application_key, :application_keys

Severity: Minor
Found in lib/developer_portal/lib/liquid/drops/application_key.rb and 1 other location - About 30 mins to fix
lib/developer_portal/lib/liquid/drops/referrer_filter.rb on lines 2..24

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def self.down
    if index_exists? :audits, [:associated_id, :associated_type], :name => 'associated_index'
      remove_index :audits, :name => 'associated_index'
    end

Severity: Minor
Found in db/migrate/20150310163429_rename_association_to_associated.rb and 1 other location - About 30 mins to fix
db/migrate/20150310163429_rename_association_to_associated.rb on lines 2..11

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid too many return statements within this method.
Open

    return if contract.pending?
Severity: Major
Found in app/observers/message_observer.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return false unless cms.admin?
    Severity: Major
    Found in lib/developer_portal/lib/cms/toolbar.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return true if association.through_reflection&.try(:klass)&.attribute_names&.include?("tenant_id")
      Severity: Major
      Found in lib/three_scale/tenant_id_integrity_checker.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return if current == original
        Severity: Major
        Found in lib/three_scale/middleware/multitenant.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return if master?
          Severity: Major
          Found in lib/three_scale/middleware/multitenant.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return true
            Severity: Major
            Found in lib/developer_portal/lib/cms/toolbar.rb - About 30 mins to fix

              attr_accessible is recommended over attr_protected
              Open

                attr_protected :plan_id, :state, :provider_public_key, :paid_until, :trial_period_expires_at, :setup_fee, :type, :variable_cost_paid_until, :application_id, :user_key, :user_account_id, :tenant_id, :audit_ids
              Severity: Minor
              Found in app/models/contract.rb by brakeman

              This warning comes up if a model does not limit what attributes can be set through mass assignment.

              In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

              Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

              Note that disabling mass assignment globally will suppress these warnings.

              Mass assignment is not restricted using attr_accessible
              Open

              class GoLiveState < ApplicationRecord
              Severity: Critical
              Found in app/models/go_live_state.rb by brakeman

              This warning comes up if a model does not limit what attributes can be set through mass assignment.

              In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

              Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

              Note that disabling mass assignment globally will suppress these warnings.

              attr_accessible is recommended over attr_protected
              Open

                attr_protected :service_id, :parent_id, :tenant_id, :audit_ids
              Severity: Minor
              Found in app/models/metric.rb by brakeman

              This warning comes up if a model does not limit what attributes can be set through mass assignment.

              In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

              Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

              Note that disabling mass assignment globally will suppress these warnings.

              attr_accessible is recommended over attr_protected
              Open

                attr_protected :account_id, :cinstance_id, :tenant_id
              Severity: Minor
              Found in app/models/alert.rb by brakeman

              This warning comes up if a model does not limit what attributes can be set through mass assignment.

              In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

              Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

              Note that disabling mass assignment globally will suppress these warnings.

              Mass assignment is not restricted using attr_accessible
              Open

              class AuthenticationProvider::Auth0 < AuthenticationProvider

              This warning comes up if a model does not limit what attributes can be set through mass assignment.

              In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

              Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

              Note that disabling mass assignment globally will suppress these warnings.

              attr_accessible is recommended over attr_protected
              Open

                attr_protected :account_id, :tenant_id
              Severity: Minor
              Found in app/models/fields_definition.rb by brakeman

              This warning comes up if a model does not limit what attributes can be set through mass assignment.

              In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

              Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

              Note that disabling mass assignment globally will suppress these warnings.

              Potentially dangerous attribute available for mass assignment
              Open

              class SSOToken
              Severity: Minor
              Found in app/models/sso_token.rb by brakeman

              Mass assignment is a feature of Rails which allows an application to create a record from the values of a hash.

              Example:

              User.new(params[:user])

              Unfortunately, if there is a user field called admin which controls administrator access, now any user can make themselves an administrator.

              attr_accessible and attr_protected can be used to limit mass assignment. However, Brakeman will warn unless attr_accessible is used, or mass assignment is completely disabled.

              There are two different mass assignment warnings which can arise. The first is when mass assignment actually occurs, such as the example above. This results in a warning like

              Unprotected mass assignment near line 61: User.new(params[:user])

              The other warning is raised whenever a model is found which does not use attr_accessible. This produces generic warnings like

              Mass assignment is not restricted using attr_accessible

              with a list of affected models.

              In Rails 3.1 and newer, mass assignment can easily be disabled:

              config.active_record.whitelist_attributes = true

              Unfortunately, it can also easily be bypassed:

              User.new(params[:user], :without_protection => true)

              Brakeman will warn on uses of without_protection.

              Potentially dangerous attribute available for mass assignment
              Open

              class Topic < ApplicationRecord
              Severity: Minor
              Found in app/models/topic.rb by brakeman

              Mass assignment is a feature of Rails which allows an application to create a record from the values of a hash.

              Example:

              User.new(params[:user])

              Unfortunately, if there is a user field called admin which controls administrator access, now any user can make themselves an administrator.

              attr_accessible and attr_protected can be used to limit mass assignment. However, Brakeman will warn unless attr_accessible is used, or mass assignment is completely disabled.

              There are two different mass assignment warnings which can arise. The first is when mass assignment actually occurs, such as the example above. This results in a warning like

              Unprotected mass assignment near line 61: User.new(params[:user])

              The other warning is raised whenever a model is found which does not use attr_accessible. This produces generic warnings like

              Mass assignment is not restricted using attr_accessible

              with a list of affected models.

              In Rails 3.1 and newer, mass assignment can easily be disabled:

              config.active_record.whitelist_attributes = true

              Unfortunately, it can also easily be bypassed:

              User.new(params[:user], :without_protection => true)

              Brakeman will warn on uses of without_protection.

              Mass assignment is not restricted using attr_accessible
              Open

              class MailDispatchRule < ApplicationRecord
              Severity: Critical
              Found in app/models/mail_dispatch_rule.rb by brakeman

              This warning comes up if a model does not limit what attributes can be set through mass assignment.

              In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

              Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

              Note that disabling mass assignment globally will suppress these warnings.

              Mass assignment is not restricted using attr_accessible
              Open

              class PaymentGatewaySetting < ApplicationRecord
              Severity: Critical
              Found in app/models/payment_gateway_setting.rb by brakeman

              This warning comes up if a model does not limit what attributes can be set through mass assignment.

              In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

              Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

              Note that disabling mass assignment globally will suppress these warnings.

              Mass assignment is not restricted using attr_accessible
              Open

              class ApplicationPlan < Plan
              Severity: Critical
              Found in app/models/application_plan.rb by brakeman

              This warning comes up if a model does not limit what attributes can be set through mass assignment.

              In particular, this check looks for attr_accessible inside model definitions. If it is not found, this warning will be issued.

              Brakeman also warns on use of attr_protected - especially since it was found to be vulnerable to bypass. Warnings for mass assignment on models using attr_protected will be reported, but at a lower confidence level.

              Note that disabling mass assignment globally will suppress these warnings.

              Severity
              Category
              Status
              Source
              Language