Fix WF docker images vulnerabilities

This commit is contained in:
fcaffieri
2026-06-05 17:30:02 -03:00
parent 0a25b40745
commit 77c66b89b7
@@ -115,9 +115,13 @@ jobs:
- name: Set up variables - name: Set up variables
id: compute-outputs id: compute-outputs
env:
PRODUCTS_INPUT: ${{ inputs.products }}
DEV_INPUT: ${{ inputs.dev }}
COMMIT_LIST_INPUT: ${{ inputs.commit_list }}
run: | run: |
# Use the default list if products is empty # Use the default list if products is empty
PRODUCTS="${{ inputs.products }}" PRODUCTS="$PRODUCTS_INPUT"
if [[ -z "$PRODUCTS" || "$PRODUCTS" == "null" ]]; then if [[ -z "$PRODUCTS" || "$PRODUCTS" == "null" ]]; then
PRODUCTS="wazuh-manager,wazuh-dashboard,wazuh-indexer,wazuh-agent" PRODUCTS="wazuh-manager,wazuh-dashboard,wazuh-indexer,wazuh-agent"
fi fi
@@ -135,9 +139,9 @@ jobs:
# Set COMMIT_LIST # Set COMMIT_LIST
WC_COMMIT_LIST="" WC_COMMIT_LIST=""
if [[ "${{ inputs.dev }}" == "true" ]]; then if [[ "$DEV_INPUT" == "true" ]]; then
if [[ "${{ inputs.commit_list }}" != "null" && "${{ inputs.commit_list }}" != "" ]]; then if [[ "$COMMIT_LIST_INPUT" != "null" && "$COMMIT_LIST_INPUT" != "" ]]; then
WC_COMMIT_LIST='${{ inputs.commit_list }}' WC_COMMIT_LIST="$COMMIT_LIST_INPUT"
else else
# Set commit list to "latest" for all components using WAZUH_COMPONENTS # Set commit list to "latest" for all components using WAZUH_COMPONENTS
COMPONENTS=($(echo "$WC_JSON_ARRAY" | jq -r '.[]')) COMPONENTS=($(echo "$WC_JSON_ARRAY" | jq -r '.[]'))
@@ -174,6 +178,7 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ inputs.docker_reference }} ref: ${{ inputs.docker_reference }}
persist-credentials: false
- name: Checkout wazuh/wazuh-automation repository - name: Checkout wazuh/wazuh-automation repository
if: ${{ inputs.dev == true }} if: ${{ inputs.dev == true }}
@@ -183,6 +188,7 @@ jobs:
ref: ${{ inputs.wazuh_automation_reference }} ref: ${{ inputs.wazuh_automation_reference }}
token: ${{ secrets.GH_CLONE_TOKEN }} token: ${{ secrets.GH_CLONE_TOKEN }}
path: wazuh-automation path: wazuh-automation
persist-credentials: false
- name: Configure AWS credentials - name: Configure AWS credentials
if: ${{ inputs.dev == true }} if: ${{ inputs.dev == true }}
@@ -215,11 +221,15 @@ jobs:
if: ${{ inputs.dev == true }} if: ${{ inputs.dev == true }}
run: | run: |
WAZUH_VERSION=$(jq -r '.version' VERSION.json) WAZUH_VERSION=$(jq -r '.version' VERSION.json)
if ! [[ "$WAZUH_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format: $WAZUH_VERSION"
exit 1
fi
WAZUH_MAJOR=$(echo "$WAZUH_VERSION" | cut -d '.' -f 1) WAZUH_MAJOR=$(echo "$WAZUH_VERSION" | cut -d '.' -f 1)
WAZUH_MINOR=$(echo "$WAZUH_VERSION" | cut -d '.' -f 1-2) WAZUH_MINOR=$(echo "$WAZUH_VERSION" | cut -d '.' -f 1-2)
echo WAZUH_VERSION=$WAZUH_VERSION >> $GITHUB_ENV echo "WAZUH_VERSION=$WAZUH_VERSION" >> $GITHUB_ENV
echo WAZUH_MAJOR=$WAZUH_MAJOR >> $GITHUB_ENV echo "WAZUH_MAJOR=$WAZUH_MAJOR" >> $GITHUB_ENV
echo WAZUH_MINOR=$WAZUH_MINOR >> $GITHUB_ENV echo "WAZUH_MINOR=$WAZUH_MINOR" >> $GITHUB_ENV
- name: Get artifacts URLs file - name: Get artifacts URLs file
if: ${{ inputs.dev == true }} if: ${{ inputs.dev == true }}
@@ -229,13 +239,14 @@ jobs:
- name: Generate presigned URLs for artifacts for dev packages - name: Generate presigned URLs for artifacts for dev packages
if: ${{ inputs.dev == true }} if: ${{ inputs.dev == true }}
env:
WAZUH_COMPONENTS: ${{ needs.setup.outputs.WAZUH_COMPONENTS }}
COMMIT_LIST: ${{ needs.setup.outputs.COMMIT_LIST }}
run: | run: |
source ${{ env.WORKFLOW_VENV }}/bin/activate source "$WORKFLOW_VENV/bin/activate"
WAZUH_COMPONENTS='${{ needs.setup.outputs.WAZUH_COMPONENTS }}' SCRIPT_PARAMS="--process $PRESIGNED_URLS_SCRIPT_PROCESS \
COMMIT_LIST='${{ needs.setup.outputs.COMMIT_LIST }}' --wazuh-version $WAZUH_VERSION \
SCRIPT_PARAMS="--process ${{ env.PRESIGNED_URLS_SCRIPT_PROCESS }} \ --aws-s3-bucket-dev $LOCAL_AWS_S3_BUCKET_DEV \
--wazuh-version ${{ env.WAZUH_VERSION }} \
--aws-s3-bucket-dev ${{ env.LOCAL_AWS_S3_BUCKET_DEV }} \
--assistant-revision $ASSISTANT_REVISION " --assistant-revision $ASSISTANT_REVISION "
@@ -270,7 +281,7 @@ jobs:
esac esac
done done
python ${{ env.GENERATE_PRESIGNED_URLS_SCRIPT_PATH }} \ python "$GENERATE_PRESIGNED_URLS_SCRIPT_PATH" \
$SCRIPT_PARAMS $SCRIPT_PARAMS
- name: Save presigned URLs file to artifact - name: Save presigned URLs file to artifact
@@ -302,6 +313,7 @@ jobs:
uses: actions/checkout@v6 uses: actions/checkout@v6
with: with:
ref: ${{ inputs.docker_reference }} ref: ${{ inputs.docker_reference }}
persist-credentials: false
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v4 uses: docker/setup-qemu-action@v4
@@ -336,11 +348,11 @@ jobs:
- name: Compute component reference (dev) - name: Compute component reference (dev)
if: ${{ inputs.dev == true }} if: ${{ inputs.dev == true }}
env:
COMPONENT: ${{ matrix.wazuh_component }}
WAZUH_COMPONENTS: ${{ needs.setup.outputs.WAZUH_COMPONENTS }}
COMMIT_LIST: ${{ needs.setup.outputs.COMMIT_LIST }}
run: | run: |
COMPONENT='${{ matrix.wazuh_component }}'
WAZUH_COMPONENTS='${{ needs.setup.outputs.WAZUH_COMPONENTS }}'
COMMIT_LIST='${{ needs.setup.outputs.COMMIT_LIST }}'
idx=$(jq -r --arg c "$COMPONENT" 'index($c)' <<<"$WAZUH_COMPONENTS") idx=$(jq -r --arg c "$COMPONENT" 'index($c)' <<<"$WAZUH_COMPONENTS")
ref=$(jq -r --argjson i "$idx" '.[ $i ]' <<<"$COMMIT_LIST") ref=$(jq -r --argjson i "$idx" '.[ $i ]' <<<"$COMMIT_LIST")
@@ -348,6 +360,9 @@ jobs:
echo "Using component ref for $COMPONENT: $ref" echo "Using component ref for $COMPONENT: $ref"
- name: Build Wazuh images - name: Build Wazuh images
env:
DEV: ${{ inputs.dev }}
WAZUH_COMPONENT: ${{ matrix.wazuh_component }}
run: | run: |
if [[ "$IMAGE_TAG" == *"-"* ]]; then if [[ "$IMAGE_TAG" == *"-"* ]]; then
IFS='-' read -r -a tokens <<< "$IMAGE_TAG" IFS='-' read -r -a tokens <<< "$IMAGE_TAG"
@@ -357,7 +372,7 @@ jobs:
fi fi
DEV_STAGE=${tokens[1]} DEV_STAGE=${tokens[1]}
WAZUH_VER=${tokens[0]} WAZUH_VER=${tokens[0]}
if [ "${{ inputs.dev }}" = true ]; then if [ "$DEV" = true ]; then
./build-images.sh \ ./build-images.sh \
-v $WAZUH_VER \ -v $WAZUH_VER \
-d $DEV_STAGE \ -d $DEV_STAGE \
@@ -365,30 +380,30 @@ jobs:
-m \ -m \
--dev \ --dev \
-refs "$COMPONENT_REFS_JSON" \ -refs "$COMPONENT_REFS_JSON" \
-c ${{ matrix.wazuh_component }} -c $WAZUH_COMPONENT
else else
./build-images.sh \ ./build-images.sh \
-v $WAZUH_VER \ -v $WAZUH_VER \
-d $DEV_STAGE \ -d $DEV_STAGE \
-rg $IMAGE_REGISTRY \ -rg $IMAGE_REGISTRY \
-m \ -m \
-c ${{ matrix.wazuh_component }} -c $WAZUH_COMPONENT
fi fi
else else
if [ "${{ inputs.dev }}" = true ]; then if [ "$DEV" = true ]; then
./build-images.sh \ ./build-images.sh \
-v $IMAGE_TAG \ -v $IMAGE_TAG \
-rg $IMAGE_REGISTRY \ -rg $IMAGE_REGISTRY \
-m \ -m \
--dev \ --dev \
-refs "$COMPONENT_REFS_JSON" \ -refs "$COMPONENT_REFS_JSON" \
-c ${{ matrix.wazuh_component }} -c $WAZUH_COMPONENT
else else
./build-images.sh \ ./build-images.sh \
-v $IMAGE_TAG \ -v $IMAGE_TAG \
-rg $IMAGE_REGISTRY \ -rg $IMAGE_REGISTRY \
-m \ -m \
-c ${{ matrix.wazuh_component }} -c $WAZUH_COMPONENT
fi fi
fi fi
# Save .env file (generated by build-images.sh) contents to $GITHUB_ENV # Save .env file (generated by build-images.sh) contents to $GITHUB_ENV
@@ -414,9 +429,10 @@ jobs:
steps: steps:
- name: Image exists validation - name: Image exists validation
id: validation id: validation
env:
IMAGE_TAG: ${{ inputs.image_tag }}
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY_PROD }}
run: | run: |
IMAGE_TAG=${{ inputs.image_tag }}
IMAGE_REGISTRY="${{ vars.IMAGE_REGISTRY_PROD }}"
PURPOSE="" PURPOSE=""
if [[ "$IMAGE_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then if [[ "$IMAGE_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
@@ -441,9 +457,9 @@ jobs:
if: ${{ steps.validation.outputs.purpose != '' }} if: ${{ steps.validation.outputs.purpose != '' }}
env: env:
GH_TOKEN: ${{ secrets.NOTIFICATION_GH_ARTIFACT_TOKEN }} GH_TOKEN: ${{ secrets.NOTIFICATION_GH_ARTIFACT_TOKEN }}
IMAGE_TAG: ${{ inputs.image_tag }}
PURPOSE: ${{ steps.validation.outputs.purpose }}
run: | run: |
IMAGE_TAG=${{ inputs.image_tag }}
PURPOSE="${{ steps.validation.outputs.purpose }}"
GH_TITLE="" GH_TITLE=""
GH_MESSAGE="" GH_MESSAGE=""