diff options
| -rw-r--r-- | .gitignore | 9 | ||||
| -rw-r--r-- | example/jitter/memory_breakpoint.py | 8 | ||||
| -rw-r--r-- | example/jitter/unpack_generic.py | 2 | ||||
| -rw-r--r-- | miasm/__init__.py | 6 | ||||
| -rw-r--r-- | miasm/analysis/debugging.py | 2 | ||||
| -rw-r--r-- | miasm/analysis/dse.py | 4 | ||||
| -rw-r--r-- | miasm/arch/aarch64/sem.py | 10 | ||||
| -rw-r--r-- | miasm/arch/x86/arch.py | 2 | ||||
| -rw-r--r-- | miasm/core/cpu.py | 6 | ||||
| -rw-r--r-- | miasm/core/graph.py | 2 | ||||
| -rw-r--r-- | miasm/core/sembuilder.py | 4 | ||||
| -rw-r--r-- | miasm/core/utils.py | 2 | ||||
| -rw-r--r-- | miasm/expression/expression.py | 4 | ||||
| -rw-r--r-- | miasm/expression/expression_helper.py | 4 | ||||
| -rw-r--r-- | miasm/expression/simplifications_common.py | 8 | ||||
| -rw-r--r-- | miasm/ir/ir.py | 2 | ||||
| -rw-r--r-- | miasm/ir/translators/z3_ir.py | 5 | ||||
| -rw-r--r-- | miasm/jitter/loader/pe.py | 18 | ||||
| -rw-r--r-- | miasm/jitter/loader/utils.py | 2 | ||||
| -rw-r--r-- | miasm/loader/minidump.py | 4 | ||||
| -rw-r--r-- | miasm/os_dep/linux/environment.py | 4 | ||||
| -rw-r--r-- | miasm/os_dep/win_api_x86_32.py | 19 | ||||
| -rw-r--r-- | requirements.txt | 2 | ||||
| -rw-r--r-- | setup.py | 2 | ||||
| -rw-r--r-- | test/analysis/depgraph.py | 4 | ||||
| -rw-r--r-- | test/arch/mep/asm/ut_helpers_asm.py | 2 |
26 files changed, 74 insertions, 63 deletions
diff --git a/.gitignore b/.gitignore index 6fc6b959..34b94382 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,18 @@ # Build directory /build/* +dist/ +sdists/ # Emacs files *~ # Compiled python files +__pycache__/ *.py[cod] # Generated files *.egg* **.dot **.so -VERSION \ No newline at end of file +VERSION +# Virtual environments +venv*/ +.env/ +.venv*/ \ No newline at end of file diff --git a/example/jitter/memory_breakpoint.py b/example/jitter/memory_breakpoint.py index 900b1621..291682a4 100644 --- a/example/jitter/memory_breakpoint.py +++ b/example/jitter/memory_breakpoint.py @@ -34,15 +34,15 @@ sb.jitter.vm.add_memory_breakpoint(address, size, access_type) def memory_breakpoint_handler(jitter): memory_read = jitter.vm.get_memory_read() if len(memory_read) > 0: - print("Read at instruction 0x%s:" % jitter.pc) + print("Read at instruction 0x%x:" % jitter.pc) for start_address, end_address in memory_read: - print("- from %s to %s" % (hex(start_address), hex(end_address))) + print("- from 0x%x to 0x%x" % (start_address, end_address)) memory_write = jitter.vm.get_memory_write() if len(memory_write) > 0: - print("Write at instruction 0x%s:" % jitter.pc) + print("Write at instruction 0x%x:" % jitter.pc) for start_address, end_address in memory_write: - print("- from %s to %s" % (hex(start_address), hex(end_address))) + print("- from 0x%x to 0x%x" % (start_address, end_address)) # Cleanup jitter.vm.set_exception(jitter.vm.get_exception() ^ EXCEPT_BREAKPOINT_MEMORY) diff --git a/example/jitter/unpack_generic.py b/example/jitter/unpack_generic.py index 3329d2a9..e389a4b5 100644 --- a/example/jitter/unpack_generic.py +++ b/example/jitter/unpack_generic.py @@ -35,7 +35,7 @@ def stop(jitter): if options.oep: # Set callbacks sb.jitter.add_breakpoint(int(options.oep, 0), stop) - + # Run until an error is encountered - IT IS UNLIKELY THE ORIGINAL ENTRY POINT try: sb.run() diff --git a/miasm/__init__.py b/miasm/__init__.py index 417a6268..309a1ae7 100644 --- a/miasm/__init__.py +++ b/miasm/__init__.py @@ -40,13 +40,13 @@ def _version_from_git_describe(): if process.returncode == 0: tag = out.decode().strip() - match = re.match('^v?(.+?)-(\\d+)-g[a-f0-9]+$', tag) + match = re.match(r'^v?(.+?)-(\d+)-g[a-f0-9]+$', tag) if match: # remove the 'v' prefix and add a '.devN' suffix return '%s.dev%s' % (match.group(1), match.group(2)) else: # just remove the 'v' prefix - return re.sub('^v', '', tag) + return re.sub(r'^v', '', tag) else: raise subprocess.CalledProcessError(process.returncode, err) @@ -71,7 +71,7 @@ def _version(): # See 'man gitattributes' for more details. git_archive_id = '$Format:%h %d$' sha1 = git_archive_id.strip().split()[0] - match = re.search('tag:(\\S+)', git_archive_id) + match = re.search(r'tag:(\S+)', git_archive_id) if match: return "git-archive.dev" + match.group(1) elif sha1: diff --git a/miasm/analysis/debugging.py b/miasm/analysis/debugging.py index f114d901..d5f59d49 100644 --- a/miasm/analysis/debugging.py +++ b/miasm/analysis/debugging.py @@ -377,7 +377,7 @@ class DebugCmd(cmd.Cmd, object): args = arg.split(" ") if args[-1].lower() not in ["on", "off"]: - self.print_warning("/!\ %s not in 'on' / 'off'" % args[-1]) + self.print_warning("[!] %s not in 'on' / 'off'" % args[-1]) return mode = args[-1].lower() == "on" d = {} diff --git a/miasm/analysis/dse.py b/miasm/analysis/dse.py index 5e6c4e8d..11674734 100644 --- a/miasm/analysis/dse.py +++ b/miasm/analysis/dse.py @@ -234,7 +234,7 @@ class DSEEngine(object): def handle(self, cur_addr): r"""Handle destination @cur_addr: Expr of the next address in concrete execution - /!\ cur_addr may be a loc_key + [!] cur_addr may be a loc_key In this method, self.symb is in the "just before branching" state """ @@ -475,7 +475,7 @@ class DSEEngine(object): @cpu: (optional) if set, update registers' value @mem: (optional) if set, update memory value - /!\ all current states will be loss. + [!] all current states will be loss. This function is usually called when states are no more synchronized (at the beginning, returning from an unstubbed syscall, ...) """ diff --git a/miasm/arch/aarch64/sem.py b/miasm/arch/aarch64/sem.py index 8cbab90b..eaa01228 100644 --- a/miasm/arch/aarch64/sem.py +++ b/miasm/arch/aarch64/sem.py @@ -179,7 +179,7 @@ system_regs = { (3, 0, 2, 3, 0): APGAKeyLo_EL1, (3, 0, 2, 3, 1): APGAKeyHi_EL1, - + (3, 0, 4, 1, 0): SP_EL0, (3, 0, 4, 6, 0): ICC_PMR_EL1, # Alias ICV_PMR_EL1 @@ -285,7 +285,7 @@ system_regs = { (3, 0, 0, 0, 1): CTR_EL0, (3, 3, 0, 0, 7): DCZID_EL0, - + (3, 3, 4, 4, 0): FPCR, (3, 3, 4, 4, 1): FPSR, @@ -1578,13 +1578,13 @@ def msr(ir, instr, arg1, arg2, arg3, arg4, arg5, arg6): e.append(ExprAssign(zf, arg6[30:31])) e.append(ExprAssign(cf, arg6[29:30])) e.append(ExprAssign(of, arg6[28:29])) - + elif arg1.is_int(3) and arg2.is_int(3) and arg3.is_id("c4") and arg4.is_id("c2") and arg5.is_int(7): e.append(ExprAssign(tco, arg6[25:26])) elif 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(dit, arg6[24:25])) - + elif arg1.is_int(3) and arg2.is_int(0) and arg3.is_id("c4") and arg4.is_id("c2") and arg5.is_int(4): e.append(ExprAssign(uao, arg6[23:24])) @@ -1599,7 +1599,7 @@ def msr(ir, instr, arg1, arg2, arg3, arg4, arg5, arg6): e.append(ExprAssign(af, arg6[8:9])) e.append(ExprAssign(iff, arg6[7:8])) e.append(ExprAssign(ff, arg6[6:7])) - + elif arg1.is_int(3) and arg2.is_int(0) and arg3.is_id("c4") and arg4.is_id("c2") and arg5.is_int(2): e.append(ExprAssign(cur_el, arg6[2:4])) diff --git a/miasm/arch/x86/arch.py b/miasm/arch/x86/arch.py index dabd0c82..c5ff9b63 100644 --- a/miasm/arch/x86/arch.py +++ b/miasm/arch/x86/arch.py @@ -428,7 +428,7 @@ def offsize(p): def get_prefix(s): - g = re.search('(\S+)(\s+)', s) + g = re.search(r'(\S+)(\s+)', s) if not g: return None, s prefix, b = g.groups() diff --git a/miasm/core/cpu.py b/miasm/core/cpu.py index 7a1cacff..7df9f991 100644 --- a/miasm/core/cpu.py +++ b/miasm/core/cpu.py @@ -393,7 +393,7 @@ variable = pyparsing.Word(pyparsing.alphas + "_$.", pyparsing.alphanums + "_") variable.setParseAction(cb_parse_id) operand = str_int | variable -base_expr = pyparsing.operatorPrecedence(operand, +base_expr = pyparsing.infixNotation(operand, [(notop, 1, pyparsing.opAssoc.RIGHT, cb_op_not), (andop, 2, pyparsing.opAssoc.RIGHT, cb_op_and), (xorop, 2, pyparsing.opAssoc.RIGHT, cb_op_xor), @@ -408,7 +408,7 @@ default_prio = 0x1337 def isbin(s): - return re.match('[0-1]+$', s) + return re.match(r'[0-1]+$', s) def int2bin(i, l): @@ -1301,7 +1301,7 @@ class cls_mn(with_metaclass(metamn, object)): @classmethod def fromstring(cls, text, loc_db, mode = None): global total_scans - name = re.search('(\S+)', text).groups() + name = re.search(r'(\S+)', text).groups() if not name: raise ValueError('cannot find name', text) name = name[0] diff --git a/miasm/core/graph.py b/miasm/core/graph.py index 0dfd7e6a..e680894c 100644 --- a/miasm/core/graph.py +++ b/miasm/core/graph.py @@ -20,7 +20,7 @@ class DiGraph(object): # N -> Nodes N2 with a edge (N2 -> N) self._nodes_pred = {} - self.escape_chars = re.compile('[' + re.escape('{}') + '&|<>' + ']') + self.escape_chars = re.compile(r'[\{\}&|<>]') def __repr__(self): diff --git a/miasm/core/sembuilder.py b/miasm/core/sembuilder.py index 24470656..9843ee6a 100644 --- a/miasm/core/sembuilder.py +++ b/miasm/core/sembuilder.py @@ -22,8 +22,8 @@ class MiasmTransformer(ast.NodeTransformer): """ # Parsers - parse_integer = re.compile("^i([0-9]+)$") - parse_mem = re.compile("^mem([0-9]+)$") + parse_integer = re.compile(r"^i([0-9]+)$") + parse_mem = re.compile(r"^mem([0-9]+)$") # Visitors def visit_Call(self, node): diff --git a/miasm/core/utils.py b/miasm/core/utils.py index 41bf78c1..eb170576 100644 --- a/miasm/core/utils.py +++ b/miasm/core/utils.py @@ -26,7 +26,7 @@ COLOR_OP = "black" COLOR_MNEMO = "blue1" -ESCAPE_CHARS = re.compile('[' + re.escape('{}') + '&|<>' + ']') +ESCAPE_CHARS = re.compile(r'[\{\}&|<>]') def set_html_text_color(text, color): return '<font color="%s">%s</font>' % (color, text) diff --git a/miasm/expression/expression.py b/miasm/expression/expression.py index c507f19f..e5debb34 100644 --- a/miasm/expression/expression.py +++ b/miasm/expression/expression.py @@ -2146,7 +2146,7 @@ def expr_is_sNaN(expr): def expr_is_float_lower(op1, op2): """Return 1 on 1 bit if @op1 < @op2, 0 otherwise. - /!\ Assume @op1 and @op2 are not NaN + [!] Assume @op1 and @op2 are not NaN Comparison is the floating point one, defined in IEEE754 """ sign1, sign2 = op1.msb(), op2.msb() @@ -2160,7 +2160,7 @@ def expr_is_float_lower(op1, op2): def expr_is_float_equal(op1, op2): """Return 1 on 1 bit if @op1 == @op2, 0 otherwise. - /!\ Assume @op1 and @op2 are not NaN + [!] Assume @op1 and @op2 are not NaN Comparison is the floating point one, defined in IEEE754 """ sign1, sign2 = op1.msb(), op2.msb() diff --git a/miasm/expression/expression_helper.py b/miasm/expression/expression_helper.py index 299e52e6..5bd2276d 100644 --- a/miasm/expression/expression_helper.py +++ b/miasm/expression/expression_helper.py @@ -89,7 +89,7 @@ op_propag_cst = ['+', '*', '^', '&', '|', '>>', def is_pure_int(e): """ return True if expr is only composed with integers - /!\ ExprCond returns True is src1 and src2 are integers + [!] ExprCond returns True is src1 and src2 are integers """ def modify_cond(e): if isinstance(e, m2_expr.ExprCond): @@ -444,7 +444,7 @@ class ExprRandom(object): """Internal function for generating sub-expression according to options @size: (optional) Operation size @depth: (optional) Expression depth - /!\ @generated_elements is left modified + [!] @generated_elements is left modified """ # Perfect tree handling if not cls.perfect_tree: diff --git a/miasm/expression/simplifications_common.py b/miasm/expression/simplifications_common.py index 835f8723..9156ee67 100644 --- a/miasm/expression/simplifications_common.py +++ b/miasm/expression/simplifications_common.py @@ -1146,7 +1146,7 @@ def simp_cmp_bijective_op(expr_simp, expr): # a + b + c == a + b if not args_b: return ExprOp(TOK_EQUAL, ExprOp(op, *args_a), ExprInt(0, args_a[0].size)) - + arg_a = ExprOp(op, *args_a) arg_b = ExprOp(op, *args_b) return ExprOp(TOK_EQUAL, arg_a, arg_b) @@ -1275,7 +1275,7 @@ def simp_cond_eq_zero(_, expr): def simp_sign_inf_zeroext(expr_s, expr): """ - /!\ Ensure before: X.zeroExt(X.size) => X + [!] Ensure before: X.zeroExt(X.size) => X X.zeroExt() <s 0 => 0 X.zeroExt() <=s 0 => X == 0 @@ -1782,7 +1782,7 @@ def simp_bcdadd_cf(_, expr): for i in range(0,16,4): nib_1 = (arg1.arg >> i) & (0xF) nib_2 = (arg2.arg >> i) & (0xF) - + j = (carry + nib_1 + nib_2) if (j >= 10): carry = 1 @@ -1807,7 +1807,7 @@ def simp_bcdadd(_, expr): for i in range(0,16,4): nib_1 = (arg1.arg >> i) & (0xF) nib_2 = (arg2.arg >> i) & (0xF) - + j = (carry + nib_1 + nib_2) if (j >= 10): carry = 1 diff --git a/miasm/ir/ir.py b/miasm/ir/ir.py index e9b86899..d26c5d1d 100644 --- a/miasm/ir/ir.py +++ b/miasm/ir/ir.py @@ -48,7 +48,7 @@ def _expr_loc_to_symb(expr, loc_db): return m2_expr.ExprId(name, expr.size) -ESCAPE_CHARS = re.compile('[' + re.escape('{}') + '&|<>' + ']') +ESCAPE_CHARS = re.compile(r'[\{\}&|<>]') class TranslatorHtml(Translator): __LANG__ = "custom_expr_color" diff --git a/miasm/ir/translators/z3_ir.py b/miasm/ir/translators/z3_ir.py index 4b674c4e..c72ff36f 100644 --- a/miasm/ir/translators/z3_ir.py +++ b/miasm/ir/translators/z3_ir.py @@ -1,10 +1,11 @@ from builtins import map from builtins import range -import imp +import importlib.util import logging # Raise an ImportError if z3 is not available WITHOUT actually importing it -imp.find_module("z3") +if importlib.util.find_spec("z3") is None: + raise ImportError("No module named 'z3'") from miasm.ir.translators.translator import Translator diff --git a/miasm/jitter/loader/pe.py b/miasm/jitter/loader/pe.py index c988fc59..9af068e4 100644 --- a/miasm/jitter/loader/pe.py +++ b/miasm/jitter/loader/pe.py @@ -23,12 +23,12 @@ log.setLevel(logging.INFO) 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. - + Example: - + pe = miasm.analysis.binary.Container.from_string(buf) deps = miasm.jitter.loader.pe.get_pe_dependencies(pe.executable) assert sorted(deps)[0] == 'api-ms-win-core-appcompat-l1-1-0.dll' @@ -63,12 +63,12 @@ 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. - + Example: - + pe = miasm.analysis.binary.Container.from_string(buf) imports = miasm.jitter.loader.pe.get_import_address_pe(pe.executable) - assert imports[('api-ms-win-core-rtlsupport-l1-1-0.dll', 'RtlCaptureStackBackTrace')] == {0x6b88a6d0} + assert imports[('api-ms-win-core-rtlsupport-l1-1-0.dll', 'RtlCaptureStackBackTrace')] == {0x6b88a6d0} """ import2addr = defaultdict(set) if e.DirImport.impdesc is None: @@ -732,7 +732,7 @@ class ImpRecStateMachine(object): "entry_module_addr": func_addr, "entry_memory_addr": self.cur_address, } - + def transition(self, data): if self.state == self.STATE_SEARCH: if data in self.func_addrs: @@ -760,7 +760,7 @@ class ImpRecStateMachine(object): self.transition(data) else: raise ValueError() - + def run(self): while True: data, address = yield @@ -804,7 +804,7 @@ class ImpRecStrategy(object): @update_libs: if set (default), update `libs` object with founded addresses @align_hypothesis: if not set (default), do not consider import addresses are written on aligned addresses - + Return the list of candidates """ candidates = [] diff --git a/miasm/jitter/loader/utils.py b/miasm/jitter/loader/utils.py index 73809141..7f913d76 100644 --- a/miasm/jitter/loader/utils.py +++ b/miasm/jitter/loader/utils.py @@ -65,7 +65,7 @@ class libimp(object): # imp_ord_or_name = vm_get_str(imp_ord_or_name, 0x100) # imp_ord_or_name = imp_ord_or_name[:imp_ord_or_name.find('\x00')] - #/!\ can have multiple dst ad + #[!] can have multiple dst ad if not imp_ord_or_name in self.lib_imp2dstad[libad]: self.lib_imp2dstad[libad][imp_ord_or_name] = set() if dst_ad is not None: diff --git a/miasm/loader/minidump.py b/miasm/loader/minidump.py index fbb7bde5..c16473b4 100644 --- a/miasm/loader/minidump.py +++ b/miasm/loader/minidump.py @@ -388,7 +388,7 @@ class Context_AMD64(CStruct): ("MxCsr", "u32"), # Segment & processor - # /!\ activation depends on multiple flags + # [!] activation depends on multiple flags ("SegCs", "u16", is_activated("CONTEXT_CONTROL")), ("SegDs", "u16", is_activated("CONTEXT_SEGMENTS")), ("SegEs", "u16", is_activated("CONTEXT_SEGMENTS")), @@ -406,7 +406,7 @@ class Context_AMD64(CStruct): ("Dr7", "u64", is_activated("CONTEXT_DEBUG_REGISTERS")), # Integer registers - # /!\ activation depends on multiple flags + # [!] activation depends on multiple flags ("Rax", "u64", is_activated("CONTEXT_INTEGER")), ("Rcx", "u64", is_activated("CONTEXT_INTEGER")), ("Rdx", "u64", is_activated("CONTEXT_INTEGER")), diff --git a/miasm/os_dep/linux/environment.py b/miasm/os_dep/linux/environment.py index 808fc847..3ba4382f 100644 --- a/miasm/os_dep/linux/environment.py +++ b/miasm/os_dep/linux/environment.py @@ -13,7 +13,7 @@ from miasm.core.interval import interval from miasm.jitter.csts import PAGE_READ, PAGE_WRITE -REGEXP_T = type(re.compile('')) +REGEXP_T = type(re.compile(r'')) StatInfo = namedtuple("StatInfo", [ "st_dev", "st_ino", "st_nlink", "st_mode", "st_uid", "st_gid", "st_rdev", @@ -262,7 +262,7 @@ class FileSystem(object): expr.flags, exc_info=True, ) - return re.compile('$X') + return re.compile(r'$X') return expr # Remove '../', etc. diff --git a/miasm/os_dep/win_api_x86_32.py b/miasm/os_dep/win_api_x86_32.py index e9c5fd4a..6e568abb 100644 --- a/miasm/os_dep/win_api_x86_32.py +++ b/miasm/os_dep/win_api_x86_32.py @@ -623,10 +623,10 @@ def kernel32_CreateFile(jitter, funcname, get_str): elif fname.upper() in ['NUL']: ret = winobjs.module_cur_hwnd else: - # sandox path + # sandbox path sb_fname = windows_to_sbpath(fname) if args.access & 0x80000000 or args.access == 1: - # read + # read and maybe write if args.dwcreationdisposition == 2: # create_always if os.access(sb_fname, os.R_OK): @@ -642,7 +642,10 @@ def kernel32_CreateFile(jitter, funcname, get_str): if stat.S_ISDIR(s.st_mode): ret = winobjs.handle_pool.add(sb_fname, 0x1337) else: - h = open(sb_fname, 'r+b') + open_mode = 'rb' + if (args.access & 0x40000000) or args.access == 2: + open_mode = 'r+b' + h = open(sb_fname, open_mode) ret = winobjs.handle_pool.add(sb_fname, h) else: log.warning("FILE %r (%s) DOES NOT EXIST!", fname, sb_fname) @@ -671,8 +674,8 @@ def kernel32_CreateFile(jitter, funcname, get_str): raise NotImplementedError("Untested case") else: raise NotImplementedError("Untested case") - elif args.access & 0x40000000: - # write + elif (args.access & 0x40000000) or args.access == 2: + # write but not read if args.dwcreationdisposition == 3: # open existing if is_original_file: @@ -684,7 +687,7 @@ def kernel32_CreateFile(jitter, funcname, get_str): # open dir ret = winobjs.handle_pool.add(sb_fname, 0x1337) else: - h = open(sb_fname, 'r+b') + h = open(sb_fname, 'wb') ret = winobjs.handle_pool.add(sb_fname, h) else: raise NotImplementedError("Untested case") # to test @@ -2452,7 +2455,7 @@ def user32_GetKeyboardType(jitter): jitter.func_ret_stdcall(ret_ad, ret) - + class startupinfo(object): """ typedef struct _STARTUPINFOA { @@ -2528,7 +2531,7 @@ def kernel32_GetStartupInfo(jitter, funcname, set_str): Retrieves the contents of the STARTUPINFO structure that was specified when the calling process was created. - + https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getstartupinfow """ diff --git a/requirements.txt b/requirements.txt index 5db3c2a8..b518400d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -pyparsing~=2.0 +pyparsing>=2.4.1 future diff --git a/setup.py b/setup.py index a33f608f..e1e54434 100644 --- a/setup.py +++ b/setup.py @@ -325,7 +325,7 @@ def build_all(): "VERSION" ] }, - install_requires=["future", "pyparsing~=2.0"], + install_requires=["future", "pyparsing>=2.4.1"], cmdclass={"install_data": smart_install_data}, ext_modules = ext_modules, # Metadata diff --git a/test/analysis/depgraph.py b/test/analysis/depgraph.py index 57a73a5f..9760e717 100644 --- a/test/analysis/depgraph.py +++ b/test/analysis/depgraph.py @@ -108,7 +108,7 @@ class IRATest(LifterModelCall): def bloc2graph(irgraph, label=False, lines=True): """Render dot graph of @blocks""" - escape_chars = re.compile('[' + re.escape('{}') + ']') + escape_chars = re.compile(r'[\{\}]') label_attr = 'colspan="2" align="center" bgcolor="grey"' edge_attr = 'label = "%s" color="%s" style="bold"' td_attr = 'align="left"' @@ -179,7 +179,7 @@ def bloc2graph(irgraph, label=False, lines=True): def dg2graph(graph, label=False, lines=True): """Render dot graph of @blocks""" - escape_chars = re.compile('[' + re.escape('{}') + ']') + escape_chars = re.compile(r'[\{\}]') label_attr = 'colspan="2" align="center" bgcolor="grey"' edge_attr = 'label = "%s" color="%s" style="bold"' td_attr = 'align="left"' diff --git a/test/arch/mep/asm/ut_helpers_asm.py b/test/arch/mep/asm/ut_helpers_asm.py index 9f6dc5c2..2ebd0622 100644 --- a/test/arch/mep/asm/ut_helpers_asm.py +++ b/test/arch/mep/asm/ut_helpers_asm.py @@ -27,7 +27,7 @@ def check_instruction(mn_str, mn_hex, multi=None, offset=0): """Try to disassemble and assemble this instruction""" # Rename objdump registers names - mn_str = re.sub("\$([0-9]+)", lambda m: "R"+m.group(1), mn_str) + mn_str = re.sub(r"\$([0-9]+)", lambda m: "R"+m.group(1), mn_str) mn_str = mn_str.replace("$", "") # Disassemble |