cea-sec/miasm

View on GitHub

Showing 1,373 of 3,020 total issues

Consider simplifying this complex logical expression.
Open

    if (expr.is_op("addr") and
            expr.args[0].is_op("[]") and
            expr.args[0].args[1] == ExprInt(0, 64)):
        return expr.args[0].args[0]
    elif (expr.is_op("[]") and
Severity: Critical
Found in miasm/core/objc.py - About 1 hr to fix

    Function fake_seh_handler has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def fake_seh_handler(jitter, except_code, previous_seh=None):
        """
        Create an exception context
        @jitter: jitter instance
        @except_code: x86 exception code
    Severity: Minor
    Found in miasm/os_dep/win_api_x86_32_seh.py - About 1 hr to fix

      Function parse_content has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def parse_content(self,
                            parse_resources=True,
                            parse_delay=True,
                            parse_reloc=True):
              off = 0
      Severity: Minor
      Found in miasm/loader/pe_init.py - About 1 hr to fix

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

        def kernel32_MultiByteToWideChar(jitter):
            MB_ERR_INVALID_CHARS = 0x8
            CP_ACP  = 0x000
            CP_1252 = 0x4e4
        
        
        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 open_ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def open_(self, path, flags, follow_link=True):
                path = self.resolve_path(path, follow_link=follow_link)
                if not os.path.exists(path):
                    # ENOENT (No such file or directory)
                    return -1
        Severity: Minor
        Found in miasm/os_dep/linux/environment.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_variable_parts has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_variable_parts(self, index, known_offsets, forward=True):
                """
                Find consecutive memory parts representing the same variable. The part
                starts at offset known_offsets[@index] and search is in offset direction
                determined by @forward
        Severity: Minor
        Found in miasm/ir/symbexec.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 ntdll_RtlFindCharInUnicodeString has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def ntdll_RtlFindCharInUnicodeString(jitter):
            ret_ad, args = jitter.func_args_stdcall(["flags", "main_str_ad",
                                                     "search_chars_ad", "pos_ad"])
        
            if args.flags != 0:
        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 simp_compose_and_mask has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def simp_compose_and_mask(_, expr):
            """
            {X 0 8, Y 8 32} & 0xFF => zeroExt(X)
            {X 0 8, Y 8 16, Z 16 32} & 0xFFFF => {X 0 8, Y 8 16, 0x0 16 32}
            {X 0 8, 0x123456 8 32} & 0xFFFFFF => {X 0 8, 0x1234 8 24, 0x0 24 32}
        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 edge2str has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def edge2str(self, nfrom, nto):
                if isinstance(nfrom, ExprCompose):
                    for i in nfrom.args:
                        if i[0] == nto:
                            return "[%s, %s]" % (i[1], i[2])
        Severity: Minor
        Found in miasm/expression/expression.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_sign_inf_zeroext has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def simp_sign_inf_zeroext(expr_s, expr):
            """
            [!] Ensure before: X.zeroExt(X.size) => X
        
            X.zeroExt() <s 0 => 0
        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 expr_simp_inverse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def expr_simp_inverse(expr_simp, e):
            """(x <u y) ^ ((x ^ y) [31:32]) == x <s y,
            (x <s y) ^ ((x ^ y) [31:32]) == x <u y"""
        
            to_match = (ExprOp_inf_unsigned(jok1, jok2) ^ jok_small)
        Severity: Minor
        Found in miasm/expression/simplifications_cond.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_cmp_int_int has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def simp_cmp_int_int(_, expr):
            """
            IntA <s IntB => int
            IntA <u IntB => int
            IntA <=s IntB => int
        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 extend_arg has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def extend_arg(dst, arg):
            if not isinstance(arg, ExprOp):
                return arg
        
            op, (reg, shift) = arg.op, arg.args
        Severity: Minor
        Found in miasm/arch/aarch64/sem.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 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def encode(self):
                expr = self.expr
                if not isinstance(expr, m2_expr.ExprOp):
                    return False
                if not expr.op in ['postinc', 'preinc_wb', '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 flen has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def flen(cls, mode, v):
                if v['a_s'] == 0b00:
                    return None
                elif v['a_s'] == 0b01:
                    if v['sreg'] in [3]:
        Severity: Minor
        Found in miasm/arch/msp430/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 arg2str has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def arg2str(expr, pos=None, loc_db=None):
                """Convert mnemonics arguments into readable strings according to the
                MeP-c4 architecture manual and their internal types
        
                Notes:
        Severity: Minor
        Found in miasm/arch/mep/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 div has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def div(rn, rm):
            """DIV - Signed division"""
        
            # LO <- Rn / Rm, HI <- Rn % Rm (Signed)
        
        
        Severity: Minor
        Found in miasm/arch/mep/sem.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 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def encode(self):
                if (isinstance(self.expr, ExprOp) and
                      self.expr.op == allshifts[self.index_op]):
                    reg, value = self.expr.args
                    if reg not in gpregs.expr:
        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 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def encode(self):
                self.parent.add_imm.value = 1
                self.parent.imm.value = 0
                expr = self.expr
                if not isinstance(expr, ExprMem):
        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 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def encode(self):
                if not isinstance(self.expr, ExprMem):
                    return False
                ptr = self.expr.ptr
                if not ptr.is_op('preinc'):
        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

        Severity
        Category
        Status
        Source
        Language