cea-sec/miasm

View on GitHub

Showing 3,020 of 3,020 total issues

File debugging.py has 427 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import print_function
from builtins import map
from builtins import range
import cmd
from future.utils import viewitems
Severity: Minor
Found in miasm/analysis/debugging.py - About 6 hrs to fix

    Function simp_cc_conds has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    def simp_cc_conds(_, expr):
        """
        High level simplifications. Example:
        CC_U<(FLAG_SUB_CF(A, B) => A <u B
        """
    Severity: Minor
    Found in miasm/expression/simplifications_common.py - About 6 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 pack has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        def pack(self):
            out = b''
            for field in self._fields:
                cpt = None
                if len(field) == 2:
    Severity: Minor
    Found in miasm/loader/new_cstruct.py - About 6 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

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

        def find(self, pattern, start=0, end=None):
            if start != 0:
                start = self.parent.virt2rva(start)
            if end != None:
                end = self.parent.virt2rva(end)
    Severity: Major
    Found in miasm/loader/pe_init.py and 1 other location - About 6 hrs to fix
    miasm/loader/pe_init.py on lines 146..155

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

    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 rfind(self, pattern, start=0, end=None):
            if start != 0:
                start = self.parent.virt2rva(start)
            if end != None:
                end = self.parent.virt2rva(end)
    Severity: Major
    Found in miasm/loader/pe_init.py and 1 other location - About 6 hrs to fix
    miasm/loader/pe_init.py on lines 135..144

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

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

    def kernel32_GetStringTypeW(jitter):
        """
            BOOL GetStringTypeW(
              DWORD                         dwInfoType,
              _In_NLS_string_(cchSrc)LPCWCH lpSrcStr,
    Severity: Minor
    Found in miasm/os_dep/win_api_x86_32.py - About 5 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

    ModularIntervals has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ModularIntervals(object):
        """Intervals with a maximum size, supporting modular arithmetic"""
    
        def __init__(self, size, intervals=None):
            """Instantiate a ModularIntervals of size @size
    Severity: Minor
    Found in miasm/analysis/modularintervals.py - About 5 hrs to fix

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

          elif (expr.is_op("CC_S<=") and
                len(expr.args) == 3 and
                expr.args[0].is_op("FLAG_SIGN_SUB") and
                expr.args[2].is_op("FLAG_EQ_CMP") and
                expr.args[0].args == expr.args[2].args and
      Severity: Major
      Found in miasm/expression/simplifications_common.py and 1 other location - About 5 hrs to fix
      miasm/expression/simplifications_common.py on lines 836..841

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

      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 locationdb.py has 409 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import warnings
      from builtins import int as int_types
      
      from functools import reduce
      from future.utils import viewitems, viewvalues
      Severity: Minor
      Found in miasm/core/locationdb.py - About 5 hrs to fix

        Function runiter_once has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

            def runiter_once(self, pc):
                """Iterator on callbacks results on code running from PC.
                Check exceptions before breakpoints."""
        
                self.pc = pc
        Severity: Minor
        Found in miasm/jitter/jitload.py - About 5 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

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

        def fsubp(_, instr, dst, src=None):
            dst, src = float_implicit_st0(dst, src)
            e = []
            src = mem2double(instr, src)
            e.append(m2_expr.ExprAssign(float_prev(dst), m2_expr.ExprOp('fsub', dst, src)))
        Severity: Major
        Found in miasm/arch/x86/sem.py and 5 other locations - About 5 hrs to fix
        miasm/arch/x86/sem.py on lines 2607..2614
        miasm/arch/x86/sem.py on lines 2766..2773
        miasm/arch/x86/sem.py on lines 2812..2819
        miasm/arch/x86/sem.py on lines 2840..2848
        miasm/arch/x86/sem.py on lines 2851..2859

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

        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

        @sbuild.parse
        def madd(rn, rm):
            """MADD - Signed 32-bit multiplication, adding results to HI & LO registers"""
        
            # HI||LO <- HI||LO + Rn*Rm (Signed)
        Severity: Major
        Found in miasm/arch/mep/sem.py and 1 other location - About 5 hrs to fix
        miasm/arch/mep/sem.py on lines 913..920

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

        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

        def fdivrp(_, instr, dst, src=None):
            dst, src = float_implicit_st0(dst, src)
            e = []
            src = mem2double(instr, src)
            e.append(m2_expr.ExprAssign(float_prev(dst), m2_expr.ExprOp('fdiv', src, dst)))
        Severity: Major
        Found in miasm/arch/x86/sem.py and 5 other locations - About 5 hrs to fix
        miasm/arch/x86/sem.py on lines 2607..2614
        miasm/arch/x86/sem.py on lines 2747..2754
        miasm/arch/x86/sem.py on lines 2766..2773
        miasm/arch/x86/sem.py on lines 2840..2848
        miasm/arch/x86/sem.py on lines 2851..2859

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

        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

        def fdivp(_, instr, dst, src=None):
            # Invalid emulation
            dst, src = float_implicit_st0(dst, src)
            e = []
            src = mem2double(instr, src)
        Severity: Major
        Found in miasm/arch/x86/sem.py and 5 other locations - About 5 hrs to fix
        miasm/arch/x86/sem.py on lines 2607..2614
        miasm/arch/x86/sem.py on lines 2747..2754
        miasm/arch/x86/sem.py on lines 2766..2773
        miasm/arch/x86/sem.py on lines 2812..2819
        miasm/arch/x86/sem.py on lines 2851..2859

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

        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

        def fmulp(_, instr, dst, src=None):
            # Invalid emulation
            dst, src = float_implicit_st0(dst, src)
            e = []
            src = mem2double(instr, src)
        Severity: Major
        Found in miasm/arch/x86/sem.py and 5 other locations - About 5 hrs to fix
        miasm/arch/x86/sem.py on lines 2607..2614
        miasm/arch/x86/sem.py on lines 2747..2754
        miasm/arch/x86/sem.py on lines 2766..2773
        miasm/arch/x86/sem.py on lines 2812..2819
        miasm/arch/x86/sem.py on lines 2840..2848

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

        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

        def fsubrp(_, instr, dst, src=None):
            dst, src = float_implicit_st0(dst, src)
            e = []
            src = mem2double(instr, src)
            e.append(m2_expr.ExprAssign(float_prev(dst), m2_expr.ExprOp('fsub', src, dst)))
        Severity: Major
        Found in miasm/arch/x86/sem.py and 5 other locations - About 5 hrs to fix
        miasm/arch/x86/sem.py on lines 2607..2614
        miasm/arch/x86/sem.py on lines 2747..2754
        miasm/arch/x86/sem.py on lines 2812..2819
        miasm/arch/x86/sem.py on lines 2840..2848
        miasm/arch/x86/sem.py on lines 2851..2859

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

        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

        def faddp(_, instr, dst, src=None):
            dst, src = float_implicit_st0(dst, src)
            e = []
            src = mem2double(instr, src)
            e.append(m2_expr.ExprAssign(float_prev(dst), m2_expr.ExprOp('fadd', dst, src)))
        Severity: Major
        Found in miasm/arch/x86/sem.py and 5 other locations - About 5 hrs to fix
        miasm/arch/x86/sem.py on lines 2747..2754
        miasm/arch/x86/sem.py on lines 2766..2773
        miasm/arch/x86/sem.py on lines 2812..2819
        miasm/arch/x86/sem.py on lines 2840..2848
        miasm/arch/x86/sem.py on lines 2851..2859

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

        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

        @sbuild.parse
        def maddu(rn, rm):
            """MADDU - Unsigned 32-bit multiplication, adding results to HI & LO registers"""
        
            # HI||LO <- HI||LO + Rn*Rm (Unsigned)
        Severity: Major
        Found in miasm/arch/mep/sem.py and 1 other location - About 5 hrs to fix
        miasm/arch/mep/sem.py on lines 903..910

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

        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 movmskps(ir, instr, dst, src):
            out = []
            for i in range(4):
                out.append(src[(32 * i) + 31:(32 * i) + 32])
            return [m2_expr.ExprAssign(dst, m2_expr.ExprCompose(*out).zeroExtend(dst.size))], []
        Severity: Major
        Found in miasm/arch/x86/sem.py and 1 other location - About 5 hrs to fix
        miasm/arch/x86/sem.py on lines 5100..5104

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

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

        def cvtps2pd(_, instr, dst, src):
            e = []
            e.append(
                m2_expr.ExprAssign(dst[:64], m2_expr.ExprOp('fpconvert_fp64', src[:32])))
            e.append(
        Severity: Major
        Found in miasm/arch/x86/sem.py and 3 other locations - About 5 hrs to fix
        miasm/arch/x86/sem.py on lines 4158..4164
        miasm/arch/x86/sem.py on lines 4199..4205
        miasm/arch/x86/sem.py on lines 4230..4236

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

        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

        Severity
        Category
        Status
        Source
        Language