cea-sec/miasm

View on GitHub

Showing 3,017 of 3,017 total issues

File sem.py has 4353 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#
# Copyright (C) 2011 EADS France, Fabrice Desclaux <fabrice.desclaux@eads.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Severity: Major
Found in miasm/arch/x86/sem.py - About 1 wk to fix

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

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

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

      #-*- coding:utf-8 -*-
      
      from builtins import range
      from future.utils import viewitems
      
      
      Severity: Major
      Found in miasm/arch/arm/arch.py - About 1 wk to fix

        File win_api_x86_32.py has 2634 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from __future__ import print_function
        #
        # Copyright (C) 2011 EADS France, Fabrice Desclaux <fabrice.desclaux@eads.net>
        #
        # This program is free software; you can redistribute it and/or modify
        Severity: Major
        Found in miasm/os_dep/win_api_x86_32.py - About 1 wk to fix

          File data_flow.py has 1918 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """Data flow analysis based on miasm intermediate representation"""
          from builtins import range
          from collections import namedtuple, Counter
          from pprint import pprint as pp
          from future.utils import viewitems, viewvalues
          Severity: Major
          Found in miasm/analysis/data_flow.py - About 5 days to fix

            File sem.py has 1821 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from builtins import range
            from future.utils import viewitems
            
            from miasm.expression.expression import ExprId, ExprInt, ExprLoc, ExprMem, \
                ExprCond, ExprCompose, ExprOp, ExprAssign
            Severity: Major
            Found in miasm/arch/aarch64/sem.py - About 4 days to fix

              File sem.py has 1788 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              from builtins import range
              from future.utils import viewitems, viewvalues
              
              from miasm.expression.expression import *
              from miasm.expression.simplifications import expr_simp
              Severity: Major
              Found in miasm/arch/arm/sem.py - About 4 days to fix

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

                #-*- coding:utf-8 -*-
                
                from builtins import range
                from future.utils import viewitems, viewvalues
                
                
                Severity: Major
                Found in miasm/arch/aarch64/arch.py - About 4 days to fix

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

                  def div(ir, instr, src1):
                      e = []
                      size = src1.size
                      if size == 8:
                          src2 = mRAX[instr.mode][:16]
                  Severity: Major
                  Found in miasm/arch/x86/sem.py and 1 other location - About 4 days to fix
                  miasm/arch/x86/sem.py on lines 1770..1812

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

                  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 idiv(ir, instr, src1):
                      e = []
                      size = src1.size
                  
                      if size == 8:
                  Severity: Major
                  Found in miasm/arch/x86/sem.py and 1 other location - About 4 days to fix
                  miasm/arch/x86/sem.py on lines 1724..1765

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

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

                  class CTypeX86_unk(CLeafTypes):
                      """Define C types sizes/alignment for x86_32 architecture"""
                  
                      obj_pad = ObjCDecl(PADDING_TYPE_NAME, 1, 1) # __padding__ is size 1/align 1
                  
                  
                  Severity: Major
                  Found in miasm/arch/x86/ctype.py and 2 other locations - About 4 days to fix
                  miasm/arch/msp430/ctype.py on lines 5..67
                  miasm/arch/x86/ctype.py on lines 5..67

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

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

                  class CTypeMSP430_unk(CLeafTypes):
                      """Define C types sizes/alignment for msp430 architecture"""
                  
                      obj_pad = ObjCDecl(PADDING_TYPE_NAME, 1, 1) # __padding__ is size 1/align 1
                  
                  
                  Severity: Major
                  Found in miasm/arch/msp430/ctype.py and 2 other locations - About 4 days to fix
                  miasm/arch/x86/ctype.py on lines 5..67
                  miasm/arch/x86/ctype.py on lines 74..136

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

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

                  class CTypeAMD64_unk(CLeafTypes):
                      """Define C types sizes/alignment for x86_64 architecture"""
                  
                      obj_pad = ObjCDecl(PADDING_TYPE_NAME, 1, 1) # __padding__ is size 1/align 1
                  
                  
                  Severity: Major
                  Found in miasm/arch/x86/ctype.py and 2 other locations - About 4 days to fix
                  miasm/arch/msp430/ctype.py on lines 5..67
                  miasm/arch/x86/ctype.py on lines 74..136

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

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

                  #
                  # Copyright (C) 2011 EADS France, Fabrice Desclaux <fabrice.desclaux@eads.net>
                  #
                  # This program is free software; you can redistribute it and/or modify
                  # it under the terms of the GNU General Public License as published by
                  Severity: Major
                  Found in miasm/expression/expression.py - About 4 days to fix

                    Function simp_cst_propagation has a Cognitive Complexity of 210 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def simp_cst_propagation(e_s, expr):
                        """This passe includes:
                         - Constant folding
                         - Common logical identities
                         - Common binary identities
                    Severity: Minor
                    Found in miasm/expression/simplifications_common.py - About 4 days 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

                    class Sandbox_Linux_arml(Sandbox, Arch_arml, OS_Linux):
                    
                        def __init__(self, loc_db, *args, **kwargs):
                            Sandbox.__init__(self, loc_db, *args, **kwargs)
                    
                    
                    Severity: Major
                    Found in miasm/analysis/sandbox.py and 1 other location - About 4 days to fix
                    miasm/analysis/sandbox.py on lines 754..809

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

                    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 Sandbox_Linux_armtl(Sandbox, Arch_armtl, OS_Linux):
                    
                        def __init__(self, loc_db, *args, **kwargs):
                            Sandbox.__init__(self, loc_db, *args, **kwargs)
                    
                    
                    Severity: Major
                    Found in miasm/analysis/sandbox.py and 1 other location - About 4 days to fix
                    miasm/analysis/sandbox.py on lines 696..751

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

                    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 Sandbox_Linux_x86_64(Sandbox, Arch_x86_64, OS_Linux):
                    
                        def __init__(self, loc_db, *args, **kwargs):
                            Sandbox.__init__(self, loc_db, *args, **kwargs)
                    
                    
                    Severity: Major
                    Found in miasm/analysis/sandbox.py and 1 other location - About 4 days to fix
                    miasm/analysis/sandbox.py on lines 577..633

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

                    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 Sandbox_Linux_x86_32(Sandbox, Arch_x86_32, OS_Linux):
                    
                        def __init__(self, loc_db, *args, **kwargs):
                            Sandbox.__init__(self, loc_db, *args, **kwargs)
                    
                    
                    Severity: Major
                    Found in miasm/analysis/sandbox.py and 1 other location - About 4 days to fix
                    miasm/analysis/sandbox.py on lines 637..693

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

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

                    def gen_modrm_form():
                        global db_afs_64, sib_64_s08_ebp
                        ebp = 5
                    
                        sib_s08_ebp = [{f_isad: True} for i in range(0x100)]
                    Severity: Minor
                    Found in miasm/arch/x86/arch.py - About 4 days 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