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
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])
- Read upRead up
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 vm_load_pe_and_dependencies
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def vm_load_pe_and_dependencies(vm, fname, name2module, runtime_lib,
lib_path_base, **kwargs):
"""Load a binary and all its dependencies. Returns a dictionary containing
the association between binaries names and it's pe object
- Read upRead up
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 vm_load_pe
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def vm_load_pe(vm, fdata, align_s=True, load_hdr=True, name="", winobjs=None, **kargs):
"""Load a PE in memory (@vm) from a data buffer @fdata
@vm: VmMngr instance
@fdata: data buffer to parse
@align_s: (optional) If False, keep gaps between section
- Read upRead up
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 vm2pe
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def vm2pe(myjit, fname, libs=None, e_orig=None,
min_addr=None, max_addr=None,
min_section_offset=0x1000, img_base=None,
added_funcs=None, **kwargs):
if e_orig:
- Read upRead up
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_new_lib
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def gen_new_lib(self, target_pe, filter_import=lambda peobj, ad: True, **kwargs):
"""Gen a new DirImport description
@target_pe: PE instance
@filter_import: (boolean f(pe, address)) restrict addresses to keep
"""
- Read upRead up
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 transition
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def transition(self, data):
if self.state == self.STATE_SEARCH:
if data in self.func_addrs:
self.state = self.STATE_FUNC_FOUND
func_addr = struct.unpack(self.ptrtype, data)[0]
- Read upRead up
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 recover_import
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def recover_import(self, update_libs=True, align_hypothesis=False):
"""
Launch the import recovery routine.
@update_libs: if set (default), update `libs` object with founded addresses
@align_hypothesis: if not set (default), do not consider import
- Read upRead up
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 vm2pe
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def vm2pe(myjit, fname, libs=None, e_orig=None,
Function vm_load_pe
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def vm_load_pe(vm, fdata, align_s=True, load_hdr=True, name="", winobjs=None, **kargs):
Function get_pe_dependencies
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_pe_dependencies(pe_obj):
"""Collect the shared libraries upon which this PE depends.
@pe_obj: pe object
Returns a set of strings of DLL names.
- Read upRead up
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_import_address_pe
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_import_address_pe(e):
"""Compute the addresses of imported symbols.
@e: pe object
Returns a dict mapping from tuple (dll name string, symbol name string) to set of virtual addresses.
- Read upRead up
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 vm_load_pe_and_dependencies
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def vm_load_pe_and_dependencies(vm, fname, name2module, runtime_lib,
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
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
Avoid deeply nested control flow statements. Open
if isinstance(exp_fname, str):
exp_fname = bytes(ord(c) for c in exp_fname)
found = None
Function vm_fix_imports_pe_libs
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def vm_fix_imports_pe_libs(lib_imgs, libs, lib_path_base,
Function vm_load_pe_lib
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def vm_load_pe_lib(vm, fname_in, libs, lib_path_base, **kargs):
Function vm_load_pe_libs
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def vm_load_pe_libs(vm, libs_name, libs, lib_path_base, **kargs):
Function preload_pe
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def preload_pe(vm, e, runtime_lib, patch_vm_imp=True):
fa = get_import_address_pe(e)
dyn_funcs = {}
# log.debug('imported funcs: %s' % fa)
for (libname, libfunc), ads in viewitems(fa):
- Read upRead up
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"