cea-sec/miasm

View on GitHub

Showing 1,373 of 3,019 total issues

Function arg2str has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def arg2str(e, pos = None, loc_db=None):
        if isinstance(e, ExprId) or isinstance(e, ExprInt):
            return str(e)
        elif isinstance(e, ExprMem):
            addr = e.ptr
Severity: Minor
Found in miasm/arch/ppc/arch.py - 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

Function asm_ast_to_expr has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def asm_ast_to_expr(self, arg, loc_db):
        if isinstance(arg, AstId):
            if isinstance(arg.name, ExprId):
                return arg.name
            if arg.name in gpregs.str:
Severity: Minor
Found in miasm/arch/ppc/arch.py - 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

Function encode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def encode(self):
        self.parent.updown.value = 1
        e = self.expr
        if not isinstance(e, ExprMem):
            return False
Severity: Minor
Found in miasm/arch/arm/arch.py - 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

Function irblock_slice has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def irblock_slice(self, irb, max_line=None):
        """Slice of the dependency nodes on the irblock @irb
        @irb: irbloc instance
        """

Severity: Minor
Found in miasm/analysis/depgraph.py - 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

Function __repr__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def __repr__(self):
        rep = ["<%s>" % (self.__class__.__name__)]
        if self.resdesc is None:
            return "\n".join(rep)
        dir_todo = [self.resdesc]
Severity: Minor
Found in miasm/loader/pe.py - 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

Function aggressive_coalesce_block has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def aggressive_coalesce_block(self):
        """Try to coalesce phi var with their pre/post variables"""

        ircfg = self.ssa.graph

Severity: Minor
Found in miasm/analysis/outofssa.py - 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

Function insert_parallel_copy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def insert_parallel_copy(self):
        """
        Naive Out-of-SSA from CSSA (without coalescing for now)
        - Replace Phi
        - Create room for parallel copies in Phi's parents
Severity: Minor
Found in miasm/analysis/outofssa.py - 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

Function gen_jump2dst has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def gen_jump2dst(self, attrib, instr_offsets, dst):
        """Generate the code for a jump to @dst with final check for error

        Several cases have to be considered:
         - jump to an offset out of the current ASM BBL (JMP 0x11223344)
Severity: Minor
Found in miasm/jitter/llvmconvert.py - 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

Function get_phi_sources_parent_block has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def get_phi_sources_parent_block(ircfg, loc_key, sources):
    """
    Return a dictionary linking a variable to it's direct parent label
    which belong to a path which affects the node.
    @loc_key: the starting node
Severity: Minor
Found in miasm/analysis/ssa.py - 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

Function isolate_phi_nodes_block has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def isolate_phi_nodes_block(self):
        """
        Init structures and virtually insert parallel copy before/after each phi
        node
        """
Severity: Minor
Found in miasm/analysis/outofssa.py - 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

Function cannon_list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def cannon_list(tmp):
        """
        Return a cannonizes list of intervals
        @tmp: list of (int, int)
        """
Severity: Minor
Found in miasm/core/interval.py - 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

Function resolve_symbol has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def resolve_symbol(blockChains, loc_db, dst_interval=None):
    """Place @blockChains in the @dst_interval"""

    log_asmblock.info('resolve_symbol')
    if dst_interval is None:
Severity: Minor
Found in miasm/core/asmblock.py - 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

Function size_to_int has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def size_to_int(self, size):
        """Resolve an array size
        @size: CTypeOp or integer"""
        if isinstance(size, CTypeOp):
            assert len(size.args) == 2
Severity: Minor
Found in miasm/core/objc.py - 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

Function _propagate_sol has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _propagate_sol(self, node, partial_sol, graph, todo, propagator):
        """
        Try to extend the current @partial_sol by propagating the solution using
        @propagator on @node.
        New solutions are added to @todo
Severity: Minor
Found in miasm/core/graph.py - 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

Function get_ir has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def get_ir(self, instr):
        args = instr.args[:]
        args = [arg.replace_expr(float_replace) for arg in args]
        args = fix_mem_args_size(instr, *args)
        my_ss = None
Severity: Minor
Found in miasm/arch/x86/sem.py - About 1 hr to fix

    Function analyse_function has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def analyse_function():
        # Get settings
        settings = TypePropagationForm()
        ret = settings.Execute()
        if not ret:
    Severity: Minor
    Found in example/ida/ctype_propagation.py - About 1 hr to fix

      Function ldz has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def ldz(rn, rm):
          """LDZ - Count Leading Zeroes
      
             Note: this implementation is readable, yet slow. Each bit are tested
             individually, and the results are propagated to other bits.
      Severity: Minor
      Found in miasm/arch/mep/sem.py - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

            if expr.cond.is_op('-') and len(expr.cond.args) == 1:
                expr = ExprCond(expr.cond.args[0], expr.src1, expr.src2)
            # a?x:x
            elif expr.src1 == expr.src2:
                expr = expr.src1
        Severity: Critical
        Found in miasm/expression/simplifications_common.py - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

              if (not ((arg1.is_op() and arg1.op.startswith("zeroExt") and
                        arg2.is_op() and arg2.op.startswith("zeroExt")) or
                       (arg1.is_op() and arg1.op.startswith("signExt") and
                         arg2.is_op() and arg2.op.startswith("signExt")))):
                  return expr
          Severity: Critical
          Found in miasm/expression/simplifications_common.py - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                if (isinstance(child, ExprId) or isinstance(child, ExprInt) or
                    isinstance(child, ExprCompose) or isinstance(child, ExprMem) or
                    isinstance(child, ExprSlice)):
                    return False
                elif isinstance(child, ExprOp) and not child.is_infix():
            Severity: Critical
            Found in miasm/expression/expression.py - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language