ANSSI-FR/polichombr

View on GitHub

Showing 1,243 of 1,244 total issues

Avoid deeply nested control flow statements.
Open

            return nil if di.block.list[i - 1].opcode.name == 'call'
Severity: Major
Found in polichombr/analysis_tools/AnalyzeIt.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                if (di.block.list[i].opcode.name == 'call') && (di.block.list[i].instruction.args.first == creg)
                  i -= 1
                  while i >= 0
                    if di.block.list[i].opcode.name == 'push'
                      if carg == arg
    Severity: Major
    Found in polichombr/analysis_tools/AnalyzeIt.rb - About 45 mins to fix

      Function add_metadata has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_metadata(sample, metadata_type, metadata_value):
              """
                  Add a sample's metadata.
              """
              if SampleMetadataType.tostring(metadata_type) == "":
      Severity: Minor
      Found in polichombr/controllers/sample.py - 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

      Avoid deeply nested control flow statements.
      Open

                  if (di.block.list[i - 1].opcode.name == 'mov') && ((di.block.list[i - 1].instruction.args.first.to_s == "dword ptr [esp+0#{arg.to_s(16)}h]") || (((di.block.list[i - 1].instruction.args.first.to_s == 'dword ptr [esp]') && (esp == 0))))
                    return $gdasm.normalize(di.block.list[i - 1].instruction.args.last)
                  end
      Severity: Major
      Found in polichombr/analysis_tools/AnalyzeIt.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  AddTagFunction(basefunc, 'Net_') unless basefunc.nil?
        Severity: Major
        Found in polichombr/analysis_tools/AnalyzeIt.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                        printCallTree(dasm.normalize(ep), orifunc) if isFuncTreeLink(dasm.normalize(ep), orifunc)
          Severity: Major
          Found in polichombr/analysis_tools/AnalyzeIt.rb - About 45 mins to fix

            Function search_machoc_full_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def search_machoc_full_hash(self, machoc_hash, limit=0.8):
                    """
                        Search a full machoc hash.
                        In one word, diffs with other samples in database.
                    """
            Severity: Minor
            Found in polichombr/controllers/sample.py - 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

            Avoid deeply nested control flow statements.
            Open

                        if di.block.list[i - 1].opcode.name == 'push'
                          if carg == arg
                            return $gdasm.normalize(di.block.list[i - 1].instruction.args.first)
                          end
                          carg += 1
            Severity: Major
            Found in polichombr/analysis_tools/AnalyzeIt.rb - About 45 mins to fix

              Function get_filter_arguments has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_filter_arguments(mrequest):
                  """
                      Get timestamp and address from request
                  """
                  data = mrequest.args
              Severity: Minor
              Found in polichombr/views/api_idaactions.py - 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

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

              @apiview.errorhandler(400)
              def api_400_handler(error):
                  """
                      module wide error handler, returned when there is an argument problem
                  """
              Severity: Major
              Found in polichombr/views/apiview.py and 2 other locations - About 45 mins to fix
              polichombr/views/apiview.py on lines 46..53
              polichombr/views/apiview.py on lines 66..73

              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 35.

              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

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

                    dasm.each_xref(addr) do |a|
                      xaddr = a
                      xaddr = a.address if defined?(a.address)
                      xaddr = a.origin if defined?(a.origin)
                      di = dasm.di_at(xaddr)

              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.

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

                  @staticmethod
                  def delete_detection_item(item):
                      """
                          Deletes a detection item.
                      """
              Severity: Major
              Found in polichombr/controllers/family.py and 2 other locations - About 40 mins to fix
              polichombr/controllers/sample.py on lines 264..271
              polichombr/controllers/user.py on lines 152..159

              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 34.

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

                  @staticmethod
                  def delete_checklist(checklist):
                      """
                          Deletes checklist.
                      """
              Severity: Major
              Found in polichombr/controllers/sample.py and 2 other locations - About 40 mins to fix
              polichombr/controllers/family.py on lines 403..410
              polichombr/controllers/user.py on lines 152..159

              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 34.

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

                  @staticmethod
                  def delete(user):
                      """
                          Removes an user from database.
                      """
              Severity: Major
              Found in polichombr/controllers/user.py and 2 other locations - About 40 mins to fix
              polichombr/controllers/family.py on lines 403..410
              polichombr/controllers/sample.py on lines 264..271

              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 34.

              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 change_tlp_level_form.validate_on_submit():
                      level = change_tlp_level_form.level.data
                      if not api.samplecontrol.set_tlp_level(sample, level):
                          flash("Cannot change sample TLP level")
              Severity: Minor
              Found in polichombr/views/webui_sample.py and 1 other location - About 40 mins to fix
              polichombr/views/webui_families.py on lines 94..98

              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 34.

              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 set_sample_abstract_form.validate_on_submit():
                      abstract = set_sample_abstract_form.abstract.data
                      api.samplecontrol.set_abstract(sample, abstract)
                  elif sample.abstract is not None:
                      set_sample_abstract_form.abstract.default = sample.abstract
              Severity: Minor
              Found in polichombr/views/webui_sample.py and 1 other location - About 40 mins to fix
              polichombr/views/webui_families.py on lines 90..92

              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 34.

              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

                  linked_samples_2 = db.relationship('SampleMatch',
                                                     backref=db.backref('sample2',
                                                                        remote_side=[id]),
                                                     foreign_keys=[SampleMatch.sid_2])
              Severity: Minor
              Found in polichombr/models/sample.py and 1 other location - About 40 mins to fix
              polichombr/models/sample.py on lines 239..242

              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 34.

              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

                  linked_samples = db.relationship('SampleMatch',
                                                   backref=db.backref('sample1',
                                                                      remote_side=[id]),
                                                   foreign_keys=[SampleMatch.sid_1])
              Severity: Minor
              Found in polichombr/models/sample.py and 1 other location - About 40 mins to fix
              polichombr/models/sample.py on lines 243..246

              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 34.

              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 family.abstract is not None:
                              form.abstract.default = family.abstract
                              form.abstract.data = family.abstract
              Severity: Minor
              Found in polichombr/views/webui_families.py and 1 other location - About 40 mins to fix
              polichombr/views/webui_sample.py on lines 100..105

              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 34.

              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 family_parse_tlp(family, form):
                      level = form.level.data
                      if not api.familycontrol.set_tlp_level(family, level):
                          flash("Cannot change family TLP level")
              Severity: Minor
              Found in polichombr/views/webui_families.py and 1 other location - About 40 mins to fix
              polichombr/views/webui_sample.py on lines 106..109

              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 34.

              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