mirror of
https://github.com/hugsy/gef.git
synced 2026-10-11 21:49:56 +00:00
## Description This PR - removes unmaintained `shellcode` commands, tests, and documentation - (finally) switches to Ruff instead of Pylint (still handled by `pre-commit`) - fixes a few ruff/ty-found issues
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
import pathlib
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
import pytest
|
|
import requests
|
|
|
|
from tests.utils import GEF_PATH
|
|
|
|
SCRIPT_DIR = GEF_PATH.parent / "scripts"
|
|
|
|
|
|
class GefInstallScript(unittest.TestCase):
|
|
def setUp(self):
|
|
url = "https://api.github.com/repos/hugsy/gef/tags"
|
|
res = requests.get(url)
|
|
if res.status_code == 403:
|
|
pytest.skip("API rate limit exceeded")
|
|
assert res.status_code == 200
|
|
self.latest_release = res.json()[0]["name"]
|
|
|
|
@pytest.mark.online
|
|
def test_script_gef_sh(self):
|
|
script_fpath = SCRIPT_DIR / "gef.sh"
|
|
assert script_fpath.exists()
|
|
|
|
# Execute the script within a mock home dir
|
|
tempdir = tempfile.TemporaryDirectory()
|
|
tempdir_path = pathlib.Path(tempdir.name)
|
|
|
|
res = subprocess.call(
|
|
["sh", script_fpath], env={"HOME": str(tempdir_path.absolute())}
|
|
)
|
|
assert res == 0
|
|
|
|
release = self.latest_release
|
|
fname = f".gef-{release}.py"
|
|
|
|
assert (tempdir_path / ".gdbinit").exists()
|
|
assert (tempdir_path / ".gdbinit").open(
|
|
"r", encoding="utf-8"
|
|
).read() == f"source ~/{fname}\n"
|
|
|
|
fpath = tempdir_path / fname
|
|
assert fpath.exists()
|
|
assert len(fpath.open("rb").read()) > 0
|