cea-sec/miasm

View on GitHub

Showing 1,373 of 3,020 total issues

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

      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

        Function fromstring has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
        Open

            def fromstring(cls, text, loc_db, mode = None):
                global total_scans
                name = re.search(r'(\S+)', text).groups()
                if not name:
                    raise ValueError('cannot find name', text)
        Severity: Minor
        Found in miasm/core/cpu.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 _dis_block has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
        Open

            def _dis_block(self, offset, job_done=None):
                """Disassemble the block at offset @offset
                @job_done: a set of already disassembled addresses
                Return the created AsmBlock and future offsets to disassemble
                """
        Severity: Minor
        Found in miasm/core/asmblock.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

        Consider simplifying this complex logical expression.
        Open

            if (expr.is_op("CC_U>=") and
                  test_cc_eq_args(
                      expr,
                      "FLAG_SUB_CF"
                  )):
        Severity: Critical
        Found in miasm/expression/simplifications_common.py - About 1 day to fix

          Function process_messages has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
          Open

              def process_messages(self):
          
                  while self.recv_queue:
                      msg = self.recv_queue.pop(0)
                      buf = BytesIO(msg)
          Severity: Minor
          Found in miasm/analysis/gdbserver.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 dis has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
          Open

              def dis(cls, bs_o, mode_o = None, offset=0):
                  if not isinstance(bs_o, bin_stream):
                      bs_o = bin_stream_str(bs_o)
          
                  bs_o.enter_atomic_mode()
          Severity: Minor
          Found in miasm/core/cpu.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 fill_loc_db_with_symbols has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
          Open

          def fill_loc_db_with_symbols(elf, loc_db, base_addr=0):
              """Parse the miasm.loader's ELF @elf to extract symbols, and fill the LocationDB
              instance @loc_db with parsed symbols.
          
              The ELF is considered mapped at @base_addr
          Severity: Minor
          Found in miasm/jitter/loader/elf.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 get_equivalence_class has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_equivalence_class(self, node, ids_to_src):
                  todo = set([node])
                  done = set()
                  defined = set()
                  equivalence = set()
          Severity: Minor
          Found in miasm/analysis/data_flow.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 sem.py has 535 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import miasm.expression.expression as m2_expr
          from miasm.ir.ir import Lifter, IRBlock, AssignBlock
          from miasm.arch.mips32.arch import mn_mips32
          from miasm.arch.mips32.regs import R_LO, R_HI, PC, RA, ZERO, exception_flags
          from miasm.core.sembuilder import SemBuilder
          Severity: Major
          Found in miasm/arch/mips32/sem.py - About 1 day to fix

            DiGraph has 61 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class DiGraph(object):
            
                """Implementation of directed graph"""
            
                # Stand for a cell in a dot node rendering
            Severity: Major
            Found in miasm/core/graph.py - About 1 day to fix

              File codegen.py has 529 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """
              Module to generate C code for a given native @block
              """
              
              from builtins import zip
              Severity: Major
              Found in miasm/jitter/codegen.py - About 1 day to fix

                File dse.py has 526 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                """Dynamic symbolic execution module.
                
                Offers a way to have a symbolic execution along a concrete one.
                Basically, this is done through DSEEngine class, with scheme:
                
                
                Severity: Major
                Found in miasm/analysis/dse.py - About 1 day to fix

                  File pe_init.py has 523 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  #! /usr/bin/env python
                  
                  from __future__ import print_function
                  
                  from builtins import range
                  Severity: Major
                  Found in miasm/loader/pe_init.py - About 1 day to fix

                    File depgraph.py has 518 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    """Provide dependency graph"""
                    
                    from functools import total_ordering
                    
                    from future.utils import viewitems
                    Severity: Major
                    Found in miasm/analysis/depgraph.py - About 1 day to fix

                      File ssa.py has 518 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      from collections import deque
                      from future.utils import viewitems, viewvalues
                      
                      from miasm.expression.expression import ExprId, ExprAssign, ExprOp, \
                          ExprLoc, get_expr_ids
                      Severity: Major
                      Found in miasm/analysis/ssa.py - About 1 day to fix

                        Function merge has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def merge(self, other):
                                """
                                Merge the current state with @other
                                Merge rules:
                                - if two nodes are equal in both states => in equivalence class
                        Severity: Minor
                        Found in miasm/analysis/data_flow.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 arch.py has 509 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        #-*- coding:utf-8 -*-
                        
                        from builtins import range
                        
                        import logging
                        Severity: Major
                        Found in miasm/arch/msp430/arch.py - About 1 day to fix
                          Severity
                          Category
                          Status
                          Source
                          Language