cea-sec/miasm

View on GitHub

Showing 1,373 of 3,017 total issues

Function kernel32_GetStringTypeW has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

def kernel32_GetStringTypeW(jitter):
    """
        BOOL GetStringTypeW(
          DWORD                         dwInfoType,
          _In_NLS_string_(cchSrc)LPCWCH lpSrcStr,
Severity: Minor
Found in miasm/os_dep/win_api_x86_32.py - About 5 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

ModularIntervals has 43 functions (exceeds 20 allowed). Consider refactoring.
Open

class ModularIntervals(object):
    """Intervals with a maximum size, supporting modular arithmetic"""

    def __init__(self, size, intervals=None):
        """Instantiate a ModularIntervals of size @size
Severity: Minor
Found in miasm/analysis/modularintervals.py - About 5 hrs to fix

    File locationdb.py has 409 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import warnings
    from builtins import int as int_types
    
    from functools import reduce
    from future.utils import viewitems, viewvalues
    Severity: Minor
    Found in miasm/core/locationdb.py - About 5 hrs to fix

      Function runiter_once has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          def runiter_once(self, pc):
              """Iterator on callbacks results on code running from PC.
              Check exceptions before breakpoints."""
      
              self.pc = pc
      Severity: Minor
      Found in miasm/jitter/jitload.py - About 5 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 arg2str has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def arg2str(expr, index=None, loc_db=None):
              wb = False
              if expr.is_id() or expr.is_int():
                  return str(expr)
              elif expr.is_loc():
      Severity: Minor
      Found in miasm/arch/arm/arch.py - About 5 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 get_funcrva has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_funcrva(self, dllname, funcname):
              dllname = force_bytes(dllname)
              funcname = force_bytes(funcname)
      
              rva_size = self.parent_head._wsize // 8
      Severity: Minor
      Found in miasm/loader/pe.py - About 5 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 get_funcrva has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_funcrva(self, func):
              for entry in self.delaydesc:
                  isfromva = (entry.attrs & 1) == 0
                  if isfromva:
                      isfromva = lambda x: self.parent_head.virt2rva(x)
      Severity: Minor
      Found in miasm/loader/pe.py - About 5 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 gen_irblock has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def gen_irblock(self, instr_attrib, attributes, instr_offsets, irblock):
              """
              Generate the code for an @irblock
              @instr_attrib: an Attributes instance or the instruction to translate
              @attributes: list of Attributes corresponding to irblock assignments
      Severity: Minor
      Found in miasm/jitter/llvmconvert.py - About 5 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 add_export_lib has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_export_lib(self, e, name):
              if name in self.created_redirected_imports:
                  log.error("%r has previously been created due to redirect\
                  imports due to %r. Change the loading order.",
                            name, self.created_redirected_imports[name])
      Severity: Minor
      Found in miasm/jitter/loader/pe.py - About 5 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 gen_c_assignments has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def gen_c_assignments(self, assignblk):
              """
              Return C information used to generate the C code of the @assignblk
              @assignblk: an AssignBlock instance
              """
      Severity: Minor
      Found in miasm/jitter/codegen.py - About 5 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 cgen_access has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def cgen_access(self, cgenobj, base_type, offset, deref, lvl=0):
              """Return the access(es) which lead to the element at @offset of an
              object of type @base_type
      
              In case of no @deref, stops recursion as soon as we reached the base of
      Severity: Minor
      Found in miasm/core/objc.py - About 5 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 reduce_mem has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def reduce_mem(self, node, lvl=0, **kwargs):
              """Generate access for ExprMem:
              * @NN[ptr<elem>] -> elem  (type)
              * @64[ptr<ptr<elem>>] -> ptr<elem>
              * @32[ptr<struct>] -> struct.00
      Severity: Minor
      Found in miasm/core/objc.py - About 5 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

      CAstTypes has 41 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class CAstTypes(object):
          """Store all defined C types and typedefs"""
          INTERNAL_PREFIX = "__GENTYPE__"
          ANONYMOUS_PREFIX = "__ANONYMOUS__"
      
      
      Severity: Minor
      Found in miasm/core/ctypesmngr.py - About 5 hrs to fix

        Function intra_block_flow_raw has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        def intra_block_flow_raw(lifter, ircfg, flow_graph, irb, in_nodes, out_nodes):
            """
            Create data flow for an irbloc using raw IR expressions
            """
            current_nodes = {}
        Severity: Minor
        Found in miasm/analysis/data_analysis.py - About 5 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 del_dummy_phi has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

            def del_dummy_phi(self, ssa, head):
                ids_to_src = {}
                def_to_loc = {}
                for block in viewvalues(ssa.graph.blocks):
                    for index, assignblock in enumerate(block):
        Severity: Minor
        Found in miasm/analysis/data_flow.py - About 5 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 compute_strongly_connected_components has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

            def compute_strongly_connected_components(self):
                """
                Partitions the graph into strongly connected components.
        
                Iterative implementation of Gabow's path-based SCC algorithm.
        Severity: Minor
        Found in miasm/core/graph.py - About 5 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 from_ExprOp has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

            def from_ExprOp(self, expr):
                args = list(map(self.from_expr, expr.args))
                res = args[0]
        
                if len(args) > 1:
        Severity: Minor
        Found in miasm/ir/translators/smt2.py - About 5 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_add_multiple has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

        def simp_add_multiple(_, expr):
            """
            X + X => 2 * X
            X + X * int1 => X * (1 + int1)
            X * int1 + (- X) => X * (int1 - 1)
        Severity: Minor
        Found in miasm/expression/simplifications_common.py - About 5 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 setup.py has 382 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #! /usr/bin/env python2
        
        from __future__ import print_function
        # Reference: https://stackoverflow.com/a/13468644/1806760
        from setuptools import setup, Extension
        Severity: Minor
        Found in setup.py - About 5 hrs to fix

          Function resolve_path has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

              def resolve_path(self, path, follow_link=True):
                  """Resolve @path to the corresponding sandboxed path"""
          
                  # path_bytes is used for Python 2 / Python 3 compatibility
                  path_bytes = not isinstance(path, str)
          Severity: Minor
          Found in miasm/os_dep/linux/environment.py - About 5 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