cea-sec/miasm

View on GitHub

Showing 3,020 of 3,020 total issues

File ir.py has 843 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#-*- coding:utf-8 -*-

#
# Copyright (C) 2013 Fabrice Desclaux
#
Severity: Major
Found in miasm/ir/ir.py - About 2 days to fix

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

        @classmethod
        def getbits(cls, bs, attrib, start, n):
            if not n:
                return 0
            o = 0
    Severity: Major
    Found in miasm/arch/msp430/arch.py and 1 other location - About 1 day to fix
    miasm/arch/sh4/arch.py on lines 509..530

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

    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

        @classmethod
        def getbits(cls, bs, attrib, start, n):
            if not n:
                return 0
            o = 0
    Severity: Major
    Found in miasm/arch/sh4/arch.py and 1 other location - About 1 day to fix
    miasm/arch/msp430/arch.py on lines 258..279

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

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

        def eval_assignblock(self, assignblock):
            """
            Evaluate the @assignblock on the current state
            @assignblock: AssignBlock instance
            """
    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

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

    def comisd(_, instr, dst, src):
        # TODO unordered float
    
        e = []
    
    
    Severity: Major
    Found in miasm/arch/x86/sem.py and 1 other location - About 1 day to fix
    miasm/arch/x86/sem.py on lines 2350..2367

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

    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 comiss(_, instr, dst, src):
        # TODO unordered float
    
        e = []
    
    
    Severity: Major
    Found in miasm/arch/x86/sem.py and 1 other location - About 1 day to fix
    miasm/arch/x86/sem.py on lines 2370..2387

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

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

    from __future__ import print_function
    from builtins import range
    
    import miasm.expression.expression as expr
    from miasm.ir.ir import AssignBlock, Lifter, IRBlock
    Severity: Major
    Found in miasm/arch/ppc/sem.py - About 1 day to fix

      File arch.py has 789 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #-*- coding:utf-8 -*-
      
      from __future__ import print_function
      from builtins import range
      
      
      Severity: Major
      Found in miasm/arch/sh4/arch.py - About 1 day to fix

        File sandbox.py has 772 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from __future__ import print_function
        from builtins import range
        
        import os
        import logging
        Severity: Major
        Found in miasm/analysis/sandbox.py - About 1 day to fix

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

          class ppc_arg(m_arg):
              def asm_ast_to_expr(self, arg, loc_db):
                  if isinstance(arg, AstId):
                      if isinstance(arg.name, ExprId):
                          return arg.name
          Severity: Major
          Found in miasm/arch/ppc/arch.py and 1 other location - About 1 day to fix
          miasm/arch/sh4/arch.py on lines 101..122

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

          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

          class sh4_arg(m_arg):
              def asm_ast_to_expr(self, arg, loc_db):
                  if isinstance(arg, AstId):
                      if isinstance(arg.name, ExprId):
                          return arg.name
          Severity: Major
          Found in miasm/arch/sh4/arch.py and 1 other location - About 1 day to fix
          miasm/arch/ppc/arch.py on lines 38..59

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

          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 ucomiss(_, instr, src1, src2):
              e = []
              e.append(m2_expr.ExprAssign(zf, m2_expr.ExprOp(
                  'ucomiss_zf', src1[:32], src2[:32])))
              e.append(m2_expr.ExprAssign(pf, m2_expr.ExprOp(
          Severity: Major
          Found in miasm/arch/x86/sem.py and 1 other location - About 1 day to fix
          miasm/arch/x86/sem.py on lines 4356..4369

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

          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

          class ProgramHeader(object):
          
              def __init__(self, parent, sex, size, phstr):
                  self.parent = parent
                  self.ph = WPhdr(self, sex, size, phstr)
          Severity: Major
          Found in miasm/loader/elf_init.py and 1 other location - About 1 day to fix
          miasm/loader/elf_init.py on lines 595..612

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

          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

          class ProgramHeader64(object):
          
              def __init__(self, parent, sex, size, phstr):
                  self.parent = parent
                  self.ph = WPhdr64(self, sex, size, phstr)
          Severity: Major
          Found in miasm/loader/elf_init.py and 1 other location - About 1 day to fix
          miasm/loader/elf_init.py on lines 575..592

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

          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 ucomisd(_, instr, src1, src2):
              e = []
              e.append(m2_expr.ExprAssign(zf, m2_expr.ExprOp(
                  'ucomisd_zf', src1[:64], src2[:64])))
              e.append(m2_expr.ExprAssign(pf, m2_expr.ExprOp(
          Severity: Major
          Found in miasm/arch/x86/sem.py and 1 other location - About 1 day to fix
          miasm/arch/x86/sem.py on lines 4341..4354

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

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

          from __future__ import print_function
          from collections import namedtuple
          import functools
          import logging
          import os
          Severity: Major
          Found in miasm/os_dep/linux/environment.py - About 1 day to fix

            File syscall.py has 739 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from builtins import range
            import fcntl
            import functools
            import logging
            import struct
            Severity: Major
            Found in miasm/os_dep/linux/syscall.py - About 1 day to fix

              Function add_block has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
              Open

                  def add_block(self, asmblock):
                      """Create a python function corresponding to an AsmBlock
                      @asmblock: AsmBlock
                      """
              
              
              Severity: Minor
              Found in miasm/jitter/jitcore_python.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 kernel32_CreateFile has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
              Open

              def kernel32_CreateFile(jitter, funcname, get_str):
                  ret_ad, args = jitter.func_args_stdcall(["lpfilename", "access",
                                                           "dwsharedmode",
                                                           "lpsecurityattr",
                                                           "dwcreationdisposition",
              Severity: Minor
              Found in miasm/os_dep/win_api_x86_32.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 arch.py has 676 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              from builtins import range
              
              import logging
              from pyparsing import *
              from miasm.expression.expression import *
              Severity: Major
              Found in miasm/arch/ppc/arch.py - About 1 day to fix
                Severity
                Category
                Status
                Source
                Language