cea-sec/miasm

View on GitHub

Showing 1,373 of 3,020 total issues

Avoid deeply nested control flow statements.
Open

                        if func == imp.name:
                            return isfromva(entry.firstthunk) + j * 4
            elif isinstance(func, int_types):
Severity: Major
Found in miasm/loader/pe.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if funcname == imp.name:
                                return entry.firstthunk + j * rva_size
                elif isinstance(funcname, int_types):
    Severity: Major
    Found in miasm/loader/pe.py - About 45 mins to fix

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

      def _test_jmp_only(ircfg, loc_key, heads):
          """
          If irblock at @loc_key sets only IRDst to an ExprLoc, return the
          corresponding loc_key target.
          Avoid creating predecssors for heads LocKeys
      Severity: Minor
      Found in miasm/analysis/data_flow.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 value == None:
                                  o += struct.calcsize(fmt) * b"\x00"
                              else:
                                  o += struct.pack(self.sex + fmt, v)
      
      
      Severity: Major
      Found in miasm/loader/new_cstruct.py - About 45 mins to fix

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

            def gete(self, raw, off):
                if not off:
                    return None, off
        
                ofend = off + \
        Severity: Minor
        Found in miasm/loader/pe.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

        Function intra_block_flow_raw has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def intra_block_flow_raw(lifter, ircfg, flow_graph, irb, in_nodes, out_nodes):
        Severity: Minor
        Found in miasm/analysis/data_analysis.py - About 45 mins to fix

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

              def node2lines(self, node):
                  """
                  Output liveness information in dot format
                  """
                  names = self.loc_db.get_location_names(node)
          Severity: Minor
          Found in miasm/analysis/data_flow.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 n_r in current_nodes:
                                  node_n_r = current_nodes[n_r]
                              else:
                                  node_n_r = get_node_name(irb.loc_key, i, n_r)
                                  current_nodes[n_r] = node_n_r
          Severity: Major
          Found in miasm/analysis/data_analysis.py - About 45 mins to fix

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

                def add_section(self, name="default", data=b"", **args):
                    s_align = self.parent_head.NThdr.sectionalignment
                    s_align = max(0x1000, s_align)
            
                    f_align = self.parent_head.NThdr.filealignment
            Severity: Minor
            Found in miasm/loader/pe.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 tmp_thunk[j].rva & mask_ptr == funcname:
                                        return entry.firstthunk + j * rva_size
                        else:
            Severity: Major
            Found in miasm/loader/pe.py - About 45 mins to fix

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

                  def __getitem__(self, item):
                      s = self.s
                      if isinstance(item, slice):
                          end = item.stop
                          l = len(s)
              Severity: Minor
              Found in miasm/loader/strpatchwork.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

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

                  def find(self, pattern, start=0):
                      sections = []
                      offset = start
                      for s in self.parent.ph:
                          s_max = s.ph.memsz  # max(s.ph.filesz, s.ph.memsz)
              Severity: Minor
              Found in miasm/loader/elf_init.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

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

                  def get(self, rva_start, rva_stop=None):
                      """
                      Get data in RVA view starting at @rva_start, stopping at @rva_stop
                      @rva_start: rva start address
                      @rva_stop: rva stop address
              Severity: Minor
              Found in miasm/loader/pe_init.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

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

              def _version():
                  version_file = os.path.join(_MIASM_PKG_DIR, 'VERSION')
                  try:
                      tag = _version_from_git_describe()
                      # successfully read the tag from git, write it in VERSION for
              Severity: Minor
              Found in miasm/__init__.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 isfromva(tmp_thunk[j].rva & 0x7FFFFFFF) == func:
                                          return isfromva(entry.firstthunk) + j * 4
                          else:
              Severity: Major
              Found in miasm/loader/pe.py - About 45 mins to fix

                Function vm_load_pe_and_dependencies has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def vm_load_pe_and_dependencies(vm, fname, name2module, runtime_lib,
                Severity: Minor
                Found in miasm/jitter/loader/pe.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if src_new != src:
                                          modified = True
                                  # Test dst pointer if dst is mem
                                  if dst.is_mem():
                  Severity: Major
                  Found in miasm/analysis/data_flow.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if old_dst in defined:
                                                continue
                                            fixed_phis[old_dst] = old_phi_src
                    Severity: Major
                    Found in miasm/analysis/data_flow.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          for mem in mems:
                                              value = read_mem(bs, mem)
                                              replace[mem] = value
                                          src_new = src.replace_expr(replace)
                      Severity: Major
                      Found in miasm/analysis/data_flow.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if mems:
                                                replace = {}
                                                for mem in mems:
                                                    value = read_mem(bs, mem)
                                                    replace[mem] = value
                        Severity: Major
                        Found in miasm/analysis/data_flow.py - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language