diff --git a/.github/workflows/clear-cache.yml b/.github/workflows/clear-cache.yml new file mode 100644 index 0000000..365b3bd --- /dev/null +++ b/.github/workflows/clear-cache.yml @@ -0,0 +1,26 @@ +name: "cleanup caches by a branch" +on: + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Cleanup + run: | + gh extension install actions/gh-actions-cache + echo "Fetching list of cache key" + cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) + set +e + echo "Deleting caches..." + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + done + echo "Done" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge diff --git a/.github/workflows/docker-hub-image-main.yml b/.github/workflows/docker-hub-image-main.yml index 662064d..d2171a1 100644 --- a/.github/workflows/docker-hub-image-main.yml +++ b/.github/workflows/docker-hub-image-main.yml @@ -1,19 +1,13 @@ name: Build and push docker images for main branch - -# Controls when the workflow will run on: push: branches: - 'main' - - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: permissions: contents: read -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build: - # The type of runner that the job will run on runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/tests-wazuh-docker.yml b/.github/workflows/tests.yml similarity index 51% rename from .github/workflows/tests-wazuh-docker.yml rename to .github/workflows/tests.yml index b2ada97..138a9cd 100644 --- a/.github/workflows/tests-wazuh-docker.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Test Wazuh agent dockerfiles +name: Tests on: workflow_run: @@ -20,12 +20,64 @@ permissions: pull-requests: write jobs: - pyunit-tests: + test-docker-build: + runs-on: ubuntu-latest + strategy: + max-parallel: 6 + matrix: + wazuh_agent_version: ['4.3.10-1','4.4.5-1', '4.5.4-1', '4.6.0-1', '4.7.1-1', '4.7.2-1'] + include: + - dockerfile: ./Dockerfile + image: wazuh-agent-minideb + wazuh_cluster_version: '4.7.0' + - dockerfile: ./images/Dockerfile.amazonlinux + image: wazuh-agent-amazonlinux + wazuh_cluster_version: '4.7.0' + - dockerfile: ./images/Dockerfile.ubuntu + image: wazuh-agent-ubuntu + wazuh_cluster_version: '4.7.0' - runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Cache Docker images. + uses: ScribeMD/docker-cache@0.3.7 + with: + key: docker-${{ matrix.wazuh_agent_version }} + + - name: Build and Save Wazuh Agent base image + run: | + mkdir -p ${{ github.workspace }}/docker-images/ + docker build -t ${{ matrix.image }}:${{ matrix.wazuh_agent_version }} -f ${{ matrix.dockerfile }} --build-arg AGENT_VERSION=${{ matrix.wazuh_agent_version }} . + docker pull wazuh/wazuh-manager:${{ matrix.wazuh_cluster_version }} + docker pull wazuh/wazuh-indexer:${{ matrix.wazuh_cluster_version }} + docker pull wazuh/wazuh-dashboard:${{ matrix.wazuh_cluster_version }} + + pyunit-tests: + runs-on: ubuntu-latest + needs: ["test-docker-build"] + strategy: + max-parallel: 6 + matrix: + wazuh_agent_version: ['4.3.10-1','4.4.5-1', '4.5.4-1', '4.6.0-1', '4.7.1-1', '4.7.2-1'] + include: + - image: wazuh-agent-minideb + - image: wazuh-agent-amazonlinux + - image: wazuh-agent-ubuntu steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 - name: Set up Python 3.9 uses: actions/setup-python@v3 with: @@ -40,47 +92,75 @@ jobs: run: | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Cache Docker images. uses: ScribeMD/docker-cache@0.3.7 with: - key: docker-${{ runner.os }} + key: docker-${{ matrix.wazuh_agent_version }} + - name: Test with pytest run: | - pytest -n auto -v --capture=sys -x --tb=long --junitxml=/tmp/test-results/wazuh-unittests.xml + pytest -n auto -v --capture=sys -x --tb=long --junitxml=/tmp/test-results/wazuh-unittests-${{ matrix.wazuh_agent_version }}.xml + env: + AGENT_VERSION: "${{ matrix.wazuh_agent_version }}" + - name: Upload Artifact uses: actions/upload-artifact@v3 with: name: wazuh-unittests - path: /tmp/test-results/wazuh-unittests.xml - docker-compose-tests: - needs: "pyunit-tests" + path: /tmp/test-results/wazuh-unittests-${{ matrix.wazuh_agent_version }}.xml + + integrations-tests: + needs: ["pyunit-tests"] runs-on: ubuntu-latest + strategy: + matrix: + wazuh_agent_version: ['4.3.10-1','4.4.5-1', '4.5.4-1','4.6.0-1','4.7.1-1','4.7.2-1'] + wazuh_cluster_version: ['4.7.0'] + include: + - image: wazuh-agent-minideb + - image: wazuh-agent-amazonlinux + - image: wazuh-agent-ubuntu steps: - uses: actions/checkout@v3 + - name: Set up Python 3.9 uses: actions/setup-python@v3 with: python-version: "3.9" cache: 'pip' + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Install dependencies run: | python -m pip install --upgrade pip if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi + mkdir -p ${{ github.workspace }}/docker-images/ + - name: Cache Docker images. - if: always() uses: ScribeMD/docker-cache@0.3.7 with: - key: docker-${{ runner.os }} + key: docker-${{ matrix.wazuh_agent_version }} + - name: Download artifact from build job uses: actions/download-artifact@v3 with: name: wazuh-unittests path: ${{ github.workspace }}/test-results/ + - name: Create single node certificates run: docker-compose -f tests/single-node/generate-indexer-certs.yml run --rm generator - name: Start single node stack run: docker-compose -f docker-compose.yml up -d --build + env: + AGENT_VERSION: "${{ matrix.wazuh_agent_version }}" + WAZUH_CLUSTER_VERSION: "${{ matrix.wazuh_cluster_version }}" - name: Check Wazuh indexer start run: | @@ -101,22 +181,26 @@ jobs: exit 1 fi - - name: Tests agent containers - run: pytest -v --capture=sys -x --tb=long .github/workflows/test_docker_compose.py --disable-warnings --junitxml=/tmp/test-results/wazuh-docker-compose.xml + - name: Integration test for Wazuh agent + run: pytest -v --capture=sys -x --tb=long .github/workflows/test_docker_compose.py --disable-warnings --junitxml=/tmp/test-results/wazuh-docker-compose-${{ matrix.wazuh_agent_version }}.xml + - name: Copy Test Results if: always() run: | - cp -Lpr /tmp/test-results/wazuh-docker-compose.xml ${{ github.workspace }}/test-results/wazuh-docker-compose.xml + cp -Lpr /tmp/test-results/wazuh-docker-compose-${{ matrix.wazuh_agent_version }}.xml ${{ github.workspace }}/test-results/wazuh-docker-compose-${{ matrix.wazuh_agent_version }}.xml shell: bash + - name: Check results run: | ls -R ${{ github.workspace }}/test-results/ + - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: files: | test-results/**/*.xml - - name: Stop containers + + - name: Stop containers and destroy if: always() run: docker-compose -f docker-compose.yml down diff --git a/.gitignore b/.gitignore index 0082789..7019b94 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ tmp/ wazuh_indexer_ssl_certs snyk-code.sarif .dccache +.coverage* +coverage.xml +htmlcov diff --git a/Dockerfile b/Dockerfile index d79ce77..753787d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN install_packages \ curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | apt-key add - && \ echo "deb https://packages.wazuh.com/4.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list && \ install_packages wazuh-agent=${AGENT_VERSION} && \ - echo "deb http://deb.debian.org/debian-security/ bullseye-security main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb https://deb.debian.org/debian-security/ bullseye-security main contrib non-free" >> /etc/apt/sources.list && \ mkdir -p /usr/share/man/man1 && \ install_packages openjdk-11-jdk diff --git a/Makefile b/Makefile index 580a218..771f72e 100644 --- a/Makefile +++ b/Makefile @@ -50,4 +50,7 @@ destroy: ## Destroy docker compose stack and cleanup docker compose down --remove-orphans --rmi local -v rm -rf tests/single-node/config/wazuh_indexer_ssl_certs/* test: ## Run unit tests - pytest -v -n auto --capture=sys -x --tb=long + pytest -v --cov=. --cov-report xml --cov-report html -n auto --capture=sys -x --tb=long + +gh-actions: ## Run github action locally + DOCKER_DEFAULT_PLATFORM= act --artifact-server-path=/tmp/wazuh diff --git a/README.md b/README.md index 0314e3e..6782b1f 100644 --- a/README.md +++ b/README.md @@ -40,13 +40,24 @@ This implementation offers a seamless and adaptable solution for incorporating W ## Wazuh agent version -| GitHub branch/tag | Wazuh Agent version | Docker image tag | -|-------------------|---------------------|------------------| -| main | v4.3.10 | lates | -| v4.7.1-1 | v4.7.1-1 | 4.7.1 | -| v4.6.0-1 | v4.6.0-1 | 4.6.0 | -| v4.5.4-1 | v4.5.4-1 | 4.5.4 | -| v4.4.5-1 | v4.4.5-1 | 4.4.5 | +### Braking changes + +*Wazuh agent v4.3.10* will reach its end of life (EOL) and the cessation of support on February 1, 2024. + + +>> Commencing on February 1, 2024, the main branch will incorporate the latest code. +>> +>> Exercise caution, as potential bugs may exist in this branch. It is crucial to migrate all your deployments to Docker image tags listed below for reference. + + +| GitHub branch/tag | Wazuh Agent version | EOL | Docker image tag | +|-------------------|---------------------|--------------------|------------------| +| main | v4.3.10 | v4.3.10 01.02.2024 | latest | +| v4.7.2-1 | v4.7.2-1 | LTS | 4.7.1 | +| v4.7.1-1 | v4.7.1-1 | LTS | 4.7.1 | +| v4.6.0-1 | v4.6.0-1 | LTS | 4.6.0 | +| v4.5.4-1 | v4.5.4-1 | LTS | 4.5.4 | +| v4.4.5-1 | v4.4.5-1 | LTS | 4.4.5 | ## DockerHub images diff --git a/docker-compose.yml b/docker-compose.yml index af17eae..db4afb1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,11 @@ services: build: context: . dockerfile: ./Dockerfile - image: wazuh-agent:minideb + args: + AGENT_VERSION: ${AGENT_VERSION:-4.3.10-1} + image: wazuh-agent-minideb:${AGENT_VERSION:-4.3.10-1} + volumes: + - ./register_agent.py:/var/ossec/register_agent.py hostname: wazuh-agent-minideb deploy: replicas: ${LOCAL_DEV:-1} @@ -22,7 +26,9 @@ services: build: context: . dockerfile: ./images/Dockerfile.amazonlinux - image: wazuh-agent:amazonlinux + args: + AGENT_VERSION: ${AGENT_VERSION:-4.3.10-1} + image: wazuh-agent-amazonlinux:${AGENT_VERSION:-4.3.10-1} deploy: replicas: ${AGENT_REPLICAS:-1} restart: always @@ -42,7 +48,9 @@ services: build: context: . dockerfile: ./images/Dockerfile.ubuntu - image: wazuh-agent:ubuntu + args: + AGENT_VERSION: ${AGENT_VERSION:-4.3.10-1} + image: wazuh-agent-ubuntu:${AGENT_VERSION:-4.3.10-1} deploy: replicas: ${AGENT_REPLICAS:-1} hostname: wazuh-agent-ubuntu @@ -59,7 +67,7 @@ services: - wazuh.manager - wazuh.indexer wazuh.manager: - image: wazuh/wazuh-manager:4.7.0 + image: wazuh/wazuh-manager:${WAZUH_CLUSTER_VERSION:-4.7.0} hostname: wazuh.manager restart: always ulimits: @@ -106,7 +114,7 @@ services: timeout: 10s retries: 10 wazuh.indexer: - image: wazuh/wazuh-indexer:4.7.0 + image: wazuh/wazuh-indexer:${WAZUH_CLUSTER_VERSION:-4.7.0} hostname: wazuh.indexer restart: always ports: @@ -131,7 +139,7 @@ services: - ./tests/single-node/config/wazuh_indexer/internal_users.yml:/usr/share/wazuh-indexer/opensearch-security/internal_users.yml wazuh.dashboard: - image: wazuh/wazuh-dashboard:4.7.0 + image: wazuh/wazuh-dashboard:${WAZUH_CLUSTER_VERSION:-4.7.0} hostname: wazuh.dashboard restart: always ports: diff --git a/register_agent.py b/register_agent.py old mode 100644 new mode 100755 index 960adf5..2c8551a --- a/register_agent.py +++ b/register_agent.py @@ -14,6 +14,9 @@ from http.server import BaseHTTPRequestHandler, HTTPServer import time +from requests.adapters import HTTPAdapter +from urllib3.util.retry import Retry + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) try: import requests @@ -25,10 +28,10 @@ class RequestHandler(BaseHTTPRequestHandler): - def log_message(self, format, *args): - pass + def log_message(self, *args): + raise NotImplementedError("notImplemented() cannot be performed because ...") - def do_GET(self): + def sent_request(self): message, status_code, headers = health.run() try: request_path = str(self.path).replace("\n", " ") @@ -81,14 +84,44 @@ def create_config_file(): ) +def delete_agent(agt_name): + status_code, response = wazuh_api("get", f"agents?pretty=true&q=name={agt_name}") + print(response, status_code) + for items in response["data"]["affected_items"]: + print(f"Item {items}") + status_code, response = wazuh_api( + "delete", + f"agents?pretty=true&older_than=0s&agents_list={items['id']}&status=all", + ) + msg = json.dumps(response, indent=4, sort_keys=True) + code = f"Status: {status_code} - {code_desc(status_code)}" + logger.error(f"INFO - DELETE AGENT:\n{code}\n{msg}") + status_code, response = wazuh_api( + "delete", + "agents?pretty=true&older_than=21d&agents_list=all&status=never_connected,disconnected", + ) + for items in response["data"]["affected_items"]: + status_code, response = wazuh_api( + "delete", + f"agents?pretty=true&older_than=0s&agents_list={items['id']}&status=all", + ) + msg = json.dumps(response, indent=4, sort_keys=True) + code = f"Status: {status_code} - {code_desc(status_code)}" + logger.error(f"INFO - DELETE AGENT:\n{code}\n{msg}") + + def wazuh_api(method, resource, data=None): code = None response_json = {} + session = requests.Session() + retry = Retry(connect=int(max_retry_count), backoff_factor=0.5) + adapter = HTTPAdapter(max_retries=retry) + session.mount("https://", adapter) login_headers = { "Content-Type": "application/json", "Authorization": f"Basic {b64encode(auth).decode()}", } - response = requests.get(login_url, headers=login_headers, verify=False) # nosec + response = session.get(login_url, headers=login_headers, verify=False) # nosec logger.info( f"Response code {response.status_code} response content {response.content}" ) @@ -99,22 +132,20 @@ def wazuh_api(method, resource, data=None): } url = f"{base_url}/{resource}" try: - requests.packages.urllib3.disable_warnings() - if method.lower() == "post": - response = requests.post( + response = session.post( url, headers=requests_headers, data=json.dumps(data), verify=verify ) elif method.lower() == "put": - response = requests.put( + response = session.put( url, headers=requests_headers, data=data, verify=verify ) elif method.lower() == "delete": - response = requests.delete( + response = session.delete( url, headers=requests_headers, data=data, verify=verify ) else: - response = requests.get( + response = session.get( url, headers=requests_headers, params=data, verify=verify ) @@ -139,7 +170,23 @@ def check_self(): def code_desc(http_status_code): - return requests.status_codes._codes[http_status_code][0] + return requests.status_codes.codes[http_status_code] + + +def get_agent_id(agt_name): + status_code, response = wazuh_api( + "get", f"agents?pretty=true&q=name={agt_name}&wait_for_complete=true" + ) + logger.debug(f"Response {status_code}: {response}") + for agt_status in response["data"]["affected_items"]: + try: + agn_id = agt_status["id"] + delete_agent(agt_name) + logger.info(f"Found wazuh agent with id {agn_id} try to re-use") + return agn_id + except KeyError as err: + logger.error(f"Got error while trying to get id {err}") + return None def add_agent_to_group(wazuh_agent_id, agent_group): @@ -160,37 +207,26 @@ def add_agent_to_group(wazuh_agent_id, agent_group): def add_agent(agt_name, agt_ip=None): - if agt_ip: - status_code, response = wazuh_api( - "post", - "agents/insert", - { - "name": agt_name, - "ip": agt_ip, - "force": { - "enabled": True, - "disconnected_time": {"enabled": False, "value": "0"}, - "after_registration_time": "1s", - }, - }, - ) + agt_id = get_agent_id(agt_name) + if agt_ip and agt_id: + agt_data = { + "name": str(agt_name), + "ip": agt_ip, + "id": agt_id, + } + elif agt_id: + agt_data = {"name": str(agt_name), "id": agt_id} else: - status_code, response = wazuh_api( - "post", - "agents/insert", - { - "name": str(agt_name), - "force": { - "enabled": True, - "disconnected_time": {"enabled": False, "value": "0"}, - "after_registration_time": "1s", - }, - }, - ) + agt_data = {"name": str(agt_name)} + logger.info(f"Try to add agent with data {agt_data}") + status_code, response = wazuh_api( + "post", + "agents/insert", + agt_data, + ) response_msg = http_codes_serializer(response=response, status_code=status_code) if status_code == 400: logger.error(f"During adding Wazuh agent request return {response_msg}") - pass elif status_code == 200 and response["error"] == 0: wazuh_agent_id = response["data"]["id"] wazuh_agent_key = response["data"]["key"] @@ -203,8 +239,6 @@ def add_agent(agt_name, agt_ip=None): def wazuh_agent_status(agt_name, pretty=None): - wazuh_agnt_name = None - wazuh_agnt_status = None if pretty: status_code, response = wazuh_api( "get", f"agents?pretty=true&q=name={agt_name}&wait_for_complete=true" @@ -215,11 +249,13 @@ def wazuh_agent_status(agt_name, pretty=None): ) response_msg = http_codes_serializer(response=response, status_code=status_code) if status_code == 200 and response["error"] == 0: + wazuh_agt_name = None + wazuh_agt_status = None for items in response["data"]["affected_items"]: - wazuh_agnt_name = items["name"] - wazuh_agnt_status = items["status"] + wazuh_agt_name = items["name"] + wazuh_agt_status = items["status"] logger.info(f"Wazuh agent status: {response_msg}") - return wazuh_agnt_name, wazuh_agnt_status + return wazuh_agt_name, wazuh_agt_status else: logger.error(f"Unable to get Wazuh agent status: {response_msg}") @@ -251,7 +287,7 @@ def execute(cmd_list, stdin=None): def restart_wazuh_agent(): cmd = "/var/ossec/bin/wazuh-control" - command_stdout, command_stderr, return_code = execute([cmd, "restart"]) + command_stdout, command_stderr, _ = execute([cmd, "restart"]) restarted = False for line_output in command_stdout.split(os.linesep): @@ -282,7 +318,7 @@ def restart_wazuh_agent(): "JOIN_MANAGER_WORKER_HOST", default="wazuh-workers.wazuh.svc.cluster.local" ) wait_time = os.environ.get("WAZUH_WAIT_TIME", default="10") - flask_bind = os.environ.get("FLASK_BIND", default="0.0.0.0") + max_retry_count = os.environ.get("MAX_RETRY_COUNT", default=10) if not node_name: node_name = os.environ.get("HOSTNAME") login_endpoint = "security/user/authenticate" @@ -310,9 +346,7 @@ def restart_wazuh_agent(): f"Waiting for Wazuh agent {agent_name} become ready current status is {agent_status}......" ) time.sleep(int(wait_time)) - if groups == "default": - pass - else: + if groups != "default": for group in list(groups.split(",")): add_agent_to_group(agent_id, group) logger.info("Listening on 0.0.0.0:5000") diff --git a/requirements-dev.txt b/requirements-dev.txt index 43a0c83..a889da9 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -9,4 +9,5 @@ pytest==7.4.4 pytest-testinfra==10.0.0 black==24.2.0 argparse==1.4.0 -pytest-xdist +pytest-xdist==3.5.0 +pytest-cov diff --git a/tests/amazonlinux/conftest.py b/tests/amazonlinux/conftest.py index e77c450..b87b222 100644 --- a/tests/amazonlinux/conftest.py +++ b/tests/amazonlinux/conftest.py @@ -5,8 +5,9 @@ import os root_dir = os.path.abspath(os.curdir) -base_image = os.getenv("IMAGE_NAME", "wazuh-agent:amazonlinux") +base_image = os.getenv("IMAGE_NAME", "wazuh-agent-amazonlinux") docker_file = os.getenv("DOCKERFILE", "images/Dockerfile.amazonlinux") +wazuh_agent_version = os.getenv("AGENT_VERSION", "4.3.10-1") @pytest.fixture(scope="session") @@ -20,6 +21,8 @@ def host(request): f"{base_image}", "-f", docker_file, + "--build-arg", + f"AGENT_VERSION={wazuh_agent_version}", root_dir, ] ) diff --git a/tests/minideb/conftest.py b/tests/minideb/conftest.py index 7e47562..42e69b1 100644 --- a/tests/minideb/conftest.py +++ b/tests/minideb/conftest.py @@ -5,8 +5,9 @@ import os root_dir = os.path.abspath(os.curdir) -base_image = os.getenv("IMAGE_NAME", "wazuh-agent:minideb") +base_image = os.getenv("IMAGE_NAME", "wazuh-agent-minideb") docker_file = os.getenv("DOCKERFILE", "Dockerfile") +wazuh_agent_version = os.getenv("AGENT_VERSION", "4.3.10-1") @pytest.fixture(scope="session") @@ -20,6 +21,8 @@ def host(request): f"{base_image}", "-f", docker_file, + "--build-arg", + f"AGENT_VERSION={wazuh_agent_version}", root_dir, ] ) diff --git a/tests/ubuntu/conftest.py b/tests/ubuntu/conftest.py index 7edd580..8d40738 100644 --- a/tests/ubuntu/conftest.py +++ b/tests/ubuntu/conftest.py @@ -5,8 +5,9 @@ import os root_dir = os.path.abspath(os.curdir) -base_image = os.getenv("IMAGE_NAME", "wazuh-agent:ubuntu") +base_image = os.getenv("IMAGE_NAME", "wazuh-agent-ubuntu") docker_file = os.getenv("DOCKERFILE", "images/Dockerfile.ubuntu") +wazuh_agent_version = os.getenv("AGENT_VERSION", "4.3.10-1") @pytest.fixture(scope="session") @@ -20,6 +21,8 @@ def host(request): f"{base_image}", "-f", docker_file, + "--build-arg", + f"AGENT_VERSION={wazuh_agent_version}", root_dir, ] )