Skip to content

Commit

Permalink
[Release 2024.06] Fixes (#1116)
Browse files Browse the repository at this point in the history
Restores tests on non-x86 (tested arm, arm64 and mips64)

Mostly very minor fixes, only unit tests related.
Qemu tests are temporarily disabled when remoting because they all
assume host & target are Intel (not blocking, but must be reworked
later).
  • Loading branch information
hugsy authored Jun 3, 2024
1 parent ff185e6 commit 1b6f46a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions tests/api/gef_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from tests.base import RemoteGefUnitTestGeneric

from tests.utils import (
ARCH,
debug_target,
gdbserver_session,
qemuuser_session,
Expand Down Expand Up @@ -135,6 +136,7 @@ def test_func_parse_maps_remote_gdbserver(self):
sections = gef.memory.maps
assert len(sections) > 0

@pytest.mark.skipif(ARCH not in ("x86_64",), reason=f"Skipped for {ARCH}")
def test_func_parse_maps_remote_qemu(self):
gdb, gef = self._gdb, self._gef
# When in a gef-remote qemu-user session `parse_gdb_info_proc_maps`
Expand Down
3 changes: 3 additions & 0 deletions tests/api/gef_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import pathlib
import random
import re
import pytest

from tests.base import RemoteGefUnitTestGeneric

from tests.utils import (
ARCH,
debug_target,
gdbserver_session,
qemuuser_session,
Expand Down Expand Up @@ -72,6 +74,7 @@ def test_root_dir_remote(self):
expected.st_ino == result.st_ino
)

@pytest.mark.skipif(ARCH not in ("x86_64",), reason=f"Skipped for {ARCH}")
def test_root_dir_qemu(self):
gdb, gef = self._gdb, self._gef

Expand Down
9 changes: 4 additions & 5 deletions tests/commands/canary.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@ def setUp(self) -> None:
self._target = debug_target("canary")
return super().setUp()


def test_cmd_canary(self):
assert ERROR_INACTIVE_SESSION_MESSAGE == self._gdb.execute("canary", to_string=True)
self._gdb.execute("start")
res = self._gdb.execute("canary", to_string=True)
assert "The canary of process" in res
assert self._gef.session.canary[0] == self._gef.session.original_canary[0]


def test_overwrite_canary(self):
gdb, gef = self._gdb, self._gef

gdb.execute("start")
_, canary_address = gef.session.canary
if is_64b():
gef.memory.write(gef.arch.canary_address(), p64(0xdeadbeef))
gef.memory.write(canary_address, p64(0xDEADBEEF))
else:
gef.memory.write(gef.arch.canary_address(), p32(0xdeadbeef))
res = u32(gef.memory.read(gef.arch.canary_address(), gef.arch.ptrsize))
gef.memory.write(canary_address, p32(0xDEADBEEF))
res = u32(gef.memory.read(canary_address, gef.arch.ptrsize))
assert 0xdeadbeef == res
2 changes: 2 additions & 0 deletions tests/commands/gef_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from tests.base import RemoteGefUnitTestGeneric
from tests.utils import (
ARCH,
debug_target,
gdbserver_session,
qemuuser_session,
Expand Down Expand Up @@ -39,6 +40,7 @@ def test_cmd_gef_remote_gdbserver(self):
assert res.endswith(f"pid={gef.session.pid}, mode={gdbserver_mode})")

@pytest.mark.slow
@pytest.mark.skipif(ARCH not in ("x86_64",), reason=f"Skipped for {ARCH}")
def test_cmd_gef_remote_qemu_user(self):
gdb = self._gdb
gef = self._gef
Expand Down
2 changes: 1 addition & 1 deletion tests/commands/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ScanCommand(RemoteGefUnitTestGeneric):
"""`scan` command test module"""

def setUp(self) -> None:
self._target = debug_target("checksec-no-pie")
self._target = debug_target("default")
return super().setUp()

def test_cmd_scan(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/commands/vmmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def test_cmd_vmmap(self):
res = gdb.execute("vmmap stack", to_string=True)
self.assertGreater(len(res.splitlines()), 1)

res = gdb.execute("vmmap $rip", to_string=True)
res = gdb.execute("vmmap $pc", to_string=True)
self.assertEqual(len(res.splitlines()), 2)

0 comments on commit 1b6f46a

Please sign in to comment.