cea-sec/miasm

View on GitHub

Showing 1,373 of 3,017 total issues

Function build_all has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

def build_all():
    packages=[
        "miasm",
        "miasm/arch",
        "miasm/arch/x86",
Severity: Minor
Found in setup.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 build_graph has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

def build_graph(start_addr, type_graph, simplify=False, use_ida_stack=True, dontmodstack=False, loadint=False, verbose=False):
    machine = guess_machine(addr=start_addr)
    dis_engine, lifter_model_call = machine.dis_engine, machine.lifter_model_call

    class IRADelModCallStack(lifter_model_call):
Severity: Minor
Found in example/ida/graph_ir.py - About 7 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function simp_slice has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

def simp_slice(e_s, expr):
    "Slice optimization"

    # slice(A, 0, a.size) => A
    if expr.start == 0 and expr.stop == expr.arg.size:
Severity: Minor
Found in miasm/expression/simplifications_common.py - About 7 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File win_api_x86_32_seh.py has 496 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

#
# Copyright (C) 2011 EADS France, Fabrice Desclaux <fabrice.desclaux@eads.net>
#
Severity: Minor
Found in miasm/os_dep/win_api_x86_32_seh.py - About 7 hrs to fix

    Function __init__ has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, machine_name):
    
            dis_engine = None
            mn = None
            lifter_model_call = None
    Severity: Minor
    Found in miasm/analysis/machine.py - About 7 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Expr has 54 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Expr(object):
    
        "Parent class for Miasm Expressions"
    
        __slots__ = ["_hash", "_repr", "_size"]
    Severity: Major
    Found in miasm/expression/expression.py - About 7 hrs to fix

      Function handle has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle(self, cur_addr):
              cur_addr = canonize_to_exprloc(self.lifter.loc_db, cur_addr)
              symb_pc = self.eval_expr(self.lifter.IRDst)
              possibilities = possible_values(symb_pc)
              cur_path_constraint = set() # path_constraint for the concrete path
      Severity: Minor
      Found in miasm/analysis/dse.py - About 7 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      File C.py has 467 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from miasm.ir.translators.translator import Translator
      from miasm.core.utils import size2mask
      from miasm.expression.expression import ExprInt, ExprCond, ExprCompose, \
          TOK_EQUAL, \
          TOK_INF_SIGNED, TOK_INF_UNSIGNED, \
      Severity: Minor
      Found in miasm/ir/translators/C.py - About 7 hrs to fix

        File jitload.py has 456 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import logging
        import warnings
        from functools import wraps
        from collections import namedtuple
        try:
        Severity: Minor
        Found in miasm/jitter/jitload.py - About 6 hrs to fix

          Function parse_content has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_content(self,
                                parse_resources=True,
                                parse_delay=True,
                                parse_reloc=True):
                  off = 0
          Severity: Minor
          Found in miasm/loader/pe_init.py - About 6 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          File minidump.py has 454 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """Constants and structures associated to Minidump format
          Based on: http://amnesia.gtisc.gatech.edu/~moyix/minidump.py
          """
          from future.utils import viewitems
          
          
          Severity: Minor
          Found in miasm/loader/minidump.py - About 6 hrs to fix

            File expression_helper.py has 448 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: Minor
            Found in miasm/expression/expression_helper.py - About 6 hrs to fix

              Function gen_cand has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
              Open

                  def gen_cand(self, v_cand, admode):
                      if not admode in modrm2byte:
                          # XXX TODO: 64bit
                          return
                      if not v_cand:
              Severity: Minor
              Found in miasm/arch/x86/arch.py - About 6 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function parse_mem has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
              Open

              def parse_mem(expr, parent, w8, sx=0, xmm=0, mm=0, bnd=0):
                  dct_expr = {}
                  opmode = parent.v_opmode()
                  if is_mem_segm(expr) and expr.ptr.args[0].is_int():
                      return None, None, False
              Severity: Minor
              Found in miasm/arch/x86/arch.py - About 6 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function unpack_l has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
              Open

                  def unpack_l(cls, s, off=0, parent_head=None, _sex=None, _wsize=None):
                      if _sex is None and _wsize is None:
                          # get sex and size from parent
                          if parent_head is not None:
                              _sex = parent_head._sex
              Severity: Minor
              Found in miasm/loader/new_cstruct.py - About 6 hrs to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              File modularintervals.py has 428 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """Intervals with a maximum size, supporting modular arithmetic"""
              
              from future.builtins import range
              from builtins import int as int_types
              from itertools import product
              Severity: Minor
              Found in miasm/analysis/modularintervals.py - About 6 hrs to fix

                Function load_from_int has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
                Open

                def load_from_int(ircfg, bs, is_addr_ro_variable):
                    """
                    Replace memory read based on constant with static value
                    @ircfg: IRCFG instance
                    @bs: binstream instance
                Severity: Minor
                Found in miasm/analysis/data_flow.py - About 6 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                File debugging.py has 427 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from __future__ import print_function
                from builtins import map
                from builtins import range
                import cmd
                from future.utils import viewitems
                Severity: Minor
                Found in miasm/analysis/debugging.py - About 6 hrs to fix

                  Function simp_cc_conds has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def simp_cc_conds(_, expr):
                      """
                      High level simplifications. Example:
                      CC_U<(FLAG_SUB_CF(A, B) => A <u B
                      """
                  Severity: Minor
                  Found in miasm/expression/simplifications_common.py - About 6 hrs to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function pack has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def pack(self):
                          out = b''
                          for field in self._fields:
                              cpt = None
                              if len(field) == 2:
                  Severity: Minor
                  Found in miasm/loader/new_cstruct.py - About 6 hrs to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Severity
                  Category
                  Status
                  Source
                  Language