cea-sec/miasm

View on GitHub

Showing 3,020 of 3,020 total issues

File simplifications_common.py has 1535 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# ----------------------------- #
# Common simplifications passes #
# ----------------------------- #

from future.utils import viewitems
Severity: Major
Found in miasm/expression/simplifications_common.py - About 4 days to fix

    File pe.py has 1470 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #! /usr/bin/env python
    
    from __future__ import print_function
    from builtins import range, str
    from collections import defaultdict
    Severity: Major
    Found in miasm/loader/pe.py - About 3 days to fix

      File llvmconvert.py has 1463 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #
      #
      # Miasm2 Extension:                                                            #
      # - Miasm2 IR to LLVM IR                                                       #
      # - JiT                                                                        #
      Severity: Major
      Found in miasm/jitter/llvmconvert.py - About 3 days to fix

        File objc.py has 1424 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        C helper for Miasm:
        * raw C to Miasm expression
        * Miasm expression to raw C
        * Miasm expression to C type
        Severity: Major
        Found in miasm/core/objc.py - About 3 days to fix

          File cpu.py has 1364 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          #-*- coding:utf-8 -*-
          
          from builtins import range
          import re
          import struct
          Severity: Major
          Found in miasm/core/cpu.py - About 3 days to fix

            File elf.py has 1349 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #! /usr/bin/env python
            
            from miasm.loader.cstruct import CStruct
            
            class Ehdr(CStruct):
            Severity: Major
            Found in miasm/loader/elf.py - About 3 days to fix

              Function add_ir has a Cognitive Complexity of 164 (exceeds 5 allowed). Consider refactoring.
              Open

                  def add_ir(self, expr):
                      "Add a Miasm2 IR to the last bbl. Return the var created"
              
                      if self.main_stream is True and expr in self.expr_cache:
                          return self.expr_cache[expr]
              Severity: Minor
              Found in miasm/jitter/llvmconvert.py - About 3 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

              File types.py has 1269 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """This module provides classes to manipulate pure C types as well as their
              representation in memory. A typical usecase is to use this module to
              easily manipylate structures backed by a VmMngr object (a miasm sandbox virtual
              memory):
              
              
              Severity: Major
              Found in miasm/core/types.py - About 3 days to fix

                File asmblock.py has 1109 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                #-*- coding:utf-8 -*-
                
                from builtins import map
                from builtins import range
                import logging
                Severity: Major
                Found in miasm/core/asmblock.py - About 2 days to fix

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

                  # Toshiba MeP-c4 - miasm architecture definition
                  # Guillaume Valadon <guillaume@valadon.net>
                  
                  from builtins import range
                  from miasm.core.cpu import *
                  Severity: Major
                  Found in miasm/arch/mep/arch.py - About 2 days to fix

                    Function parse_txt has a Cognitive Complexity of 122 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def parse_txt(mnemo, attrib, txt, loc_db):
                        """Parse an assembly listing. Returns an AsmCfg instance
                    
                        @mnemo: architecture used
                        @attrib: architecture attribute
                    Severity: Minor
                    Found in miasm/core/parse_asm.py - About 2 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

                            if self.options.mimic_env:
                                env_ptrs = []
                                for env in self.envp:
                                    env = force_bytes(env)
                                    env += b"\x00"
                    Severity: Major
                    Found in miasm/analysis/sandbox.py and 1 other location - About 2 days to fix
                    miasm/analysis/sandbox.py on lines 906..930

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

                    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 self.options.mimic_env:
                                env_ptrs = []
                                for env in self.envp:
                                    env = force_bytes(env)
                                    env += b"\x00"
                    Severity: Major
                    Found in miasm/analysis/sandbox.py and 1 other location - About 2 days to fix
                    miasm/analysis/sandbox.py on lines 819..843

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

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

                    from __future__ import print_function
                    from builtins import range
                    import logging
                    try:
                        from collections.abc import MutableMapping
                    Severity: Major
                    Found in miasm/ir/symbexec.py - About 2 days to fix

                      Function from_ExprOp has a Cognitive Complexity of 106 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def from_ExprOp(self, expr):
                              if len(expr.args) == 1:
                                  if expr.op == 'parity':
                                      arg = expr.args[0]
                                      out = self.from_expr(arg)
                      Severity: Minor
                      Found in miasm/ir/translators/C.py - About 2 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

                      File graph.py has 864 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      from collections import defaultdict, namedtuple
                      
                      from future.utils import viewitems, viewvalues
                      import re
                      
                      
                      Severity: Major
                      Found in miasm/core/graph.py - About 2 days to fix

                        Identical blocks of code found in 4 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/arm/arch.py and 3 other locations - About 2 days to fix
                        miasm/arch/aarch64/arch.py on lines 520..542
                        miasm/arch/arm/arch.py on lines 793..815
                        miasm/arch/ppc/arch.py on lines 245..267

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

                        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 4 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/arm/arch.py and 3 other locations - About 2 days to fix
                        miasm/arch/aarch64/arch.py on lines 520..542
                        miasm/arch/arm/arch.py on lines 692..714
                        miasm/arch/ppc/arch.py on lines 245..267

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

                        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 4 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/ppc/arch.py and 3 other locations - About 2 days to fix
                        miasm/arch/aarch64/arch.py on lines 520..542
                        miasm/arch/arm/arch.py on lines 692..714
                        miasm/arch/arm/arch.py on lines 793..815

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

                        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 4 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/aarch64/arch.py and 3 other locations - About 2 days to fix
                        miasm/arch/arm/arch.py on lines 692..714
                        miasm/arch/arm/arch.py on lines 793..815
                        miasm/arch/ppc/arch.py on lines 245..267

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

                        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