From e70084b54fa5194217291c52eed364fddb0d7c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mayoral=20Vilches?= Date: Mon, 13 Jan 2025 07:56:15 +0000 Subject: [PATCH] Add ctfs and various fixes to finalize testing CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vรญctor Mayoral Vilches --- .gitlab-ci.yml | 2 +- ci/ctfs/.ctf.yml | 59 +++++++++++++++++++++++++++++++++++++++++++++++ ci/test/.test.yml | 16 +++++++++---- 3 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 ci/ctfs/.ctf.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3b6ed60e..6cc0aa70 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,7 +25,7 @@ include: - project: 'aliasrobotics/alias_research/cai' ref: main file: - - 'ci/build/.build.yml' # build + # - 'ci/build/.build.yml' # build #- 'ci/setup/.setup.yml' # setup - 'ci/test/.test.yml' # test #- 'ci/ctfs/.ctf.yml' # ctf diff --git a/ci/ctfs/.ctf.yml b/ci/ctfs/.ctf.yml new file mode 100644 index 00000000..d29b2592 --- /dev/null +++ b/ci/ctfs/.ctf.yml @@ -0,0 +1,59 @@ +.use_base_container: &use_base_container + stage: test + image: "${CI_REGISTRY_IMAGE}:latest" + services: + - name: docker:dind + command: ["dockerd", "--host=tcp://192.168.2.1:2375", "--host=unix:///var/run/docker.sock", "--dns=8.8.8.8", "--dns=8.8.4.4"] +.run_test: &run_test + <<: *use_base_container + before_script: + - | + for i in $(seq 1 5); do + echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY_IMAGE && break || sleep 10 + + echo "Retrying docker login ($i/5)..." + done + script: + - pip3 uninstall pentestperf --yes # remove old version + - pip3 install -e . + - msfrpcd -P cai > /dev/null 2>&1 & + - | + # Set additional environment variables if defined + for var in $(compgen -e); do + if [[ $var == CTF_* && -n ${!var} ]]; then + export $var="${!var}" + fi + done + - pytest $TEST_PATH -s + artifacts: + paths: + - cai.png + - cai.dot + expire_in: 1 month # Retain the artifacts for 1 month + tags: + - p40 + - x86 + rules: + - if: $CI_COMMIT_BRANCH + when: on_success + +################################################################################ +# CTF +################################################################################ + +# ๐Ÿšฉ picoctf_static_flag | qw:14b | ๐Ÿ“ r: +# <<: *run_test +# stage: ctf-super-easy +# variables: +# TEST_PATH: tests/benchmarks/generic.py -s +# CTF_NAME: picoctf_static_flag +# CTF_MODEL: qwen2.5:14b +# # Optional +# CTF_MODEL_STATE_OVERRIDE: marco-o1:7b-fp16 +# CTF_MODEL_AGENT_OVERRIDE: qwen2.5:14b +# CTF_PLANNER_CLASS: PlannerR +# CTF_SUBNET: 192.168.3.0/24 +# CTF_IP: 192.168.3.100 +# CTF_MULTI_CALL: true +# CTF_MAX_TASKS: 50 +# CTF_REPLAN_N: 10 diff --git a/ci/test/.test.yml b/ci/test/.test.yml index e4a1fb1f..850f2a3e 100644 --- a/ci/test/.test.yml +++ b/ci/test/.test.yml @@ -10,7 +10,7 @@ <<: *use_base_container script: - pip3 install -e . - - pytest $TEST_PATH -s + - pytest -s $TEST_PATH tags: - p40 - x86 @@ -24,7 +24,13 @@ TEST_PATH: tests/tools/reconnaissance/test_filesystem.py -# ๐Ÿ—๏ธ tools test_list_dir: -# <<: *run_test -# variables: -# TEST_PATH: tests/tests/tools/reconnaissance/filesystem/list_dir.py +๐Ÿ—๏ธ tools test_architecture: + <<: *run_test + variables: + TEST_PATH: tests/tools/architecture + + +๐Ÿ—๏ธ tools test_agents: + <<: *run_test + variables: + TEST_PATH: tests/tools/agents