cea-sec/miasm

View on GitHub

Showing 3,020 of 3,020 total issues

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

def cvtdq2ps(_, instr, dst, src):
    e = []
    e.append(
        m2_expr.ExprAssign(dst[:32], m2_expr.ExprOp('sint_to_fp', src[:32])))
    e.append(
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 4208..4218

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

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 cvtps2dq(_, instr, dst, src):
    e = []
    e.append(
        m2_expr.ExprAssign(dst[:32], m2_expr.ExprOp('fp_to_sint32', src[:32])))
    e.append(
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 4135..4145

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

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

def match_expr(expr, pattern, tks, result=None):
    """Try to match the @pattern expression with the pattern @expr with @tks jokers.
    Result is output dictionary with matching joker values.
    @expr : Expr pattern
    @pattern : Targeted Expr to match
Severity: Minor
Found in miasm/expression/expression.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 elf_init.py has 670 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#! /usr/bin/env python

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

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

    #-*- coding:utf-8 -*-
    
    import logging
    from collections import defaultdict
    
    
    Severity: Major
    Found in miasm/arch/mips32/arch.py - About 1 day to fix

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

      Severity: Major
      Found in example/disasm/dis_binary_lift_model_call.py and 1 other location - About 1 day to fix
      example/disasm/dis_binary_lift.py on lines 0..39

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

      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

      Severity: Major
      Found in example/disasm/dis_binary_lift.py and 1 other location - About 1 day to fix
      example/disasm/dis_binary_lift_model_call.py on lines 0..42

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

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

      from builtins import map
      import os
      import struct
      import logging
      from collections import defaultdict
      Severity: Major
      Found in miasm/jitter/loader/pe.py - About 1 day to fix

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

        # Toshiba MeP-c4 - miasm instructions side effects
        # Guillaume Valadon <guillaume@valadon.net>
        
        from miasm.core.sembuilder import SemBuilder
        from miasm.ir.ir import Lifter
        Severity: Major
        Found in miasm/arch/mep/sem.py - About 1 day to fix

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

          def sys_x86_64_ioctl(jitter, linux_env):
              # Parse arguments
              fd, cmd, arg = jitter.syscall_args_systemv(3)
              log.debug("sys_ioctl(%x, %x, %x)", fd, cmd, arg)
          
          
          Severity: Major
          Found in miasm/os_dep/linux/syscall.py and 1 other location - About 1 day to fix
          miasm/os_dep/linux/syscall.py on lines 498..515

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

          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 sys_arml_ioctl(jitter, linux_env):
              # Parse arguments
              fd, cmd, arg = jitter.syscall_args_systemv(3)
              log.debug("sys_ioctl(%x, %x, %x)", fd, cmd, arg)
          
          
          Severity: Major
          Found in miasm/os_dep/linux/syscall.py and 1 other location - About 1 day to fix
          miasm/os_dep/linux/syscall.py on lines 478..495

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

          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

          Consider simplifying this complex logical expression.
          Open

              if arg2.is_int(3) and arg3.is_int(3) and arg4.is_id("c4") and arg5.is_id("c2") and arg6.is_int(0):
                  out = []
                  out.append(ExprInt(0x0, 28))
                  out.append(of)
                  out.append(cf)
          Severity: Critical
          Found in miasm/arch/aarch64/sem.py - About 1 day to fix

            Consider simplifying this complex logical expression.
            Open

                if arg1.is_int(3) and arg2.is_int(3) and arg3.is_id("c4") and arg4.is_id("c2") and arg5.is_int(0):
                    e.append(ExprAssign(nf, arg6[31:32]))
                    e.append(ExprAssign(zf, arg6[30:31]))
                    e.append(ExprAssign(cf, arg6[29:30]))
                    e.append(ExprAssign(of, arg6[28:29]))
            Severity: Critical
            Found in miasm/arch/aarch64/sem.py - About 1 day to fix

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

              class mips32_s16imm_noarg(mips32_imm):
                  def decode(self, v):
                      v = v & self.lmask
                      v = cpu.sign_ext(v, 16, 32)
                      self.expr = ExprInt(v, 32)
              Severity: Major
              Found in miasm/arch/mips32/arch.py and 1 other location - About 1 day to fix
              miasm/arch/mips32/arch.py on lines 340..356

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

              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 mips32_s09imm_noarg(mips32_imm):
                  def decode(self, v):
                      v = v & self.lmask
                      v = cpu.sign_ext(v, 9, 32)
                      self.expr = ExprInt(v, 32)
              Severity: Major
              Found in miasm/arch/mips32/arch.py and 1 other location - About 1 day to fix
              miasm/arch/mips32/arch.py on lines 321..337

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

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

              import re
              
              from pycparser import c_parser, c_ast
              
              RE_HASH_CMT = re.compile(r'^#\s*\d+.*$', flags=re.MULTILINE)
              Severity: Major
              Found in miasm/core/ctypesmngr.py - About 1 day to fix

                Function expr2modrm has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
                Open

                def expr2modrm(expr, parent, w8, sx=0, xmm=0, mm=0, bnd=0):
                    dct_expr = {f_isad : False}
                
                    if mm or xmm or bnd:
                        if mm and expr.size != 64:
                Severity: Minor
                Found in miasm/arch/x86/arch.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

                class ppc_s14imm_branch(ppc_imm):
                
                    def decode(self, v):
                        v = sign_ext(v << 2, 16, 32)
                        self.expr = ExprInt(v, 32)
                Severity: Major
                Found in miasm/arch/ppc/arch.py and 1 other location - About 1 day to fix
                miasm/arch/ppc/arch.py on lines 377..394

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

                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 ppc_s24imm_branch(ppc_imm):
                
                    def decode(self, v):
                        v = sign_ext(v << 2, 26, 32)
                        self.expr = ExprInt(v, 32)
                Severity: Major
                Found in miasm/arch/ppc/arch.py and 1 other location - About 1 day to fix
                miasm/arch/ppc/arch.py on lines 358..375

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

                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 slice_rest(self):
                        "Return the completion of the current slice"
                        size = self._arg.size
                        if self._start >= size or self._stop > size:
                            raise ValueError('bad slice rest %s %s %s' %
                Severity: Major
                Found in miasm/expression/expression.py and 1 other location - About 1 day to fix
                miasm/ir/ir.py on lines 152..168

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

                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