SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
CI: Tests need correct repo_path and challenge_path
Kilian Lieret577baa7ad35d
diff --git a/tests/conftest.py b/tests/conftest.pyindex d6c70ff6..e52e52d5 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -43,6 +43,13 @@ def test_ctf_trajectories_path(test_data_path) -> Path:return p+def ctf_data_path(test_data_sources_path) -> Path:+ p = test_data_sources_path / "ctf"+ assert p.is_dir()+ return p++@pytest.fixturedef test_data_sources_path(test_data_path) -> Path:p = test_data_path / "data_sources"diff --git a/tests/test_data/data_sources/ctf/misc/Networking 1/README.md b/tests/test_data/data_sources/ctf/misc/networking_1/README.mdsimilarity index 100%rename from tests/test_data/data_sources/ctf/misc/Networking 1/README.mdrename to tests/test_data/data_sources/ctf/misc/networking_1/README.mddiff --git a/tests/test_data/data_sources/ctf/misc/Networking 1/challenge.json b/tests/test_data/data_sources/ctf/misc/networking_1/challenge.jsonsimilarity index 100%rename from tests/test_data/data_sources/ctf/misc/Networking 1/challenge.jsonrename to tests/test_data/data_sources/ctf/misc/networking_1/challenge.jsondiff --git a/tests/test_data/data_sources/ctf/misc/Networking 1/networking.pcap b/tests/test_data/data_sources/ctf/misc/networking_1/networking.pcapsimilarity index 100%rename from tests/test_data/data_sources/ctf/misc/Networking 1/networking.pcaprename to tests/test_data/data_sources/ctf/misc/networking_1/networking.pcapdiff --git a/tests/test_data/data_sources/ctf/web/I Got Id/000-default.conf b/tests/test_data/data_sources/ctf/web/i_got_id_demo/000-default.confsimilarity index 100%rename from tests/test_data/data_sources/ctf/web/I Got Id/000-default.confrename to tests/test_data/data_sources/ctf/web/i_got_id_demo/000-default.confdiff --git a/tests/test_data/data_sources/ctf/web/I Got Id/Dockerfile b/tests/test_data/data_sources/ctf/web/i_got_id_demo/Dockerfilesimilarity index 100%rename from tests/test_data/data_sources/ctf/web/I Got Id/Dockerfilerename to tests/test_data/data_sources/ctf/web/i_got_id_demo/Dockerfilediff --git a/tests/test_data/data_sources/ctf/web/I Got Id/cgi/file.pl b/tests/test_data/data_sources/ctf/web/i_got_id_demo/cgi/file.plsimilarity index 100%rename from tests/test_data/data_sources/ctf/web/I Got Id/cgi/file.plrename to tests/test_data/data_sources/ctf/web/i_got_id_demo/cgi/file.pldiff --git a/tests/test_data/data_sources/ctf/web/I Got Id/cgi/forms.pl b/tests/test_data/data_sources/ctf/web/i_got_id_demo/cgi/forms.plsimilarity index 100%rename from tests/test_data/data_sources/ctf/web/I Got Id/cgi/forms.plrename to tests/test_data/data_sources/ctf/web/i_got_id_demo/cgi/forms.pldiff --git a/tests/test_data/data_sources/ctf/web/I Got Id/cgi/hello.pl b/tests/test_data/data_sources/ctf/web/i_got_id_demo/cgi/hello.plsimilarity index 100%rename from tests/test_data/data_sources/ctf/web/I Got Id/cgi/hello.plrename to tests/test_data/data_sources/ctf/web/i_got_id_demo/cgi/hello.pldiff --git a/tests/test_data/data_sources/ctf/web/I Got Id/challenge.json b/tests/test_data/data_sources/ctf/web/i_got_id_demo/challenge.jsonsimilarity index 100%rename from tests/test_data/data_sources/ctf/web/I Got Id/challenge.jsonrename to tests/test_data/data_sources/ctf/web/i_got_id_demo/challenge.jsondiff --git a/tests/test_data/data_sources/ctf/web/I Got Id/docker-compose.yml b/tests/test_data/data_sources/ctf/web/i_got_id_demo/docker-compose.ymlsimilarity index 100%rename from tests/test_data/data_sources/ctf/web/I Got Id/docker-compose.ymlrename to tests/test_data/data_sources/ctf/web/i_got_id_demo/docker-compose.ymldiff --git a/tests/test_data/data_sources/ctf/web/I Got Id/flag b/tests/test_data/data_sources/ctf/web/i_got_id_demo/flagsimilarity index 100%rename from tests/test_data/data_sources/ctf/web/I Got Id/flagrename to tests/test_data/data_sources/ctf/web/i_got_id_demo/flagdiff --git a/tests/test_data/data_sources/ctf/web/I Got Id/index.html b/tests/test_data/data_sources/ctf/web/i_got_id_demo/index.htmlsimilarity index 100%rename from tests/test_data/data_sources/ctf/web/I Got Id/index.htmlrename to tests/test_data/data_sources/ctf/web/i_got_id_demo/index.htmldiff --git a/tests/test_data/data_sources/ctf/web/I Got Id/solution.txt b/tests/test_data/data_sources/ctf/web/i_got_id_demo/solution.txtsimilarity index 100%rename from tests/test_data/data_sources/ctf/web/I Got Id/solution.txtrename to tests/test_data/data_sources/ctf/web/i_got_id_demo/solution.txtdiff --git a/tests/test_replay_ctf.py b/tests/test_replay_ctf.pyindex 327ad3ab..dac60956 100644--- a/tests/test_replay_ctf.py+++ b/tests/test_replay_ctf.py@@ -1,9 +1,18 @@from __future__ import annotations+import sys+import pytestfrom run_replay import get_args, main+_TEST_OUTPUTS = {+ "pwn/warmup.traj": r"Closed connection to pwn.chal.csaw.io port 8000\nFLAG{LET_US_BEGIN_CSAW_2016}",+ "forensics/flash.traj": r"the black flag waved night and day from the",+ # "web/i_got_id_demo.traj": r"4365",+ "misc/networking_1.traj": r"Password: \nflag{d316759c281bf925d600be698a4973d5}",+}+@pytest.mark.slow@pytest.mark.ctf@@ -11,12 +20,22 @@ from run_replay import get_args, main"traj_rel_path",["pwn/warmup.traj", "forensics/flash.traj", "web/i_got_id_demo.traj", "rev/rock.traj", "misc/networking_1.traj"],)-def test_ctf_traj_replay(test_ctf_trajectories_path, traj_rel_path):+def test_ctf_traj_replay(test_ctf_trajectories_path, traj_rel_path, ctf_data_path, capsys):+ if sys.platform == "darwin" and traj_rel_path in ["pwn/warmup.traj", "rev/rock.traj"]:+ pytest.skip("Skipping test on macOS")traj_path = test_ctf_trajectories_path / traj_rel_path+ challenge_dir = ctf_data_path / traj_rel_path.removesuffix(".traj")+ assert challenge_dir.is_dir()+ data_path = challenge_dir / "challenge.json"+ assert data_path.is_file()assert traj_path.is_file()args = ["--traj_path",str(traj_path),+ "--data_path",+ str(data_path),+ "--repo_path",+ str(challenge_dir),"--config_file","config/default_ctf.yaml","--raise_exceptions",@@ -24,3 +43,6 @@ def test_ctf_traj_replay(test_ctf_trajectories_path, traj_rel_path):]args, remaining_args = get_args(args)main(**vars(args), forward_args=remaining_args)+ captured = capsys.readouterr()+ if traj_rel_path in _TEST_OUTPUTS:+ assert _TEST_OUTPUTS[traj_rel_path] in captured.out