cea-sec/miasm

View on GitHub

Showing 1,373 of 3,019 total issues

Function set_rva has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def set_rva(self, rva, size=None):
        rva_size = self.parent_head._wsize // 8
        self.parent_head.NThdr.optentries[DIRECTORY_ENTRY_DELAY_IMPORT].rva = rva
        if not size:
            self.parent_head.NThdr.optentries[DIRECTORY_ENTRY_DELAY_IMPORT].size = len(self)
Severity: Minor
Found in miasm/loader/pe.py - About 2 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 _init_variable_defs has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def _init_variable_defs(self, head):
        """
        Initialises all variable definitions and
        assigns the corresponding IRBlocks.

Severity: Minor
Found in miasm/analysis/ssa.py - About 2 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 del_block_in_range has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def del_block_in_range(self, ad1, ad2):
        """Find and remove jitted block in range [ad1, ad2].
        Return the list of block removed.
        @ad1: First address
        @ad2: Last address
Severity: Minor
Found in miasm/jitter/jitcore.py - About 2 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 __init__ has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, strbits=None, l=None, cls=None,
                 fname=None, order=0, flen=None, **kargs):
        if fname is None:
            fname = hex(id(str((strbits, l, cls, fname, order, flen, kargs))))
        if strbits is None:
Severity: Minor
Found in miasm/core/cpu.py - About 2 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

Consider simplifying this complex logical expression.
Open

        if self.name == "SSARB":
            # The first operand is displayed in decimal, not in hex
            o += " %d" % int(self.args[0])
            o += self.arg2str(self.args[1])

Severity: Critical
Found in miasm/arch/mep/arch.py - About 2 hrs to fix

    mn_x86 has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class mn_x86(cls_mn):
        name = "x86"
        prefix_op_size = False
        prefix_ad_size = False
        regs = regs_module
    Severity: Minor
    Found in miasm/arch/x86/arch.py - About 2 hrs to fix

      Debugguer has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Debugguer(object):
      
          "Debugguer linked with a Jitter instance"
      
          def __init__(self, myjit):
      Severity: Minor
      Found in miasm/analysis/debugging.py - About 2 hrs to fix

        Function find_variables_rec has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def find_variables_rec(self, expr):
                """Recursive method called by find_variable to expand @expr.
                Set @var_names and @var_values.
                This implementation is faster than an expression visitor because
                we do not rebuild each expression.
        Severity: Minor
        Found in miasm/expression/expression_helper.py - About 2 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 encode has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def encode(self):
                if not isinstance(self.expr, m2_expr.ExprOp):
                    return False
                if len(self.expr.args) != 2:
                    return False
        Severity: Minor
        Found in miasm/arch/aarch64/arch.py - About 2 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 __str__ has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def __str__(self):
                """Return the mnemonic as a string.
        
                Note:
                    - it is not mandatory as the instruction class already implement
        Severity: Minor
        Found in miasm/arch/mep/arch.py - About 2 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 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def arg2html(expr, index=None, loc_db=None):
                if expr.is_id() or expr.is_int() or expr.is_loc():
                    o = color_expr_html(expr, loc_db)
                elif ((isinstance(expr, ExprOp) and expr.op == 'far' and
                       isinstance(expr.args[0], ExprMem)) or
        Severity: Minor
        Found in miasm/arch/x86/arch.py - About 2 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 exprfindmod has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def exprfindmod(e, o=None):
            if o is None:
                o = {}
            if isinstance(e, ExprInt):
                return e
        Severity: Minor
        Found in miasm/arch/x86/arch.py - About 2 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_useful_assignments has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_useful_assignments(self, ircfg, defuse, reaching_defs):
                """
                Mark useful statements using previous reach analysis and defuse
        
                Return a set of triplets (block, assignblk number, lvalue) of
        Severity: Minor
        Found in miasm/analysis/data_flow.py - About 2 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 _compute_def_use_block has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def _compute_def_use_block(self, block, reaching_defs, deref_mem=False, apply_simp=False):
                for index, assignblk in enumerate(block):
                    assignblk_reaching_defs = reaching_defs.get_definitions(block.loc_key, index)
                    for lval, expr in viewitems(assignblk):
                        self.add_node(AssignblkNode(block.loc_key, index, lval))
        Severity: Minor
        Found in miasm/analysis/data_flow.py - About 2 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 __init__ has a Cognitive Complexity of 17 (exceeds 5 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 2 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 assemble_block has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def assemble_block(mnemo, block, conservative=False):
            """Assemble a @block
            @conservative: (optional) use original bytes when possible
            """
            offset_i = 0
        Severity: Minor
        Found in miasm/core/asmblock.py - About 2 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 ast_get_c_access_expr has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def ast_get_c_access_expr(ast, expr_types, lvl=0):
            """Transform C ast object into a C Miasm expression
        
            @ast: parsed pycparser.c_ast object
            @expr_types: a dictionary linking ID names to their types
        Severity: Minor
        Found in miasm/core/objc.py - About 2 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 asm has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def asm(cls, instr, loc_db=None):
                """
                Re asm instruction by searching mnemo using name and args. We then
                can modify args and get the hex of a modified instruction
                """
        Severity: Minor
        Found in miasm/core/cpu.py - About 2 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 smt2.py has 256 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from builtins import map
        from builtins import range
        import logging
        
        from miasm.ir.translators.translator import Translator
        Severity: Minor
        Found in miasm/ir/translators/smt2.py - About 2 hrs to fix

          Function __init__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, op, *args):
                  """Create an ExprOp
                  @op: str, operation
                  @*args: Expr, operand list
                  """
          Severity: Minor
          Found in miasm/expression/expression.py - About 2 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

          Severity
          Category
          Status
          Source
          Language