ANSSI-FR/polichombr

View on GitHub

Showing 1,243 of 1,244 total issues

Block has too many lines. [29/25]
Open

dasm.sections.each do |secAddr, secDatas|
  cryptoPatterns.each do |name, patterns|
    ok = 0
    pattAddr = 0
    for pattern in patterns

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

MetasmUtils tests 'defined?(di.block)' at least 4 times
Open

    return result unless defined?(di.block)
    return result if di.block.to_normal.nil?
    di.block.to_normal.each do |tdi_addr|
      tdi = $gdasm.di_at(tdi_addr)
      next unless defined?(tdi.block)
Severity: Minor
Found in polichombr/analysis_tools/AnalyzeIt.rb by reek

Repeated Conditional is a special case of Simulated Polymorphism. Basically it means you are checking the same value throughout a single class and take decisions based on this.

Example

Given

class RepeatedConditionals
  attr_accessor :switch

  def repeat_1
    puts "Repeat 1!" if switch
  end

  def repeat_2
    puts "Repeat 2!" if switch
  end

  def repeat_3
    puts "Repeat 3!" if switch
  end
end

Reek would emit the following warning:

test.rb -- 4 warnings:
  [5, 9, 13]:RepeatedConditionals tests switch at least 3 times (RepeatedConditional)

If you get this warning then you are probably not using the right abstraction or even more probable, missing an additional abstraction.

Function create_sample_and_run_analysis has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create_sample_and_run_analysis(
Severity: Minor
Found in polichombr/controllers/api.py - About 35 mins to fix

    Function add_function has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def add_function(cls, sample, address, machoc_hash,
    Severity: Minor
    Found in polichombr/controllers/sample.py - About 35 mins to fix

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

              if timestamp is not None:
                  endpoint += "?timestamp="
                  endpoint += datetime.datetime.strftime(timestamp, format_ts)
      Severity: Minor
      Found in skelenox_plugin/connection.py and 1 other location - About 35 mins to fix
      skelenox_plugin/connection.py on lines 314..316

      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

      Function execute_rename has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute_rename(name):
              """
                  This is a wrapper to execute the renaming synchronously
              """
              def get_name():
      Severity: Minor
      Found in skelenox_plugin/utils.py - About 35 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

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

      class AddSubFamilyForm(FlaskForm):
      
          """
          Create sub-family.
          """
      Severity: Major
      Found in polichombr/views/forms.py and 4 other locations - About 35 mins to fix
      polichombr/views/forms.py on lines 36..42
      polichombr/views/forms.py on lines 45..51
      polichombr/views/forms.py on lines 300..307
      polichombr/views/forms.py on lines 310..316

      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 5 locations. Consider refactoring.
      Open

      class CompareMachocForm(FlaskForm):
      
          """
          Compare to other samples.
          """
      Severity: Major
      Found in polichombr/views/forms.py and 4 other locations - About 35 mins to fix
      polichombr/views/forms.py on lines 36..42
      polichombr/views/forms.py on lines 45..51
      polichombr/views/forms.py on lines 130..136
      polichombr/views/forms.py on lines 310..316

      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 5 locations. Consider refactoring.
      Open

      class FullTextSearchForm(FlaskForm):
      
          """
          Full-text search.
          """
      Severity: Major
      Found in polichombr/views/forms.py and 4 other locations - About 35 mins to fix
      polichombr/views/forms.py on lines 36..42
      polichombr/views/forms.py on lines 45..51
      polichombr/views/forms.py on lines 130..136
      polichombr/views/forms.py on lines 300..307

      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

      Function api_post_families has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def api_post_families():
          """
              Insert a new family
              @return the created family id
          """
      Severity: Minor
      Found in polichombr/views/api_family.py - About 35 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

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

              if timestamp is not None:
                  endpoint += "?timestamp="
                  endpoint += datetime.datetime.strftime(timestamp, format_ts)
      Severity: Minor
      Found in skelenox_plugin/connection.py and 1 other location - About 35 mins to fix
      skelenox_plugin/connection.py on lines 302..304

      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

      Function gen_sample_view has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def gen_sample_view(sample_id, graph=None, fctaddr=None):
          """
          Generates a sample's view (template). We split the view because of the
          disassembly view, which is directly included in the sample's view, but
          not "by default".
      Severity: Minor
      Found in polichombr/views/webui_sample.py - About 35 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

      Function add_function has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_function(cls, sample, address, machoc_hash,
                           name="", overwrite=False):
              """
                  Add a function. Updates if exists.
              """
      Severity: Minor
      Found in polichombr/controllers/sample.py - About 35 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

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

      class ChgNameForm(FlaskForm):
      
          """
          Change user's full name.
          """
      Severity: Major
      Found in polichombr/views/forms.py and 4 other locations - About 35 mins to fix
      polichombr/views/forms.py on lines 36..42
      polichombr/views/forms.py on lines 130..136
      polichombr/views/forms.py on lines 300..307
      polichombr/views/forms.py on lines 310..316

      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

      Function login has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def login():
          """
          Flask-Login.
          """
          if g.user.is_authenticated:
      Severity: Minor
      Found in polichombr/views/webui_user.py - About 35 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

      Function get_comment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_comment(address):
              """
                  Wrapper to get both the Cmt and RptCmt
              """
              cmt_types = [idc.get_cmt, idc.get_func_cmt]  # TODO: RPT CMT
      Severity: Minor
      Found in skelenox_plugin/utils.py - About 35 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

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

      class ChgNickForm(FlaskForm):
      
          """
          Change user's nickname (login).
          """
      Severity: Major
      Found in polichombr/views/forms.py and 4 other locations - About 35 mins to fix
      polichombr/views/forms.py on lines 45..51
      polichombr/views/forms.py on lines 130..136
      polichombr/views/forms.py on lines 300..307
      polichombr/views/forms.py on lines 310..316

      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

              if res["result"]:
                  logger.debug("New type %s sent for address 0x%x", mtype, address)
              else:
                  logger.error("Cannot send type %s ( 0x%x )", mtype, address)
      Severity: Minor
      Found in skelenox_plugin/connection.py and 1 other location - About 35 mins to fix
      skelenox_plugin/connection.py on lines 262..268

      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

          @staticmethod
          def get_functions(sample_id):
              """
                  Return all the functions for a sample
              """
      Severity: Minor
      Found in polichombr/controllers/sample.py and 1 other location - About 35 mins to fix
      polichombr/controllers/sample.py on lines 814..820

      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

          password = PasswordField(
              'password', validators=[
                  Length(min=6),
                  DataRequired(),
                  EqualTo('rpt_pass',
      Severity: Minor
      Found in polichombr/views/forms.py and 1 other location - About 35 mins to fix
      polichombr/views/forms.py on lines 60..64

      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

      Severity
      Category
      Status
      Source
      Language