cea-sec/miasm

View on GitHub

Showing 3,020 of 3,020 total issues

File ctype_propagation.py has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import print_function
import ida_kernwin
import idc
import ida_funcs

Severity: Minor
Found in example/ida/ctype_propagation.py - About 2 hrs to fix

    Jitter has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Jitter(object):
    
        "Main class for JIT handling"
    
        C_Gen = CGen
    Severity: Minor
    Found in miasm/jitter/jitload.py - About 2 hrs to fix

      cls_mn has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class cls_mn(with_metaclass(metamn, object)):
          args_symb = []
          instruction = instruction
          # Block's offset alignment
          alignment = 1
      Severity: Minor
      Found in miasm/core/cpu.py - About 2 hrs to fix

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

        aarch64op("stlrb",[bs('0'), bs('0'), bs('001000'), bs('1'), bs('0'), bs('0'), bs('11111'), bs('1'), bs('11111'), rn64_deref_nooff, rt32], [rt32, rn64_deref_nooff])
        Severity: Major
        Found in miasm/arch/aarch64/arch.py and 5 other locations - About 2 hrs to fix
        miasm/arch/aarch64/arch.py on lines 2277..2277
        miasm/arch/aarch64/arch.py on lines 2280..2280
        miasm/arch/aarch64/arch.py on lines 2287..2287
        miasm/arch/aarch64/arch.py on lines 2288..2288
        miasm/arch/aarch64/arch.py on lines 2294..2294

        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 60.

        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

                    for dst in irblock[0]:
                        new_var = self.phi_new_var[dst]
                        for parent, src in self.phi_parent_sources[dst]:
                            parent_to_parallel_copies.setdefault(parent, {})[new_var] = src
        Severity: Major
        Found in miasm/analysis/outofssa.py and 1 other location - About 2 hrs to fix
        miasm/analysis/outofssa.py on lines 82..85

        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 60.

        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 6 locations. Consider refactoring.
        Open

        aarch64op("ldxrh", [bs('0'), bs('1'), bs('001000'), bs('0'), bs('1'), bs('0'), bs('11111'), bs('0'), bs('11111'), rn64_deref_nooff, rt32], [rt32, rn64_deref_nooff])
        Severity: Major
        Found in miasm/arch/aarch64/arch.py and 5 other locations - About 2 hrs to fix
        miasm/arch/aarch64/arch.py on lines 2277..2277
        miasm/arch/aarch64/arch.py on lines 2287..2287
        miasm/arch/aarch64/arch.py on lines 2288..2288
        miasm/arch/aarch64/arch.py on lines 2293..2293
        miasm/arch/aarch64/arch.py on lines 2294..2294

        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 60.

        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 6 locations. Consider refactoring.
        Open

        aarch64op("stlrh",[bs('0'), bs('1'), bs('001000'), bs('1'), bs('0'), bs('0'), bs('11111'), bs('1'), bs('11111'), rn64_deref_nooff, rt32], [rt32, rn64_deref_nooff])
        Severity: Major
        Found in miasm/arch/aarch64/arch.py and 5 other locations - About 2 hrs to fix
        miasm/arch/aarch64/arch.py on lines 2277..2277
        miasm/arch/aarch64/arch.py on lines 2280..2280
        miasm/arch/aarch64/arch.py on lines 2287..2287
        miasm/arch/aarch64/arch.py on lines 2288..2288
        miasm/arch/aarch64/arch.py on lines 2293..2293

        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 60.

        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 6 locations. Consider refactoring.
        Open

        aarch64op("ldarb",[bs('0'), bs('0'), bs('001000'), bs('1'), bs('1'), bs('0'), bs('11111'), bs('1'), bs('11111'), rn64_deref_nooff, rt32], [rt32, rn64_deref_nooff])
        Severity: Major
        Found in miasm/arch/aarch64/arch.py and 5 other locations - About 2 hrs to fix
        miasm/arch/aarch64/arch.py on lines 2277..2277
        miasm/arch/aarch64/arch.py on lines 2280..2280
        miasm/arch/aarch64/arch.py on lines 2288..2288
        miasm/arch/aarch64/arch.py on lines 2293..2293
        miasm/arch/aarch64/arch.py on lines 2294..2294

        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 60.

        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 6 locations. Consider refactoring.
        Open

        aarch64op("ldarh",[bs('0'), bs('1'), bs('001000'), bs('0'), bs('1'), bs('0'), bs('11111'), bs('1'), bs('11111'), rn64_deref_nooff, rt], [rt, rn64_deref_nooff])
        Severity: Major
        Found in miasm/arch/aarch64/arch.py and 5 other locations - About 2 hrs to fix
        miasm/arch/aarch64/arch.py on lines 2277..2277
        miasm/arch/aarch64/arch.py on lines 2280..2280
        miasm/arch/aarch64/arch.py on lines 2287..2287
        miasm/arch/aarch64/arch.py on lines 2293..2293
        miasm/arch/aarch64/arch.py on lines 2294..2294

        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 60.

        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

                    for dst in irblock[0]:
                        new_var = self.phi_new_var[dst]
                        for parent, src in self.phi_parent_sources[dst]:
                            parent_to_parallel_copies.setdefault(parent, {})[new_var] = src
        Severity: Major
        Found in miasm/analysis/outofssa.py and 1 other location - About 2 hrs to fix
        miasm/analysis/outofssa.py on lines 337..340

        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 60.

        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 6 locations. Consider refactoring.
        Open

        aarch64op("ldxrb", [bs('0'), bs('0'), bs('001000'), bs('0'), bs('1'), bs('0'), bs('11111'), bs('0'), bs('11111'), rn64_deref_nooff, rt32], [rt32, rn64_deref_nooff])
        Severity: Major
        Found in miasm/arch/aarch64/arch.py and 5 other locations - About 2 hrs to fix
        miasm/arch/aarch64/arch.py on lines 2280..2280
        miasm/arch/aarch64/arch.py on lines 2287..2287
        miasm/arch/aarch64/arch.py on lines 2288..2288
        miasm/arch/aarch64/arch.py on lines 2293..2293
        miasm/arch/aarch64/arch.py on lines 2294..2294

        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 60.

        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

            elif cls1 == ExprSlice:
                ret = compare_exprs(expr1.arg, expr2.arg)
                if ret:
                    return ret
                ret = cmp_elts(expr1.start, expr2.start)
        Severity: Major
        Found in miasm/expression/expression.py and 1 other location - About 2 hrs to fix
        miasm/expression/expression.py on lines 1579..1587

        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 60.

        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 lh(ir, instr, reg_dst, deref_dst):
            """LH - Load Halfword from memory"""
        
            # Rn <- SignExt(MemHword(Rm31..1||0))
            # Rn <- SignExt(MemHword((ZeroExt((disp7)6..1||0)+TP)31..1||0)
        Severity: Major
        Found in miasm/arch/mep/sem.py and 1 other location - About 2 hrs to fix
        miasm/arch/mep/sem.py on lines 177..185

        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 60.

        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 lhu(ir, instr, reg_dst, deref_dst):
            """LHU - Load an unsigned Halfword from memory"""
        
            # Rn <- ZeroExt(MemHword(Rm31..1||0))
            # Rn <- ZeroExt(MemHword((SignExt(disp16)+Rm)31..1||0))
        Severity: Major
        Found in miasm/arch/mep/sem.py and 1 other location - About 2 hrs to fix
        miasm/arch/mep/sem.py on lines 138..146

        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 60.

        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

            elif cls2 == ExprCond:
                ret = compare_exprs(expr1.cond, expr2.cond)
                if ret:
                    return ret
                ret = compare_exprs(expr1.src1, expr2.src1)
        Severity: Major
        Found in miasm/expression/expression.py and 1 other location - About 2 hrs to fix
        miasm/expression/expression.py on lines 1597..1605

        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 60.

        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 possible_values has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        def possible_values(expr):
            """Return possible values for expression @expr, associated with their
            condition constraint as a ConstrainedValues instance
            @expr: Expr instance
            """
        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 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def encode(self):
                e = self.expr
                if e in self.reg_info.expr:
                    self.parent.a_s.value = 0
                    self.value = self.reg_info.expr.index(e)
        Severity: Minor
        Found in miasm/arch/msp430/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 _shift_rotate_tpl has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        def _shift_rotate_tpl(ir, instr, dst, shift_operation, setflags=False, is_not=False, onlyCarry=False):
            """
            Template to generate a shift/rotate
            A temporary basic block is generated to handle 0-shift
            @dst: destination
        Severity: Minor
        Found in miasm/arch/arm/sem.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 _shift_tpl has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        def _shift_tpl(op, ir, instr, a, b, c=None, op_inv=None, left=False,
                       custom_of=None):
            """Template to generate a shifter with operation @op
            A temporary basic block is generated to handle 0-shift
            @op: operation to execute
        Severity: Minor
        Found in miasm/arch/x86/sem.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_ir has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_ir(self, instr):
                args = instr.args[:]
                args = [arg.replace_expr(float_replace) for arg in args]
                args = fix_mem_args_size(instr, *args)
                my_ss = None
        Severity: Minor
        Found in miasm/arch/x86/sem.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