cea-sec/miasm

View on GitHub

Showing 1,373 of 3,020 total issues

Avoid deeply nested control flow statements.
Open

                        if p in parsers[(i, start_i)]:
                            continue
                        try:
Severity: Major
Found in miasm/core/cpu.py - About 45 mins to fix

    Function add_block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_block(self, block):
            """
            Add the block @block to the current instance, if it is not already in
            @block: AsmBlock instance
    
    
    Severity: Minor
    Found in miasm/core/asmblock.py - About 45 mins 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 divert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def divert(self, i, candidates):
            out = []
            for cls, _, bases, dct, fields in candidates:
                tab = self.args['mn_mod']
                if isinstance(tab, list):
    Severity: Minor
    Found in miasm/core/cpu.py - About 45 mins 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

    Avoid deeply nested control flow statements.
    Open

                            if start != 0:
                                v, start, stop = [None], None, None
                            if v != [None]:
    Severity: Major
    Found in miasm/core/cpu.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if v is None:
                                  v, start, stop = [None], None, None
                              parsers[(i, start_i)][p] = v, start, stop
      Severity: Major
      Found in miasm/core/cpu.py - About 45 mins to fix

        Function cmp_interval has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def cmp_interval(inter1, inter2):
            """Compare @inter1 and @inter2 and returns the associated INT_* case
            @inter1, @inter2: interval instance
            """
            if inter1 == inter2:
        Severity: Minor
        Found in miasm/core/interval.py - About 45 mins 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

        Avoid deeply nested control flow statements.
        Open

                            for dst in line.getdstflow(loc_db):
                                if not isinstance(dst, ExprId):
                                    continue
                                if dst in mnemo.regs.all_regs_ids:
                                    continue
        Severity: Major
        Found in miasm/core/parse_asm.py - About 45 mins to fix

          Function ast_to_typeid_struct has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def ast_to_typeid_struct(self, ast):
                  """Return the CTypeBase of an Struct ast"""
                  name = self.gen_uniq_name() if ast.name is None else ast.name
                  args = []
                  if ast.decls:
          Severity: Minor
          Found in miasm/core/ctypesmngr.py - About 45 mins 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

          Avoid deeply nested control flow statements.
          Open

                                  if not exp_dname in self.name2off:
                                      self.created_redirected_imports.setdefault(
                                          exp_dname, set()).add(name)
          
                                  # Ensure import entry is created
          Severity: Major
          Found in miasm/jitter/loader/pe.py - About 45 mins to fix

            Function to_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def to_string(self):
                    out = []
                    out.append(self.loc_db.pretty_str(self.loc_key))
            
                    for instr in self.lines:
            Severity: Minor
            Found in miasm/core/asmblock.py - About 45 mins 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 sanity_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def sanity_check(self):
                    """Do sanity checks on blocks' constraints:
                    * no pendings
                    * no multiple next constraint to same block
                    * no next constraint to self
            Severity: Minor
            Found in miasm/core/asmblock.py - About 45 mins 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, name, abi, type_ret, args, void_p_align, void_p_size):
            Severity: Minor
            Found in miasm/core/objc.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if self.enforce_strict_access and target.size != node.expr.size // 8:
                                          continue
                                      found.add(CGenDeref(finalcgenobj))
              Severity: Major
              Found in miasm/core/objc.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        for tmp_func, tmp_addr in ads:
                                            if tmp_func == exp_fname:
                                                found = tmp_addr
                                        assert found is not None
                Severity: Major
                Found in miasm/jitter/loader/pe.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          while index[current.node] <= len(stack):
                                              popped = stack.pop()
                                              index[popped] = counter
                                              scc.add(popped)
                  
                  
                  Severity: Major
                  Found in miasm/core/graph.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            while index[current.node] < boundaries[-1]:
                                                boundaries.pop()
                    
                                    # merge strongly connected component
                                    else:
                    Severity: Major
                    Found in miasm/core/graph.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if runner not in frontier:
                                                  frontier[runner] = set()
                      
                      
                      Severity: Major
                      Found in miasm/core/graph.py - About 45 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if isinstance(expr, ExprId) or isinstance(expr, ExprInt) or isinstance(expr, ExprLoc):
                                    return color_expr_html(expr, loc_db)
                        
                                elif isinstance(expr, ExprMem) and (isinstance(expr.ptr, ExprId) or isinstance(expr.ptr, ExprInt)):
                                    return "(%s)" % color_expr_html(expr.ptr, loc_db)
                        Severity: Major
                        Found in miasm/arch/mep/arch.py - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  if expr.is_id() or expr.is_int():
                                      o = str(expr)
                                  elif expr.is_loc():
                                      if loc_db is not None:
                                          o = loc_db.pretty_str(expr.loc_key)
                          Severity: Major
                          Found in miasm/arch/x86/arch.py - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                            if 'mod' in dct and dct['mod'] == 0b00 and \
                                                    'rm' in dct and dct['rm'] == 0b110:
                                                nfields[i] = bs(
                                                    l=16, cls=(x86_16_ne,), fname=self.args['fname'])
                                                ndct[self.args['fname']] = True
                            Severity: Major
                            Found in miasm/arch/x86/arch.py - About 40 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language