cea-sec/miasm

View on GitHub
miasm/analysis/debugging.py

Summary

Maintainability
D
3 days
Test Coverage

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

    DebugCmd has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DebugCmd(cmd.Cmd, object):
    
        "CommandLineInterpreter for Debugguer instance"
    
        color_g = '\033[92m'
    Severity: Minor
    Found in miasm/analysis/debugging.py - About 4 hrs to fix

      Function handle_exception has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_exception(self, res):
              if not res:
                  # A breakpoint has stopped the execution
                  return DebugBreakpointTerminate(res)
      
      
      Severity: Minor
      Found in miasm/analysis/debugging.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

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

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

        Function do_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def do_info(self, arg):
                av_info = [
                    "registers",
                    "display",
                    "breakpoints",
        Severity: Minor
        Found in miasm/analysis/debugging.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_breakpoints has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def add_breakpoints(self, bp_addr):
                for addr in bp_addr:
                    addr = int(addr, 0)
        
                    good = True
        Severity: Minor
        Found in miasm/analysis/debugging.py - About 55 mins 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_access_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_access_type(cls, read=False, write=False):
                value = 0
                for k, v in viewitems(cls.type2str):
                    if v == "R" and read is True:
                        value += k
        Severity: Minor
        Found in miasm/analysis/debugging.py - About 25 mins 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

                        if len(memory_write) > 0:
                            print("Write:")
                            for start_address, end_address in memory_write:
                                print("- from 0x%08x to 0x%08x" % (start_address, end_address))
        Severity: Major
        Found in miasm/analysis/debugging.py and 1 other location - About 1 hr to fix
        miasm/analysis/debugging.py on lines 169..172

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

        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 len(memory_read) > 0:
                            print("Read:")
                            for start_address, end_address in memory_read:
                                print("- from 0x%08x to 0x%08x" % (start_address, end_address))
        Severity: Major
        Found in miasm/analysis/debugging.py and 1 other location - About 1 hr to fix
        miasm/analysis/debugging.py on lines 174..177

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

        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

        class DebugBreakpointSoft(DebugBreakpoint):
        
            "Stand for software breakpoint"
        
            def __init__(self, addr):
        Severity: Major
        Found in miasm/analysis/debugging.py and 3 other locations - About 1 hr to fix
        miasm/analysis/debugging.py on lines 30..37
        miasm/core/asm_ast.py on lines 45..53
        miasm/core/asm_ast.py on lines 56..64

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

        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

        class DebugBreakpointTerminate(DebugBreakpoint):
            "Stand for an execution termination"
        
            def __init__(self, status):
                self.status = status
        Severity: Major
        Found in miasm/analysis/debugging.py and 3 other locations - About 1 hr to fix
        miasm/analysis/debugging.py on lines 19..27
        miasm/core/asm_ast.py on lines 45..53
        miasm/core/asm_ast.py on lines 56..64

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

        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 len(args) >= 2:
                    size = int(args[1], 0)
                else:
                    size = 0xF
        Severity: Minor
        Found in miasm/analysis/debugging.py and 1 other location - About 50 mins to fix
        miasm/analysis/debugging.py on lines 515..518

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

        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 len(args) >= 2:
                        size = int(args[1], 0)
                    else:
                        size = 0xF
        Severity: Minor
        Found in miasm/analysis/debugging.py and 1 other location - About 50 mins to fix
        miasm/analysis/debugging.py on lines 403..406

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

        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

        There are no issues that match your filters.

        Category
        Status