unclesp1d3r/CipherSwarm

View on GitHub

Showing 542 of 542 total issues

Class Attack has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

class Attack < ApplicationRecord
  acts_as_paranoid # Soft deletes the attack

  ##
  # Associations
Severity: Minor
Found in app/models/attack.rb - About 3 hrs to fix

Method perform has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Confirmed

  def perform(id)
    list = HashList.find(id)
    return if list.processed?

    HashList.transaction do
Severity: Minor
Found in app/jobs/process_hash_list_job.rb - About 3 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

File attack.rb has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Attack < ApplicationRecord
  acts_as_paranoid # Soft deletes the attack

  ##
  # Associations
Severity: Minor
Found in app/models/attack.rb - About 2 hrs to fix

Method submit_status has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def submit_status
    @task = @agent.tasks.find(params[:id])
    @task.update(activity_timestamp: Time.zone.now)
    status = @task.hashcat_statuses.build({
                                            original_line: params[:original_line],
Severity: Major
Found in app/controllers/api/v1/client/tasks_controller.rb - About 2 hrs to fix

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

  def new_task
    # Immediately return the first incomplete task if there's no fatal errors for it.
    incomplete_task = tasks.incomplete.find do |task|
      !agent_errors.exists?(severity: :fatal, task_id: task.id) && task.uncracked_remaining
    end
Severity: Minor
Found in app/models/agent.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

Method submit_error has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def submit_error
    if @agent.blank?
      render json: { error: "Agent not found" }, status: :not_found
      return
    end
Severity: Minor
Found in app/controllers/api/v1/client/agents_controller.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 check_for_cracker_update has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def check_for_cracker_update
    current_version = params[:version]
    operating_system = params[:operating_system]

    if current_version.blank? || current_version.nil?
Severity: Minor
Found in app/controllers/api/v1/client/crackers_controller.rb - About 1 hr to fix

Method calculate_mask_candidates has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.calculate_mask_candidates(mask_line)
    require "bigdecimal"

    charset_counts = {
      "?a" => 95, # All printable ASCII characters
Severity: Minor
Found in lib/mask_calculation_methods.rb - About 1 hr to fix

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

  def self.calculate_mask_candidates(mask_line)
    require "bigdecimal"

    charset_counts = {
      "?a" => 95, # All printable ASCII characters
Severity: Minor
Found in lib/mask_calculation_methods.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 submit_status has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def submit_status
    @task = @agent.tasks.find(params[:id])
    @task.update(activity_timestamp: Time.zone.now)
    status = @task.hashcat_statuses.build({
                                            original_line: params[:original_line],
Severity: Minor
Found in app/controllers/api/v1/client/tasks_controller.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 submit_error has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def submit_error
    if @agent.blank?
      render json: { error: "Agent not found" }, status: :not_found
      return
    end
Severity: Minor
Found in app/controllers/api/v1/client/agents_controller.rb - About 1 hr to fix

Method submit_crack has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def submit_crack
    timestamp = params[:timestamp]
    hash = params[:hash]
    plain_text = params[:plain_text]

Severity: Minor
Found in app/controllers/api/v1/client/tasks_controller.rb - About 1 hr to fix

Method new_task has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def new_task
    # Immediately return the first incomplete task if there's no fatal errors for it.
    incomplete_task = tasks.incomplete.find do |task|
      !agent_errors.exists?(severity: :fatal, task_id: task.id) && task.uncracked_remaining
    end
Severity: Minor
Found in app/models/agent.rb - About 1 hr to fix

Method submit_benchmark has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def submit_benchmark
    # There's a weird bug where the JSON is sometimes in the body and as a param.
    if params[:hashcat_benchmarks].nil?
      render json: { error: "No benchmarks submitted" }, status: :bad_request
      return
Severity: Minor
Found in app/controllers/api/v1/client/agents_controller.rb - About 1 hr to fix

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

  def check_for_cracker_update
    current_version = params[:version]
    operating_system = params[:operating_system]

    if current_version.blank? || current_version.nil?
Severity: Minor
Found in app/controllers/api/v1/client/crackers_controller.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

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

  def perform(mask_list_id)
    mask_list = MaskList.find(mask_list_id)
    return if mask_list.nil? || mask_list.file.nil? || mask_list.complexity_value != 0

    total_combinations = 0
Severity: Minor
Found in app/jobs/calculate_mask_complexity_job.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

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

    def check_for_newer(operating_system_name, version_string)
      # Convert the version string to a semantic version.
      sem_version = CrackerBinary.to_semantic_version(version_string)

      # Return nil if the version string is invalid.
Severity: Minor
Found in app/models/cracker_binary.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

HashList#uncracked_list refers to 'hash_lines' more than self (maybe move it to another class?)
Open

      hash_lines << "#{h}"
    end
    hash_lines.join("\n")
Severity: Minor
Found in app/models/hash_list.rb by reek

Feature Envy occurs when a code fragment references another object more often than it references itself, or when several clients do the same series of manipulations on a particular type of object.

Feature Envy reduces the code's ability to communicate intent: code that "belongs" on one class but which is located in another can be hard to find, and may upset the "System of Names" in the host class.

Feature Envy also affects the design's flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application's domain, and creates a loss of cohesion in the unwilling host class.

Feature Envy often arises because it must manipulate other objects (usually its arguments) to get them into a useful form, and one force preventing them (the arguments) doing this themselves is that the common knowledge lives outside the arguments, or the arguments are of too basic a type to justify extending that type. Therefore there must be something which 'knows' about the contents or purposes of the arguments. That thing would have to be more than just a basic type, because the basic types are either containers which don't know about their contents, or they are single objects which can't capture their relationship with their fellows of the same type. So, this thing with the extra knowledge should be reified into a class, and the utility method will most likely belong there.

Example

Running Reek on:

class Warehouse
  def sale_price(item)
    (item.price - item.rebate) * @vat
  end
end

would report:

Warehouse#total_price refers to item more than self (FeatureEnvy)

since this:

(item.price - item.rebate)

belongs to the Item class, not the Warehouse.

CalculateMaskComplexityJob#perform contains iterators nested 2 deep
Open

      file.each_line do |line|

A Nested Iterator occurs when a block contains another block.

Example

Given

class Duck
  class << self
    def duck_names
      %i!tick trick track!.each do |surname|
        %i!duck!.each do |last_name|
          puts "full name is #{surname} #{last_name}"
        end
      end
    end
  end
end

Reek would report the following warning:

test.rb -- 1 warning:
  [5]:Duck#duck_names contains iterators nested 2 deep (NestedIterators)

MaskCalculationMethods#self.calculate_mask_candidates has approx 20 statements
Open

  def self.calculate_mask_candidates(mask_line)
Severity: Minor
Found in lib/mask_calculation_methods.rb by reek

A method with Too Many Statements is any method that has a large number of lines.

Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

So the following method would score +6 in Reek's statement-counting algorithm:

def parse(arg, argv, &error)
  if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
    return nil, block, nil                                         # +1
  end
  opt = (val = parse_arg(val, &error))[1]                          # +2
  val = conv_arg(*val)                                             # +3
  if opt and !arg
    argv.shift                                                     # +4
  else
    val[0] = nil                                                   # +5
  end
  val                                                              # +6
end

(You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

Severity
Category
Status
Source
Language