Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/cicd/extension-kit-tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tasks:
- cmdline: "shell whoami"
expected: "ci_runner"

- cmdline: "shell echo extension_kit_ok"
expected: "extension_kit_ok"

- cmdline: "xyzzy frobnicate"
expected: "will never succeed"
allowed_to_fail: true
18 changes: 18 additions & 0 deletions .github/cicd/install-extension-kit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Install Extension-Kit BOF collection inside adaptixc2.
# The repo is cloned to /app/extenders/extension-kit.
set -euo pipefail

EXT_KIT_DIR=/app/extenders/extension-kit

echo "Extension-Kit: checking for pre-built BOF files..."

if [[ -f "${EXT_KIT_DIR}/setup.sh" ]]; then
bash "${EXT_KIT_DIR}/setup.sh"
elif [[ -f "${EXT_KIT_DIR}/install.sh" ]]; then
bash "${EXT_KIT_DIR}/install.sh"
else
echo "No setup script found — BOF files assumed pre-compiled."
fi

echo "Extension-Kit install complete."
34 changes: 34 additions & 0 deletions .github/cicd/install-kharon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Build and install Kharon extender inside the adaptixc2 container.
# The repo is already cloned to /app/extenders/kharon by Testing-Kit.
set -euo pipefail

KHARON_DIR=/app/extenders/kharon

if ! command -v go &>/dev/null; then
apt-get update -qq
apt-get install -y -qq golang-go
fi

GO_VERSION=$(go version | awk '{print $3}')
echo "Using Go: ${GO_VERSION}"

echo "Building Kharon listener..."
cd "${KHARON_DIR}"
if [[ -f Makefile ]]; then
make listener
else
cd "${KHARON_DIR}/listener_kharon_http"
go build -buildmode=plugin -trimpath -o listener.so .
fi

echo "Building Kharon agent..."
cd "${KHARON_DIR}"
if [[ -f Makefile ]]; then
make agent
else
cd "${KHARON_DIR}/agent_kharon"
go build -buildmode=plugin -trimpath -o agent.so .
fi

echo "Kharon build complete."
6 changes: 6 additions & 0 deletions .github/cicd/kharon-malleable-profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
"Headers": [],
"URIs": ["/api/v1/status", "/api/v1/check"],
"BodyEncoding": "base64"
}
17 changes: 17 additions & 0 deletions .github/cicd/kharon-tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tasks:
- cmdline: "shell whoami"
expected: "ci_runner"

- cmdline: "shell hostname"
expected_regex: "(?i)win|desktop|server"

- cmdline: "shell dir C:\\"
expected: "Windows"
not_expected: "File Not Found"

- cmdline: "shell echo kharon_test_ok"
expected: "kharon_test_ok"

- cmdline: "xyzzy frobnicate"
expected: "will never succeed"
allowed_to_fail: true
File renamed without changes.
127 changes: 127 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,130 @@ jobs:
- name: Teardown
if: always()
run: ./testing-kit-cli reset

test-kharon:
name: Test Kharon extender
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false

- name: Build CLI
run: |
cd cli && go build \
-ldflags "-X main.version=${GITHUB_SHA} -X 'main.repoOwner=TGJLS/Testing-Kit'" \
-o ../testing-kit-cli \
.

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Build Docker image
run: docker build -t ghcr.io/tgjls/testing-kit:2.1.0 .

- name: Install stack
run: ./testing-kit-cli install

- name: Wait for testing-kit API
run: |
for i in $(seq 1 30); do
curl -sf http://localhost:1234/health > /dev/null 2>&1 && exit 0
sleep 2
done
echo "testing-kit API did not become ready in time"
exit 1

- name: Add Kharon extender
run: |
PROFILE_B64=$(base64 -w0 .github/cicd/kharon-malleable-profile.json)
./testing-kit-cli add-extender https://github.com/entropy-z/Kharon \
--install-script .github/cicd/install-kharon.sh \
--override "listener.uploaded_file=${PROFILE_B64}"

- name: Seed Kharon tasks
run: |
curl -sf -X PUT http://localhost:1234/v1/tasks/batch \
-H "Content-Type: application/json" \
-d "$(python3 -c "
import json, yaml
data = yaml.safe_load(open('.github/cicd/kharon-tasks.yaml'))
print(json.dumps(data['tasks']))
")"

- name: Run tests
run: ./testing-kit-cli run-tests

- name: Tear down
if: always()
run: ./testing-kit-cli down

test-extension-kit:
name: Test Extension-Kit BOFs
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false

- name: Build CLI
run: |
cd cli && go build \
-ldflags "-X main.version=${GITHUB_SHA} -X 'main.repoOwner=TGJLS/Testing-Kit'" \
-o ../testing-kit-cli \
.

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Build Docker image
run: docker build -t ghcr.io/tgjls/testing-kit:2.1.0 .

- name: Install stack
run: ./testing-kit-cli install

- name: Wait for testing-kit API
run: |
for i in $(seq 1 30); do
curl -sf http://localhost:1234/health > /dev/null 2>&1 && exit 0
sleep 2
done
echo "testing-kit API did not become ready in time"
exit 1

- name: Add Extension-Kit BOFs
run: |
./testing-kit-cli add-extender \
https://github.com/Adaptix-Framework/Extension-Kit \
--install-script .github/cicd/install-extension-kit.sh

- name: Seed Extension-Kit tasks
run: |
curl -sf -X PUT http://localhost:1234/v1/tasks/batch \
-H "Content-Type: application/json" \
-d "$(python3 -c "
import json, yaml
data = yaml.safe_load(open('.github/cicd/extension-kit-tasks.yaml'))
print(json.dumps(data['tasks']))
")"

- name: Run tests
run: ./testing-kit-cli run-tests

- name: Tear down
if: always()
run: ./testing-kit-cli down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __pycache__/
*.py[oc]
build/
dist/
!adaptixc2/dist/
wheels/
*.egg-info

Expand All @@ -26,3 +27,5 @@ docker-compose.override.yml
ssh/
testing-kit-cli
testing-kit-cli.tar.gz
!.github/cicd/tasks.yaml
adaptixc2/dist/extenders/
Loading
Loading