cea-sec/miasm

View on GitHub

Showing 1,373 of 3,020 total issues

Function compare_exprs has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

def compare_exprs(expr1, expr2):
    """Compare 2 expressions for canonization
    @expr1: Expr
    @expr2: Expr
    0  => ==
Severity: Minor
Found in miasm/expression/expression.py - About 5 hrs 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 arg2html has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def arg2html(expr, index=None, loc_db=None):
        wb = False
        if expr.is_id() or expr.is_int() or expr.is_loc():
            return color_expr_html(expr, loc_db)
        if isinstance(expr, ExprOp) and expr.op in expr2shift_dct:
Severity: Minor
Found in miasm/arch/arm/arch.py - About 5 hrs 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 vm_load_pe_and_dependencies has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

def vm_load_pe_and_dependencies(vm, fname, name2module, runtime_lib,
                                lib_path_base, **kwargs):
    """Load a binary and all its dependencies. Returns a dictionary containing
    the association between binaries names and it's pe object

Severity: Minor
Found in miasm/jitter/loader/pe.py - About 5 hrs 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 value has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    def value(self, mode):
        todo = [(0, 0, [(x, self.fields_order[x]) for x in self.to_decode[::-1]])]

        result = []
        done = []
Severity: Minor
Found in miasm/core/cpu.py - About 5 hrs 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

LocationDB has 38 functions (exceeds 20 allowed). Consider refactoring.
Open

class LocationDB(object):
    """
    LocationDB is a "database" of information associated to location.

    An entry in a LocationDB is uniquely identified with a LocKey.
Severity: Minor
Found in miasm/core/locationdb.py - About 5 hrs to fix

    moduint has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class moduint(object):
    
        def __init__(self, arg):
            self.arg = int(arg) % self.__class__.limit
            assert(self.arg >= 0 and self.arg < self.__class__.limit)
    Severity: Minor
    Found in miasm/core/modint.py - About 5 hrs to fix

      File regs.py has 373 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from builtins import range
      from miasm.expression.expression import ExprId
      from miasm.core.cpu import reg_info
      
      
      
      Severity: Minor
      Found in miasm/arch/x86/regs.py - About 4 hrs to fix

        Function from_ExprOp has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

            def from_ExprOp(self, expr):
                args = list(map(self.from_expr, expr.args))
                res = args[0]
        
                if len(args) > 1:
        Severity: Minor
        Found in miasm/ir/translators/z3_ir.py - About 4 hrs 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_symb has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

        def intra_block_flow_symb(lifter, _, flow_graph, irblock, in_nodes, out_nodes):
            symbols_init = lifter.arch.regs.regs_init.copy()
            sb = SymbolicExecutionEngine(lifter, symbols_init)
            sb.eval_updt_irblock(irblock)
            print('*' * 40)
        Severity: Minor
        Found in example/expression/graph_dataflow.py - About 4 hrs 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 visit has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

            def visit(self, expr, *args, **kwargs):
                if expr.is_int() or expr.is_id() or expr.is_loc():
                    pass
                elif expr.is_assign():
                    ret = self.visit(expr.dst, *args, **kwargs)
        Severity: Minor
        Found in miasm/expression/expression.py - About 4 hrs 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 arg2str has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

            def arg2str(expr, index=None, loc_db=None):
                wb = False
                if expr.is_id() or expr.is_int():
                    return str(expr)
                elif expr.is_loc():
        Severity: Minor
        Found in miasm/arch/aarch64/arch.py - About 4 hrs 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 src_gen_phi_node_srcs has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

            def src_gen_phi_node_srcs(self, equivalence_graph):
                for node in equivalence_graph.nodes():
                    if not node.is_op("Phi"):
                        continue
                    phi_successors = equivalence_graph.successors(node)
        Severity: Minor
        Found in miasm/analysis/data_flow.py - About 4 hrs 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 ldz has a Cognitive Complexity of 32 (exceeds 5 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 4 hrs 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 a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_ir(self, instr):
                args = instr.args[:]
                if instr.name[0:5] in [ 'ADDIS', 'ORIS', 'XORIS', 'ANDIS' ]:
                    args[2] = ExprInt(int(args[2]) << 16, 32)
                if instr.name[0:3] == 'ADD':
        Severity: Minor
        Found in miasm/arch/ppc/sem.py - About 4 hrs 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 modrm2expr has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

        def modrm2expr(modrm, parent, w8, sx=0, xmm=0, mm=0, bnd=0):
            o = []
            if not modrm[f_isad]:
                modrm_k = [key for key, value in viewitems(modrm) if value == 1]
                if len(modrm_k) != 1:
        Severity: Minor
        Found in miasm/arch/x86/arch.py - About 4 hrs 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 gete has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

            def gete(self, raw, off):
                if not off:
                    return None, off
                if self.parent_head._wsize == 32:
                    mask_ptr = 0x80000000
        Severity: Minor
        Found in miasm/loader/pe.py - About 4 hrs 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 gete has a Cognitive Complexity of 32 (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 4 hrs 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 vm_load_pe has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

        def vm_load_pe(vm, fdata, align_s=True, load_hdr=True, name="", winobjs=None, **kargs):
            """Load a PE in memory (@vm) from a data buffer @fdata
            @vm: VmMngr instance
            @fdata: data buffer to parse
            @align_s: (optional) If False, keep gaps between section
        Severity: Minor
        Found in miasm/jitter/loader/pe.py - About 4 hrs 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_objc has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_objc(self, type_id, resolved=None, to_fix=None, lvl=0):
                if resolved is None:
                    resolved = {}
                if to_fix is None:
                    to_fix = []
        Severity: Minor
        Found in miasm/core/objc.py - About 4 hrs 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

        File sem.py has 358 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #-*- coding:utf-8 -*-
        
        from miasm.expression.expression import *
        from miasm.arch.msp430.regs import *
        from miasm.arch.msp430.arch import mn_msp430
        Severity: Minor
        Found in miasm/arch/msp430/sem.py - About 4 hrs to fix
          Severity
          Category
          Status
          Source
          Language