cea-sec/miasm

View on GitHub

Showing 1,373 of 3,020 total issues

Function ast_parse_op has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def ast_parse_op(tokens):
    if len(tokens) == 1:
        return tokens[0]
    if len(tokens) == 2:
        if tokens[0] in ['-', '+', '!']:
Severity: Minor
Found in miasm/core/cpu.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_bad_blocks_predecessors has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def get_bad_blocks_predecessors(self, strict=False):
        """Iterator on loc_keys with an AsmBlockBad destination
        @strict: (optional) if set, return loc_key with only bad
        successors
        """
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 reduce_op_array has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def reduce_op_array(self, node, **kwargs):
        """Reduce array operator"""

        if not node.expr.is_op('[]'):
            return None
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 __setitem__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def __setitem__(self, asked_key, value):
        if asked_key not in self._data:
            # Update internal size and use's counter
            self._size += 1

Severity: Minor
Found in miasm/core/utils.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 build_graph has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def build_graph(start_addr, type_graph, simplify=False, use_ida_stack=True, dontmodstack=False, loadint=False, verbose=False):
    machine = guess_machine(addr=start_addr)
    dis_engine, lifter_model_call = machine.dis_engine, machine.lifter_model_call

    class IRADelModCallStack(lifter_model_call):
Severity: Minor
Found in example/ida/graph_ir.py - About 1 hr to fix

    Function build_content has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def build_content(self):
    
            content = StrPatchwork()
            content[0] = bytes(self.Doshdr)
    
    
    Severity: Minor
    Found in miasm/loader/pe_init.py - About 1 hr to fix

      Function __init__ has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, lifter, jit_type="gcc"):
              """Init an instance of jitter.
              @lifter: Lifter instance for this architecture
              @jit_type: JiT backend to use. Available options are:
                  - "gcc"
      Severity: Minor
      Found in miasm/jitter/jitload.py - About 1 hr to fix

        Function st_ld_r has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def st_ld_r(ir, instr, a, a2, b, store=False, size=32, s_ext=False, z_ext=False):
        Severity: Major
        Found in miasm/arch/arm/sem.py - About 1 hr to fix

          Function _shift_tpl has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def _shift_tpl(op, ir, instr, a, b, c=None, op_inv=None, left=False,
          Severity: Major
          Found in miasm/arch/x86/sem.py - About 1 hr to fix

            Function cache_dst has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def cache_dst(self):
                    final_dst = None
                    final_linenb = None
                    for linenb, assignblk in enumerate(self):
                        for dst, src in viewitems(assignblk):
            Severity: Minor
            Found in miasm/ir/ir.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 kernel32_CreateMutex has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def kernel32_CreateMutex(jitter, funcname, get_str):
                ret_ad, args = jitter.func_args_stdcall(["mutexattr", "initowner",
                                                         "lpname"])
            
                if args.lpname:
            Severity: Minor
            Found in miasm/os_dep/win_api_x86_32.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 OnFormChange has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def OnFormChange(self, fid):
                    if fid == -1: # INIT
                        self.EnableField(self.functionAddr, True)
                        self.EnableField(self.startAddr, False)
                        self.EnableField(self.endAddr, False)
            Severity: Minor
            Found in example/ida/ctype_propagation.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 simp_cond_op_int has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def simp_cond_op_int(_, expr):
                "Extract conditions from operations"
            
            
                # x?a:b + x?c:d + e => x?(a+c+e:b+d+e)
            Severity: Minor
            Found in miasm/expression/simplifications_common.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 simp_cond_logic_ext has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def simp_cond_logic_ext(expr_s, expr):
                """(X.zeroExt() + ... + Int) ? A:B => X + ... + int[:] ? A:B"""
                cond = expr.cond
                if not cond.is_op():
                    return expr
            Severity: Minor
            Found in miasm/expression/simplifications_common.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 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def encode(self):
                    expr = self.expr
                    if not isinstance(expr, m2_expr.ExprOp):
                        return False
                    if expr.op != 'preinc':
            Severity: Minor
            Found in miasm/arch/aarch64/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 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def encode(self):
                    size = self.expr.size
                    if not test_set_sf(self.parent, size):
                        return False
                    if isinstance(self.expr, m2_expr.ExprId):
            Severity: Minor
            Found in miasm/arch/aarch64/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 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def encode(self):
                    if isinstance(self.expr, m2_expr.ExprInt):
                        if int(self.expr) > 0xFFFF:
                            return False
                        self.value = int(self.expr)
            Severity: Minor
            Found in miasm/arch/aarch64/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 dstflow2label has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def dstflow2label(self, loc_db):
                    if self.name in ["CBZ", "CBNZ"]:
                        expr = self.args[1]
                    else:
                        expr = self.args[0]
            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 encode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def encode(self):
                    e = self.expr
                    rlist = []
                    reg_l = list(e.args)
            
            
            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 v_opmode_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def v_opmode_info(size, opmode, rex_w, stk):
                if size in [16, 32]:
                    if opmode:
                        return invmode[size]
                    else:
            Severity: Minor
            Found in miasm/arch/x86/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

            Severity
            Category
            Status
            Source
            Language