cea-sec/miasm

View on GitHub

Showing 1,373 of 3,020 total issues

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

def is_expr_cst(lifter, expr):
    """Return true if @expr is only composed of ExprInt and init_regs
    @lifter: Lifter instance
    @expr: Expression to test"""

Severity: Minor
Found in miasm/analysis/cst_propag.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 gen_dst_goto has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def gen_dst_goto(self, attrib, instr_offsets, dst2index):
        """
        Generate code for possible @dst2index.

        @attrib: an Attributes instance
Severity: Minor
Found in miasm/jitter/codegen.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

                        for predecessor in graph.predecessors(node):
                            if predecessor not in todo:
                                todo.append(predecessor)
                        continue
Severity: Major
Found in miasm/analysis/data_flow.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if parent not in known:
                                is_ok = False
                                break
                        if not is_ok:
    Severity: Major
    Found in miasm/analysis/data_flow.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if src.size <= self.translator.NATIVE_INT_MAX_SIZE:
                                  c_mem.append('MEM_WRITE_BN_INT(jitcpu, %d, %s, %s);' % (
                                      src.size, ptr_str, self.id_to_c(src))
                                  )
                              else:
      Severity: Major
      Found in miasm/jitter/codegen.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if parent not in known:
                                    is_ok = False
                                    break
                            if not is_ok:
        Severity: Major
        Found in miasm/analysis/data_flow.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if dst in self.immutable_ids or dst in self.ssa_variable_to_expr:
                                      continue
                                  # map variable definition to blocks
                                  self.defs.setdefault(dst, set()).add(irblock.loc_key)
          Severity: Major
          Found in miasm/analysis/ssa.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if predecessor not in todo:
                                        todo.append(predecessor)
                                continue
            Severity: Major
            Found in miasm/analysis/data_flow.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if expr.is_mem():
                                          addr_range = expr_range(expr.ptr)
                                          # At upper bounds, add the size of the memory access
                                          # if addr (- [a, b], then @size[addr] reachables
                                          # values are in @8[a, b + size[
              Severity: Major
              Found in miasm/analysis/dse.py - About 45 mins to fix

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

                def get_pe_dependencies(pe_obj):
                    """Collect the shared libraries upon which this PE depends.
                
                    @pe_obj: pe object
                    Returns a set of strings of DLL names.
                Severity: Minor
                Found in miasm/jitter/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 ssa_def_is_live_at has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def ssa_def_is_live_at(self, node_a, node_b, parent):
                        """
                        Return True if @node_a is live during @node_b definition
                        If @parent is None, this is a liveness test for a post phi variable;
                        Else, it is a liveness test for a variable source of the phi node
                Severity: Minor
                Found in miasm/analysis/outofssa.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_import_address_pe has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def get_import_address_pe(e):
                    """Compute the addresses of imported symbols.
                    @e: pe object
                    Returns a dict mapping from tuple (dll name string, symbol name string) to set of virtual addresses.
                
                
                Severity: Minor
                Found in miasm/jitter/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 mem_read has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def mem_read(self, expr_mem):
                        if not expr_mem.ptr.is_int():
                            return super(ESETrackModif, self).mem_read(expr_mem)
                        dst_addr = int(expr_mem.ptr)
                
                
                Severity: Minor
                Found in miasm/analysis/dse.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 not value.is_int():
                                            raise TypeError("Rely on a symbolic memory case, " \
                                                            "address 0x%x" % address)
                                        path_constraint.add(ExprAssign(expr_mem, value))
                Severity: Major
                Found in miasm/analysis/dse.py - About 45 mins to fix

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

                      def __init__(self, loc_db, loc_key=None, alignment=1, errno=ERROR_UNKNOWN, *args, **kwargs):
                  Severity: Minor
                  Found in miasm/core/asmblock.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if len(instr.raw) == 0:
                                                l = 0
                                            else:
                                                l = (instr.raw[0].size // 8) * len(instr.raw)
                                        elif isinstance(instr.raw, str):
                    Severity: Major
                    Found in miasm/core/asmblock.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if v != [None]:
                                                  v = f.asm_ast_to_expr(v[0], loc_db)
                                              if v is None:
                      Severity: Major
                      Found in miasm/core/cpu.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if isinstance(exp_fname, str):
                                                    exp_fname = bytes(ord(c) for c in exp_fname)
                                                found = None
                        Severity: Major
                        Found in miasm/jitter/loader/pe.py - About 45 mins to fix

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

                              def reduce_op_memberof(self, node, **kwargs):
                                  """Reduce -> operator"""
                          
                                  if not node.expr.is_op('->'):
                                      return None
                          Severity: Minor
                          Found in miasm/core/objc.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 ast_to_typeid_union has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def ast_to_typeid_union(self, ast):
                                  """Return the CTypeBase of an Union ast"""
                                  name = self.gen_uniq_name() if ast.name is None else ast.name
                                  args = []
                                  if ast.decls:
                          Severity: Minor
                          Found in miasm/core/ctypesmngr.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

                          Severity
                          Category
                          Status
                          Source
                          Language