From 5e7b406dff6b5fb2ccafd4ef00cbd1ebc1fbe6f3 Mon Sep 17 00:00:00 2001 From: Disconnect3d Date: Thu, 28 Nov 2024 14:16:41 +0100 Subject: [PATCH] Fix #2549: block config. assignments (#2585) * Fix #2549: block config. assignments This commit blocks `config. = ` assignments as they should be done via `config..value = ` instead. * Update config.py * add .value --- DEVELOPING.md | 2 +- pwndbg/lib/config.py | 5 +++++ tests/gdb-tests/tests/test_hexdump.py | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/DEVELOPING.md b/DEVELOPING.md index 97eac19c8..be0f7a722 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -89,7 +89,7 @@ Here's a small snippet of the actual test: ```python def test_hexdump(start_binary): start_binary(BINARY) - pwndbg.config.hexdump_group_width = -1 + pwndbg.config.hexdump_group_width.value = -1 gdb.execute("set hexdump-byte-separator") stack_addr = pwndbg.aglib.regs.rsp - 0x100 diff --git a/pwndbg/lib/config.py b/pwndbg/lib/config.py index 9d0df2653..6d8c4e66b 100644 --- a/pwndbg/lib/config.py +++ b/pwndbg/lib/config.py @@ -208,3 +208,8 @@ class Config: return self.params[name] else: raise AttributeError(f"'Config' object has no attribute '{name}'") + + def __setattr__(self, attr, val): + if attr in ("params", "triggers"): + return super().__setattr__(attr, val) + raise AttributeError("Use config..value to set value of a parameter") diff --git a/tests/gdb-tests/tests/test_hexdump.py b/tests/gdb-tests/tests/test_hexdump.py index 5b8bfbba4..63b747d50 100644 --- a/tests/gdb-tests/tests/test_hexdump.py +++ b/tests/gdb-tests/tests/test_hexdump.py @@ -13,7 +13,7 @@ BINARY = tests.binaries.get("reference-binary.out") def run_tests(stack, use_big_endian, expected): - pwndbg.config.hexdump_group_use_big_endian = use_big_endian + pwndbg.config.hexdump_group_use_big_endian.value = use_big_endian # Put some data onto the stack pwndbg.aglib.memory.write(stack, cyclic(0x100)) @@ -35,7 +35,7 @@ def run_tests(stack, use_big_endian, expected): def test_hexdump(start_binary): start_binary(BINARY) - pwndbg.config.hexdump_group_width = -1 + pwndbg.config.hexdump_group_width.value = -1 # TODO: Setting theme options with Python isn't working gdb.execute("set hexdump-byte-separator")