cea-sec/miasm

View on GitHub

Showing 3,020 of 3,020 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def slice_rest(expr):
    "Return the completion of the current slice"
    size = expr.arg.size
    if expr.start >= size or expr.stop > size:
        raise ValueError('bad slice rest %s %s %s' %
Severity: Major
Found in miasm/ir/ir.py and 1 other location - About 1 day to fix
miasm/expression/expression.py on lines 1401..1417

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 146.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function fromstring has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

    def fromstring(cls, text, loc_db, mode = None):
        global total_scans
        name = re.search(r'(\S+)', text).groups()
        if not name:
            raise ValueError('cannot find name', text)
Severity: Minor
Found in miasm/core/cpu.py - About 1 day 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def fixDstOffset(self):
        e = self.args[0]
        if self.offset is None:
            raise ValueError('symbol not resolved %s' % l)
        if not isinstance(e, ExprInt):
Severity: Major
Found in miasm/arch/arm/arch.py and 1 other location - About 1 day to fix
miasm/arch/arm/arch.py on lines 636..649

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 142.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def fixDstOffset(self):
        e = self.args[0]
        if self.offset is None:
            raise ValueError('symbol not resolved %s' % l)
        if not isinstance(e, ExprInt):
Severity: Major
Found in miasm/arch/arm/arch.py and 1 other location - About 1 day to fix
miasm/arch/arm/arch.py on lines 557..567

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 142.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def sys_x86_64_writev(jitter, linux_env):
    # Parse arguments
    fd, vec, vlen = jitter.syscall_args_systemv(3)
    log.debug("sys_writev(%d, %d, %x)", fd, vec, vlen)

Severity: Major
Found in miasm/os_dep/linux/syscall.py and 1 other location - About 1 day to fix
miasm/os_dep/linux/syscall.py on lines 268..284

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 140.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def sys_arml_writev(jitter, linux_env):
    # Parse arguments
    fd, vec, vlen = jitter.syscall_args_systemv(3)
    log.debug("sys_writev(%d, %d, %x)", fd, vec, vlen)

Severity: Major
Found in miasm/os_dep/linux/syscall.py and 1 other location - About 1 day to fix
miasm/os_dep/linux/syscall.py on lines 249..265

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 140.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function _dis_block has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    def _dis_block(self, offset, job_done=None):
        """Disassemble the block at offset @offset
        @job_done: a set of already disassembled addresses
        Return the created AsmBlock and future offsets to disassemble
        """
Severity: Minor
Found in miasm/core/asmblock.py - About 1 day 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_op("CC_U>=") and
          test_cc_eq_args(
              expr,
              "FLAG_SUB_CF"
          )):
Severity: Critical
Found in miasm/expression/simplifications_common.py - About 1 day to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            if isinstance(expr, ExprId):
                r, s = expr, None
            elif len(expr.args) == 1 and isinstance(expr.args[0], ExprId):
                r, s = expr.args[0], None
            elif isinstance(expr.args[0], ExprId):
    Severity: Major
    Found in miasm/arch/arm/arch.py and 1 other location - About 1 day to fix
    miasm/arch/arm/arch.py on lines 401..408

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 138.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            if isinstance(expr, ExprId):
                r, s = expr, None
            elif len(expr.args) == 1 and isinstance(expr.args[0], ExprId):
                r, s = expr.args[0], None
            elif isinstance(expr.args[0], ExprId):
    Severity: Major
    Found in miasm/arch/arm/arch.py and 1 other location - About 1 day to fix
    miasm/arch/arm/arch.py on lines 474..481

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 138.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function process_messages has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_messages(self):
    
            while self.recv_queue:
                msg = self.recv_queue.pop(0)
                buf = BytesIO(msg)
    Severity: Minor
    Found in miasm/analysis/gdbserver.py - About 1 day 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 dis has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

        def dis(cls, bs_o, mode_o = None, offset=0):
            if not isinstance(bs_o, bin_stream):
                bs_o = bin_stream_str(bs_o)
    
            bs_o.enter_atomic_mode()
    Severity: Minor
    Found in miasm/core/cpu.py - About 1 day 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 fill_loc_db_with_symbols has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

    def fill_loc_db_with_symbols(elf, loc_db, base_addr=0):
        """Parse the miasm.loader's ELF @elf to extract symbols, and fill the LocationDB
        instance @loc_db with parsed symbols.
    
        The ELF is considered mapped at @base_addr
    Severity: Minor
    Found in miasm/jitter/loader/elf.py - About 1 day 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_equivalence_class has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_equivalence_class(self, node, ids_to_src):
            todo = set([node])
            done = set()
            defined = set()
            equivalence = set()
    Severity: Minor
    Found in miasm/analysis/data_flow.py - About 1 day 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 535 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import miasm.expression.expression as m2_expr
    from miasm.ir.ir import Lifter, IRBlock, AssignBlock
    from miasm.arch.mips32.arch import mn_mips32
    from miasm.arch.mips32.regs import R_LO, R_HI, PC, RA, ZERO, exception_flags
    from miasm.core.sembuilder import SemBuilder
    Severity: Major
    Found in miasm/arch/mips32/sem.py - About 1 day to fix

      DiGraph has 61 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class DiGraph(object):
      
          """Implementation of directed graph"""
      
          # Stand for a cell in a dot node rendering
      Severity: Major
      Found in miasm/core/graph.py - About 1 day to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if op_b.is_op() and op_b.op in ["+", "^"]:
                args = list(op_b.args)
                if op_a in args:
                    args.remove(op_a)
                    if not args:
        Severity: Major
        Found in miasm/expression/simplifications_common.py and 1 other location - About 1 day to fix
        miasm/expression/simplifications_common.py on lines 1101..1111

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 131.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if op_a.is_op() and op_a.op in ["+", "^"]:
                args = list(op_a.args)
                if op_b in args:
                    args.remove(op_b)
                    if not args:
        Severity: Major
        Found in miasm/expression/simplifications_common.py and 1 other location - About 1 day to fix
        miasm/expression/simplifications_common.py on lines 1113..1123

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 131.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        File codegen.py has 529 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        Module to generate C code for a given native @block
        """
        
        from builtins import zip
        Severity: Major
        Found in miasm/jitter/codegen.py - About 1 day to fix

          File dse.py has 526 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """Dynamic symbolic execution module.
          
          Offers a way to have a symbolic execution along a concrete one.
          Basically, this is done through DSEEngine class, with scheme:
          
          
          Severity: Major
          Found in miasm/analysis/dse.py - About 1 day to fix
            Severity
            Category
            Status
            Source
            Language