cea-sec/miasm

View on GitHub

Showing 1,373 of 3,019 total issues

Function get_block_loc_keys has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def get_block_loc_keys(block):
    """Extract loc_keys used by @block"""
    symbols = set()
    for instr in block.lines:
        if isinstance(instr, AsmRaw):
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 group_constrained_blocks has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def group_constrained_blocks(asmcfg):
    """
    Return the BlockChains list built from grouped blocks in asmcfg linked by
    asm_constraint_next
    @asmcfg: an AsmCfg instance
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 digest_decl has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def digest_decl(self, c_str):

        char_id = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"


Severity: Minor
Found in miasm/core/ctypesmngr.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

Consider simplifying this complex logical expression.
Open

        if expr.is_id() or expr.is_int():
            return str(expr)
        elif expr.is_loc():
            if loc_db is not None:
                return loc_db.pretty_str(expr.loc_key)
Severity: Critical
Found in miasm/arch/aarch64/arch.py - About 1 hr to fix

    Function kernel32_WaitForSingleObject has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def kernel32_WaitForSingleObject(jitter):
        ret_ad, args = jitter.func_args_stdcall(['handle', 'dwms'])
    
        t_start = time.time() * 1000
        found = False
    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 find_call has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_call(ircfg):
        """Returns (irb, index) which call"""
    
        for irb in viewvalues(ircfg.blocks):
            out = set()
    Severity: Minor
    Found in example/expression/access_c.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 _set has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _set(self, dst, src):
            """
            Special cases:
            * if dst is an ExprSlice, expand it to assign the full Expression
            * if dst already known, sources are merged
    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 simp_cmp_int has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def simp_cmp_int(expr_simp, expr):
        """
        ({X, 0} == int) => X == int[:]
        X + int1 == int2 => X == int2-int1
        X ^ int1 == int2 => X == int1^int2
    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_factor has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def simp_cond_factor(e_s, expr):
        "Merge similar conditions"
        if not expr.op in ["+", "|", "^", "&", "*", '<<', '>>', 'a>>']:
            return expr
        if len(expr.args) < 2:
    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 categorize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def categorize(self, node, lvl=0, **kwargs):
            """Recursively apply rules to @node
    
            @node: ExprNode to analyze
            @lvl: actual recursion level
    Severity: Minor
    Found in miasm/expression/expression_reduce.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 msr has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def msr(ir, instr, arg1, arg2, arg3, arg4, arg5, arg6):
    
        e = []
        if arg1.is_int(3) and arg2.is_int(3) and arg3.is_id("c4") and arg4.is_id("c2") and arg5.is_int(0):
            e.append(ExprAssign(nf, arg6[31:32]))
    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 arg2str has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def arg2str(expr, index=None, loc_db=None):
            if isinstance(expr, ExprId) or isinstance(expr, ExprInt):
                return str(expr)
            elif expr.is_loc():
                if loc_db is not None:
    Severity: Minor
    Found in miasm/arch/sh4/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 block2assignblks has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def block2assignblks(self, block):
            irblocks_list = super(mipsCGen, self).block2assignblks(block)
            for irblocks in irblocks_list:
                for blk_idx, irblock in enumerate(irblocks):
                    has_breakflow = any(assignblock.instr.breakflow() for assignblock in irblock)
    Severity: Minor
    Found in miasm/arch/mips32/jit.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 mn_do_sub has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def mn_do_sub(ir, instr, arg1, arg2, arg3):
        assert instr.name[0:4] == 'SUBF'
    
        flags_update = []
    
    
    Severity: Minor
    Found in miasm/arch/ppc/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 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def encode(self):
            self.value = 0
            p = self.parent
            expr = self.expr
            osize = p.v_opmode()
    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

    Function discard_phi_sources has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def discard_phi_sources(ircfg, deleted_vars):
        """
        Remove phi sources in @ircfg belonging to @deleted_vars set
        @ircfg: IRCFG instance in ssa form
        @deleted_vars: unused phi sources
    Severity: Minor
    Found in miasm/analysis/data_flow.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 parse_messages has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_messages(self, data):
            buf = BytesIO(data)
            msgs = []
    
            while (buf.tell() < buf.len):
    Severity: Minor
    Found in miasm/analysis/gdbserver.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 __init__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, parent, sex, size):
            self.parent = parent
            self.shlist = []
            ehdr = self.parent.Ehdr
            of1 = ehdr.shoff
    Severity: Minor
    Found in miasm/loader/elf_init.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 from_ssa has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_ssa(cls, ssa):
            """
            Return a DefUse DiGraph from a SSA graph
            @ssa: SSADiGraph instance
            """
    Severity: Minor
    Found in miasm/analysis/data_flow.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 add_reloc has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_reloc(self, rels, rtype=3, patchrel=True):
            dirrel = self.parent_head.NThdr.optentries[DIRECTORY_ENTRY_BASERELOC]
            if not rels:
                return
            rels.sort()
    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

    Severity
    Category
    Status
    Source
    Language