From 760cc17f47934be594ea47a3dadc6f7179f1d23a Mon Sep 17 00:00:00 2001 From: Guido Modarelli <38738725+guidomodarelli@users.noreply.github.com> Date: Wed, 13 Nov 2024 07:38:25 -0300 Subject: [PATCH 1/8] Update the actions' version (#7142) * feat: integrate ButtonExploreAgent component into MainModuleAgent for enhanced agent interaction and updated layout consistency * feat: add pinned agent mechanic across all pages for improved consistency in functionality and user experience * feat: enhance ButtonPinnedAgent with clsx for dynamic class management and improved background styling * refactor: clean up agent selector styles by removing unnecessary focus and hover states for better maintainability * refactor: update WzButtonProps type to include EUI component properties for better flexibility and maintainability * refactor: improve ButtonPinnedAgent structure by adding data-test attribute and simplifying JSX for cleaner code readability * test: add tests for explore agent button rendering in various agent tabs for improved coverage and verification of UI functionality * test: add tests for explore agent button rendering in various agent tabs for improved coverage and verification of UI functionality refactor: enhance MainModuleAgent layout by adding margin and padding styles to EuiFlexItems for improved UI consistency * refactor: add newline in ButtonPinnedAgent for improved readability and code consistency in explore agent button component * chore: update CHANGELOG to clarify pinned agent mechanic in inventory, stats, and configuration for consistency across pages * refactor: add unPinAgent functionality to agent components for enhanced user interaction and UI consistency across agent views * refactor: remove unused EuiButtonEmpty import for cleaner code in configuration overview component * refactor: update useGenericRequest hook for improved type safety and cleaner data handling in API requests * refactor: enhance type safety in InventoryMetrics and streamline API request handling with updated useGenericRequest usage * refactor: rename ErrorOrchestratorService to ErrorService for improved clarity and type safety in error handling logic * refactor: add JSDoc comments to GenericRequest for improved type safety and better documentation of request parameters * refactor: improve cluster handling logic and error management in WzConfigurationSwitch for better state management and readability * refactor: streamline AgentStats component with improved type safety and error handling for enhanced clarity and maintainability * Fix Prettier issue * refactor: update test descriptions in MainModuleAgent tests to clarify the "Pinned Agent" button functionality across tabs * refactor: remove deprecated Route for syscollector in AgentView to clean up component structure and improve readability * refactor: rename PartialRecordMock to DeepPartialRecordMock for better clarity and maintainability in type definitions * feat: add mock agent data for Debian, Windows, and Darwin to enhance testing and provide a comprehensive environment setup * refactor: replace inline AGENT mock with import from test mocks for improved test organization and maintainability * test: add API call verification in AgentStats tests to ensure correct fetching of agent stats during component rendering * test: enhance AgentStats tests to verify API calls with correct agent IDs and endpoints on component updates * test: refine AgentStats test description to clarify API call behavior when switching agents * test: improve AgentStats tests to ensure correct column structure, titles, and CSV filename updates on rendering changes * refactor: update breadcrumb types in useGlobalBreadcrumb for improved type safety and readability in context management * refactor: enhance withGlobalBreadcrumb HOC for better type handling and maintainability in breadcrumb logic * refactor: replace hardcoded path in agent stats breadcrumb with SECTIONS constant for improved maintainability and readability * refactor: replace hardcoded agents-preview path with SECTIONS constant for improved maintainability and readability in configuration-main.js * refactor: improve agent handling in withGlobalBreadcrumb for better maintainability and readability in configuration-main.js * refactor: add global breadcrumb support in AgentView for better navigation and maintainability in index.tsx * refactor: update unPinAgent to navigate with new URL structure for improved navigation in index.tsx * refactor: add withGlobalBreadcrumb HOC to enhance navigation structure in agent index.tsx * refactor: enhance AgentStats tests with clearer descriptions for column structure and title checks amidst agent changes * refactor: replace jQuery with native DOM method for setting title attribute in breadcrumb configuration component * refactor: improve syscollector metrics tests by adding agent ID handling and verifying data fetching for different agents * refactor: add unit test for SoftwareTab rendering WindowsUpdatesTable on Windows platform in syscollector agent component * refactor: add unit test for WindowsUpdatesTable to verify correct hotfixes endpoint when changing agents in syscollector component * refactor: fix endpoint string in WindowsUpdatesTable test for accurate hotfixes URL when changing agents in syscollector component * refactor: enhance WindowsUpdatesTable test to validate API requests for different agent IDs in syscollector component * refactor: handle potential undefined values in packages-table component for safer access to sorting fields when rendering table * test: add test suite for PackagesTable to validate API requests and table rendering for different agent IDs in syscollector component * refactor: safeguard against undefined values for sorting fields in multiple syscollector table components during rendering * test: add test suite for NetworkInterfacesTable to verify API requests and rendering behavior for changing agent IDs * test: update test descriptions in PackagesTable and WindowsUpdatesTable for clarity on data being fetched for given agent IDs * test: add tests for NetworkPortsTable to verify correct API requests and rendering behavior for different agent IDs * test: rename test suite to NetworkPortsTable for clarity and proper context in related API request tests * test: add NetworkSettingsTable tests to ensure correct rendering and API requests for changing agent IDs * test: add tests for ProcessesTable to validate rendering and API requests when switching between agent IDs * fix: improve optional chaining to direct access for initial sorting fields in network tables for better readability * test: introduce reusable functions for validating agent API requests and endpoint rendering in various system collector tables * ci: update GitHub Actions workflows to use actions/upload-artifact@v4 and clean up formatting across YAML files * ci: upgrade actions/checkout to v4 across multiple workflows for consistency and improved features * ci: upgrade Node.js setup to actions/setup-node@v4 in eslint and prettier workflows for enhanced performance and consistency * ci: update manual-build workflow to use actions/download-artifact@v4 for improved functionality and consistency with other workflows * ci: upgrade actions/dependency-review-action to v4 for enhanced functionality and consistency in dependency review process * ci: add overwrite option in Cypress report workflows for improved file handling and consistency across all test configurations * ci: standardize YAML formatting in workflows for better readability and consistency across all templates and steps --------- Co-authored-by: Federico Rodriguez --- .../actions/comment-test-coverage/README.md | 2 +- .github/workflows/codeql.yml | 61 ++++--- .github/workflows/cypress-basic.yml | 164 ++++++++--------- .github/workflows/cypress-odfe.yml | 170 +++++++++--------- .github/workflows/cypress-wzd.yml | 164 ++++++++--------- .github/workflows/cypress-xpack.yml | 166 ++++++++--------- .github/workflows/dependency-review.yml | 4 +- .github/workflows/dev-environment.yml | 5 +- .github/workflows/eslint.yml | 4 +- .github/workflows/manual-build.yml | 5 +- .github/workflows/prettier.yml | 4 +- .../wazuh-build-push-docker-action.yml | 6 +- 12 files changed, 382 insertions(+), 373 deletions(-) diff --git a/.github/actions/comment-test-coverage/README.md b/.github/actions/comment-test-coverage/README.md index e86b5f2238..b20a220ab1 100644 --- a/.github/actions/comment-test-coverage/README.md +++ b/.github/actions/comment-test-coverage/README.md @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Run Jasmine tests run: npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0b144db595..d6623591c4 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,11 +9,11 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: 'CodeQL' on: schedule: - - cron: '0 8 * * *' + - cron: '0 8 * * *' workflow_dispatch: jobs: @@ -28,45 +28,44 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'javascript' ] + language: ['javascript'] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Use only 'java' to analyze code written in Java, Kotlin or both # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v4 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: '/language:${{matrix.language}}' diff --git a/.github/workflows/cypress-basic.yml b/.github/workflows/cypress-basic.yml index e0465d7e2c..d8c6725c5e 100644 --- a/.github/workflows/cypress-basic.yml +++ b/.github/workflows/cypress-basic.yml @@ -12,18 +12,18 @@ on: description: 'Wazuh Version' default: 'v4.3.4' required: true - elastic-version: + elastic-version: description: 'Elastic Version' default: '7.16.3' required: true - ubuntu-cypress-version: + ubuntu-cypress-version: description: 'Ubuntu Cypress Version' default: '3.0.0' required: true url-package: description: 'Package Download Url' - required: false - default: 'https://packages-dev.wazuh.com/pre-release/ui/kibana/wazuh_kibana-4.3.4_7.16.3-1.zip' + required: false + default: 'https://packages-dev.wazuh.com/pre-release/ui/kibana/wazuh_kibana-4.3.4_7.16.3-1.zip' # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -31,83 +31,85 @@ jobs: name: Run setup environment wazuh kibana app runs-on: ubuntu-latest steps: - - name: Step 01 - Set up environment variables - run: | - echo "PATH_TEMPLATE=$GITHUB_WORKSPACE/wazuh-app-environments/templates_elastic_prod/es_basic-wz_cluster-agent/" >> $GITHUB_ENV + - name: Step 01 - Set up environment variables + run: | + echo "PATH_TEMPLATE=$GITHUB_WORKSPACE/wazuh-app-environments/templates_elastic_prod/es_basic-wz_cluster-agent/" >> $GITHUB_ENV - echo "Information about the workflow (basic): - wazuh-version: ${{ github.event.inputs.wazuh-version }} - elastic-version: ${{ github.event.inputs.elastic-version }} - ubuntu-cypress-version: ${{ github.event.inputs.ubuntu-cypress-version }} - url-package: ${{ github.event.inputs.url-package }}" - - - name: Step 02 - Download Project wazuh-app-environments - uses: actions/checkout@v2 - with: - repository: matiasmoreno876/wazuh-app-environments - ref: 'master' - path: wazuh-app-environments - token: ${{ secrets.FE_SECRET_TOKEN }} - - name: Step 03 - Configuring templates docker environment - run: | - cd $GITHUB_WORKSPACE/wazuh-app-environments/ - mkdir packages - cd ${{ env.PATH_TEMPLATE }} - sed -i -e 's|WAZUH_VERSION=.*|WAZUH_VERSION=${{ github.event.inputs.wazuh-version }}|g' ./.env - sed -i -e 's|ELASTIC_VERSION=.*|ELASTIC_VERSION=${{ github.event.inputs.elastic-version }}|g' ./.env - sed -i -e 's|UBUNTU_CYPRESS_VERSION=.*|UBUNTU_CYPRESS_VERSION=${{ github.event.inputs.ubuntu-cypress-version }}|g' ./.env - cat .env - - name: Step 04 - Starting containers - run: | - cd ${{ env.PATH_TEMPLATE }} - docker-compose up -d - echo CONTINUES AFTER 15 SECONDS ... - sleep 15s - - name: Step 05 - Installing package from url - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q kibana) bin/kibana-plugin install ${{ github.event.inputs.url-package }} - docker-compose restart kibana - echo CONTINUES AFTER 60 SECONDS ... - sleep 60s - docker-compose ps - - name: Step 06 - Configuring ip container into wazuh.yml - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q kibana) sed -i -e "s/url: https:\/\/localhost/url: https:\/\/wazuh-manager-master/g" /usr/share/kibana/data/wazuh/config/wazuh.yml - docker exec $(docker-compose ps -q kibana) cat /usr/share/kibana/data/wazuh/config/wazuh.yml - - name: Step 07 - Run Cypress tests - id: run-cypress-test - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:run-headless:github-actions:basic" | tee cypress.log - continue-on-error: true - - name: Step 08 - Run Cypress reports - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:report" - - name: Step 09 - Archive reports - uses: actions/upload-artifact@v2 - with: - name: cypress-reports_BASIC_${{ github.event.inputs.wazuh-version }}-${{ github.event.inputs.elastic-version }} - path: ${{ env.PATH_TEMPLATE }}/report/* - - name: Step 10 - Log parsing - run: | - cd ${{ env.PATH_TEMPLATE }} - echo "TEST_SKIPPED=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF)}')" >> $GITHUB_ENV - echo "TEST_PENDING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-1)}')" >> $GITHUB_ENV - echo "TEST_FAILING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-2)}')" >> $GITHUB_ENV - echo "TEST_PASSING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-3)}')" >> $GITHUB_ENV - echo "TEST_TOTAL=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-4)}')" >> $GITHUB_ENV - echo "TEST_TIME=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-5)}')" >> $GITHUB_ENV - - name: Step 11 - Post to a Slack channel - id: slack - uses: slackapi/slack-github-action@v1.19.0 - with: + echo "Information about the workflow (basic): + wazuh-version: ${{ github.event.inputs.wazuh-version }} + elastic-version: ${{ github.event.inputs.elastic-version }} + ubuntu-cypress-version: ${{ github.event.inputs.ubuntu-cypress-version }} + url-package: ${{ github.event.inputs.url-package }}" + + - name: Step 02 - Download Project wazuh-app-environments + uses: actions/checkout@v4 + with: + repository: matiasmoreno876/wazuh-app-environments + ref: 'master' + path: wazuh-app-environments + token: ${{ secrets.FE_SECRET_TOKEN }} + - name: Step 03 - Configuring templates docker environment + run: | + cd $GITHUB_WORKSPACE/wazuh-app-environments/ + mkdir packages + cd ${{ env.PATH_TEMPLATE }} + sed -i -e 's|WAZUH_VERSION=.*|WAZUH_VERSION=${{ github.event.inputs.wazuh-version }}|g' ./.env + sed -i -e 's|ELASTIC_VERSION=.*|ELASTIC_VERSION=${{ github.event.inputs.elastic-version }}|g' ./.env + sed -i -e 's|UBUNTU_CYPRESS_VERSION=.*|UBUNTU_CYPRESS_VERSION=${{ github.event.inputs.ubuntu-cypress-version }}|g' ./.env + cat .env + - name: Step 04 - Starting containers + run: | + cd ${{ env.PATH_TEMPLATE }} + docker-compose up -d + echo CONTINUES AFTER 15 SECONDS ... + sleep 15s + - name: Step 05 - Installing package from url + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q kibana) bin/kibana-plugin install ${{ github.event.inputs.url-package }} + docker-compose restart kibana + echo CONTINUES AFTER 60 SECONDS ... + sleep 60s + docker-compose ps + - name: Step 06 - Configuring ip container into wazuh.yml + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q kibana) sed -i -e "s/url: https:\/\/localhost/url: https:\/\/wazuh-manager-master/g" /usr/share/kibana/data/wazuh/config/wazuh.yml + docker exec $(docker-compose ps -q kibana) cat /usr/share/kibana/data/wazuh/config/wazuh.yml + - name: Step 07 - Run Cypress tests + id: run-cypress-test + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:run-headless:github-actions:basic" | tee cypress.log + continue-on-error: true + - name: Step 08 - Run Cypress reports + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:report" + - name: Step 09 - Archive reports + uses: actions/upload-artifact@v4 + with: + name: cypress-reports_BASIC_${{ github.event.inputs.wazuh-version }}-${{ github.event.inputs.elastic-version }} + path: ${{ env.PATH_TEMPLATE }}/report/* + overwrite: true + - name: Step 10 - Log parsing + run: | + cd ${{ env.PATH_TEMPLATE }} + echo "TEST_SKIPPED=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF)}')" >> $GITHUB_ENV + echo "TEST_PENDING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-1)}')" >> $GITHUB_ENV + echo "TEST_FAILING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-2)}')" >> $GITHUB_ENV + echo "TEST_PASSING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-3)}')" >> $GITHUB_ENV + echo "TEST_TOTAL=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-4)}')" >> $GITHUB_ENV + echo "TEST_TIME=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-5)}')" >> $GITHUB_ENV + - name: Step 11 - Post to a Slack channel + id: slack + uses: slackapi/slack-github-action@v1.19.0 + with: # Slack channel id, channel name, or user id to post message. # See also: https://api.slack.com/methods/chat.postMessage#channels - channel-id: ${{ secrets.SLACK_CHANNEL_ID }} - # For posting a simple plain text message - slack-message: "The following workflow was executed: ${{ github.workflow }}\nWazuh version: ${{ github.event.inputs.wazuh-version }}\nElastic version: ${{ github.event.inputs.elastic-version }}\nUbuntu Cypress version: ${{ github.event.inputs.ubuntu-cypress-version }}\nPackage used: ${{ github.event.inputs.url-package }}\n\nTest summary:\n\tTotal Test: ${{ env.TEST_TOTAL }}\n\tPassing: ${{ env.TEST_PASSING }}\n\tFailing: ${{ env.TEST_FAILING }}\n\tPending: ${{ env.TEST_PENDING }}\n\tSkipped: ${{ env.TEST_SKIPPED }}\n\tTotal Time: ${{ env.TEST_TIME }}\n\nFor more information visit: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - env: - SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_TOKEN }} \ No newline at end of file + channel-id: + ${{ secrets.SLACK_CHANNEL_ID }} + # For posting a simple plain text message + slack-message: "The following workflow was executed: ${{ github.workflow }}\nWazuh version: ${{ github.event.inputs.wazuh-version }}\nElastic version: ${{ github.event.inputs.elastic-version }}\nUbuntu Cypress version: ${{ github.event.inputs.ubuntu-cypress-version }}\nPackage used: ${{ github.event.inputs.url-package }}\n\nTest summary:\n\tTotal Test: ${{ env.TEST_TOTAL }}\n\tPassing: ${{ env.TEST_PASSING }}\n\tFailing: ${{ env.TEST_FAILING }}\n\tPending: ${{ env.TEST_PENDING }}\n\tSkipped: ${{ env.TEST_SKIPPED }}\n\tTotal Time: ${{ env.TEST_TIME }}\n\nFor more information visit: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + env: + SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_TOKEN }} diff --git a/.github/workflows/cypress-odfe.yml b/.github/workflows/cypress-odfe.yml index e95263a91a..241c8e9cd1 100644 --- a/.github/workflows/cypress-odfe.yml +++ b/.github/workflows/cypress-odfe.yml @@ -12,22 +12,22 @@ on: description: 'Wazuh Version' default: 'v4.3.4' required: true - elastic-version: + elastic-version: description: 'Elastic Version' default: '7.10.2' required: true - odfe-version: + odfe-version: description: 'ODFE Version' default: '1.13.2' required: true - ubuntu-cypress-version: + ubuntu-cypress-version: description: 'Ubuntu Cypress Version' default: '3.0.0' required: true url-package: description: 'Package Download Url' - required: false - default: 'https://packages-dev.wazuh.com/pre-release/ui/kibana/wazuh_kibana-4.3.4_7.16.3-1.zip' + required: false + default: 'https://packages-dev.wazuh.com/pre-release/ui/kibana/wazuh_kibana-4.3.4_7.16.3-1.zip' # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -35,85 +35,87 @@ jobs: name: Run setup environment wazuh kibana app runs-on: ubuntu-latest steps: - - name: Step 01 - Set up environment variables - run: | - echo "PATH_TEMPLATE=$GITHUB_WORKSPACE/wazuh-app-environments/templates_elastic_prod/es_odfe-wz_cluster-agent/" >> $GITHUB_ENV + - name: Step 01 - Set up environment variables + run: | + echo "PATH_TEMPLATE=$GITHUB_WORKSPACE/wazuh-app-environments/templates_elastic_prod/es_odfe-wz_cluster-agent/" >> $GITHUB_ENV - echo "Information about the workflow (odfe): - wazuh-version: ${{ github.event.inputs.wazuh-version }} - elastic-version: ${{ github.event.inputs.elastic-version }} - odfe-version: ${{ github.event.inputs.odfe-version }} - ubuntu-cypress-version: ${{ github.event.inputs.ubuntu-cypress-version }} - url-package: ${{ github.event.inputs.url-package }}" - - - name: Step 02 - Download Project wazuh-app-environments - uses: actions/checkout@v2 - with: - repository: matiasmoreno876/wazuh-app-environments - ref: 'master' - path: wazuh-app-environments - token: ${{ secrets.FE_SECRET_TOKEN }} - - name: Step 03 - Configuring templates docker environment - run: | - cd $GITHUB_WORKSPACE/wazuh-app-environments/ - mkdir packages - cd ${{ env.PATH_TEMPLATE }} - sed -i -e 's|WAZUH_VERSION=.*|WAZUH_VERSION=${{ github.event.inputs.wazuh-version }}|g' ./.env - sed -i -e 's|ELASTIC_VERSION=.*|ELASTIC_VERSION=${{ github.event.inputs.elastic-version }}|g' ./.env - sed -i -e 's|ODFE_VERSION=.*|ODFE_VERSION=${{ github.event.inputs.odfe-version }}|g' ./.env - sed -i -e 's|UBUNTU_CYPRESS_VERSION=.*|UBUNTU_CYPRESS_VERSION=${{ github.event.inputs.ubuntu-cypress-version }}|g' ./.env - cat .env - - name: Step 04 - Starting containers - run: | - cd ${{ env.PATH_TEMPLATE }} - docker-compose up -d - echo CONTINUES AFTER 15 SECONDS ... - sleep 15s - - name: Step 05 - Installing package from url - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q kibana) bin/kibana-plugin install ${{ github.event.inputs.url-package }} - docker-compose restart kibana - echo CONTINUES AFTER 60 SECONDS ... - sleep 60s - docker-compose ps - - name: Step 06 - Configuring ip container into wazuh.yml - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q kibana) sed -i -e "s/url: https:\/\/localhost/url: https:\/\/wazuh-manager-master/g" /usr/share/kibana/data/wazuh/config/wazuh.yml - docker exec $(docker-compose ps -q kibana) cat /usr/share/kibana/data/wazuh/config/wazuh.yml - - name: Step 07 - Run Cypress tests - id: run-cypress-test - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:run-headless:github-actions:odfe" | tee cypress.log - continue-on-error: true - - name: Step 08 - Run Cypress reports - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:report" - - name: Step 09 - Archive reports - uses: actions/upload-artifact@v2 - with: - name: cypress-reports_ODFE_${{ github.event.inputs.wazuh-version }}-${{ github.event.inputs.odfe-version }}-${{ github.event.inputs.elastic-version }} - path: ${{ env.PATH_TEMPLATE }}/report/* - - name: Step 10 - Log parsing - run: | - cd ${{ env.PATH_TEMPLATE }} - echo "TEST_SKIPPED=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF)}')" >> $GITHUB_ENV - echo "TEST_PENDING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-1)}')" >> $GITHUB_ENV - echo "TEST_FAILING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-2)}')" >> $GITHUB_ENV - echo "TEST_PASSING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-3)}')" >> $GITHUB_ENV - echo "TEST_TOTAL=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-4)}')" >> $GITHUB_ENV - echo "TEST_TIME=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-5)}')" >> $GITHUB_ENV - - name: Step 11 - Post to a Slack channel - id: slack - uses: slackapi/slack-github-action@v1.19.0 - with: + echo "Information about the workflow (odfe): + wazuh-version: ${{ github.event.inputs.wazuh-version }} + elastic-version: ${{ github.event.inputs.elastic-version }} + odfe-version: ${{ github.event.inputs.odfe-version }} + ubuntu-cypress-version: ${{ github.event.inputs.ubuntu-cypress-version }} + url-package: ${{ github.event.inputs.url-package }}" + + - name: Step 02 - Download Project wazuh-app-environments + uses: actions/checkout@v4 + with: + repository: matiasmoreno876/wazuh-app-environments + ref: 'master' + path: wazuh-app-environments + token: ${{ secrets.FE_SECRET_TOKEN }} + - name: Step 03 - Configuring templates docker environment + run: | + cd $GITHUB_WORKSPACE/wazuh-app-environments/ + mkdir packages + cd ${{ env.PATH_TEMPLATE }} + sed -i -e 's|WAZUH_VERSION=.*|WAZUH_VERSION=${{ github.event.inputs.wazuh-version }}|g' ./.env + sed -i -e 's|ELASTIC_VERSION=.*|ELASTIC_VERSION=${{ github.event.inputs.elastic-version }}|g' ./.env + sed -i -e 's|ODFE_VERSION=.*|ODFE_VERSION=${{ github.event.inputs.odfe-version }}|g' ./.env + sed -i -e 's|UBUNTU_CYPRESS_VERSION=.*|UBUNTU_CYPRESS_VERSION=${{ github.event.inputs.ubuntu-cypress-version }}|g' ./.env + cat .env + - name: Step 04 - Starting containers + run: | + cd ${{ env.PATH_TEMPLATE }} + docker-compose up -d + echo CONTINUES AFTER 15 SECONDS ... + sleep 15s + - name: Step 05 - Installing package from url + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q kibana) bin/kibana-plugin install ${{ github.event.inputs.url-package }} + docker-compose restart kibana + echo CONTINUES AFTER 60 SECONDS ... + sleep 60s + docker-compose ps + - name: Step 06 - Configuring ip container into wazuh.yml + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q kibana) sed -i -e "s/url: https:\/\/localhost/url: https:\/\/wazuh-manager-master/g" /usr/share/kibana/data/wazuh/config/wazuh.yml + docker exec $(docker-compose ps -q kibana) cat /usr/share/kibana/data/wazuh/config/wazuh.yml + - name: Step 07 - Run Cypress tests + id: run-cypress-test + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:run-headless:github-actions:odfe" | tee cypress.log + continue-on-error: true + - name: Step 08 - Run Cypress reports + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:report" + - name: Step 09 - Archive reports + uses: actions/upload-artifact@v4 + with: + name: cypress-reports_ODFE_${{ github.event.inputs.wazuh-version }}-${{ github.event.inputs.odfe-version }}-${{ github.event.inputs.elastic-version }} + path: ${{ env.PATH_TEMPLATE }}/report/* + overwrite: true + - name: Step 10 - Log parsing + run: | + cd ${{ env.PATH_TEMPLATE }} + echo "TEST_SKIPPED=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF)}')" >> $GITHUB_ENV + echo "TEST_PENDING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-1)}')" >> $GITHUB_ENV + echo "TEST_FAILING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-2)}')" >> $GITHUB_ENV + echo "TEST_PASSING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-3)}')" >> $GITHUB_ENV + echo "TEST_TOTAL=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-4)}')" >> $GITHUB_ENV + echo "TEST_TIME=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-5)}')" >> $GITHUB_ENV + - name: Step 11 - Post to a Slack channel + id: slack + uses: slackapi/slack-github-action@v1.19.0 + with: # Slack channel id, channel name, or user id to post message. # See also: https://api.slack.com/methods/chat.postMessage#channels - channel-id: ${{ secrets.SLACK_CHANNEL_ID }} - # For posting a simple plain text message - slack-message: "The following workflow was executed: ${{ github.workflow }}\nWazuh version: ${{ github.event.inputs.wazuh-version }}\nElastic version: ${{ github.event.inputs.elastic-version }}\nODFE version: ${{ github.event.inputs.odfe-version }}\nUbuntu Cypress version: ${{ github.event.inputs.ubuntu-cypress-version }}\nPackage used: ${{ github.event.inputs.url-package }}\n\nTest summary:\n\tTotal Test: ${{ env.TEST_TOTAL }}\n\tPassing: ${{ env.TEST_PASSING }}\n\tFailing: ${{ env.TEST_FAILING }}\n\tPending: ${{ env.TEST_PENDING }}\n\tSkipped: ${{ env.TEST_SKIPPED }}\n\tTotal Time: ${{ env.TEST_TIME }}\n\nFor more information visit: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - env: - SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_TOKEN }} \ No newline at end of file + channel-id: + ${{ secrets.SLACK_CHANNEL_ID }} + # For posting a simple plain text message + slack-message: "The following workflow was executed: ${{ github.workflow }}\nWazuh version: ${{ github.event.inputs.wazuh-version }}\nElastic version: ${{ github.event.inputs.elastic-version }}\nODFE version: ${{ github.event.inputs.odfe-version }}\nUbuntu Cypress version: ${{ github.event.inputs.ubuntu-cypress-version }}\nPackage used: ${{ github.event.inputs.url-package }}\n\nTest summary:\n\tTotal Test: ${{ env.TEST_TOTAL }}\n\tPassing: ${{ env.TEST_PASSING }}\n\tFailing: ${{ env.TEST_FAILING }}\n\tPending: ${{ env.TEST_PENDING }}\n\tSkipped: ${{ env.TEST_SKIPPED }}\n\tTotal Time: ${{ env.TEST_TIME }}\n\nFor more information visit: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + env: + SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_TOKEN }} diff --git a/.github/workflows/cypress-wzd.yml b/.github/workflows/cypress-wzd.yml index 8e0b051142..b4abd30034 100644 --- a/.github/workflows/cypress-wzd.yml +++ b/.github/workflows/cypress-wzd.yml @@ -12,14 +12,14 @@ on: description: 'Wazuh Stack Version' default: '4.3.4' required: true - ubuntu-cypress-version: + ubuntu-cypress-version: description: 'Ubuntu Cypress Version' default: '3.0.0' required: true url-package: description: 'Package Download Url' - required: false - default: 'https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuh-4.3.4-1.zip' + required: false + default: 'https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuh-4.3.4-1.zip' # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -27,84 +27,86 @@ jobs: name: Run setup environment wazuh dashboard app runs-on: ubuntu-latest steps: - - name: Step 01 - Set up environment variables - run: | - echo "PATH_TEMPLATE=$GITHUB_WORKSPACE/wazuh-app-environments/templates_wazuh_prod/" >> $GITHUB_ENV + - name: Step 01 - Set up environment variables + run: | + echo "PATH_TEMPLATE=$GITHUB_WORKSPACE/wazuh-app-environments/templates_wazuh_prod/" >> $GITHUB_ENV - echo "Information about the workflow (wzd): - wazuh-stack-version: ${{ github.event.inputs.wazuh-stack-version }} - ubuntu-cypress-version: ${{ github.event.inputs.ubuntu-cypress-version }} - url-package: ${{ github.event.inputs.url-package }}" - - - name: Step 02 - Download Project wazuh-app-environments - uses: actions/checkout@v2 - with: - repository: matiasmoreno876/wazuh-app-environments - ref: 'master' - path: wazuh-app-environments - token: ${{ secrets.FE_SECRET_TOKEN }} - - name: Step 03 - Configuring templates docker environment - run: | - cd $GITHUB_WORKSPACE/wazuh-app-environments/ - mkdir packages - cd ${{ env.PATH_TEMPLATE }} - sed -i -e 's|WAZUH_STACK_VERSION=.*|WAZUH_STACK_VERSION=${{ github.event.inputs.wazuh-stack-version }}|g' ./.env - sed -i -e 's|UBUNTU_CYPRESS_VERSION=.*|UBUNTU_CYPRESS_VERSION=${{ github.event.inputs.ubuntu-cypress-version }}|g' ./.env - cat .env - - name: Step 04 - Starting containers - run: | - cd ${{ env.PATH_TEMPLATE }} - docker-compose up -d - echo CONTINUES AFTER 30 SECONDS ... - sleep 30s - - name: Step 05 - Remove Wazuh - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q wazuh.dashboard) bin/opensearch-dashboards-plugin remove wazuh - docker-compose restart wazuh.dashboard - echo CONTINUES AFTER 30 SECONDS ... - sleep 30s - docker-compose ps - - name: Step 06 - Installing package from url - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q wazuh.dashboard) bin/opensearch-dashboards-plugin install ${{ github.event.inputs.url-package }} - docker-compose restart wazuh.dashboard - echo CONTINUES AFTER 60 SECONDS ... - sleep 60s - docker-compose ps - - name: Step 07 - Run Cypress tests - id: run-cypress-test - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:run-headless:github-actions:wzd" | tee cypress.log - continue-on-error: true - - name: Step 08 - Run Cypress reports - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:report" - - name: Step 09 - Archive reports - uses: actions/upload-artifact@v2 - with: - name: cypress-reports_WZD_${{ github.event.inputs.wazuh-stack-version }} - path: ${{ env.PATH_TEMPLATE }}/report/* - - name: Step 10 - Log parsing - run: | - cd ${{ env.PATH_TEMPLATE }} - echo "TEST_SKIPPED=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF)}')" >> $GITHUB_ENV - echo "TEST_PENDING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-1)}')" >> $GITHUB_ENV - echo "TEST_FAILING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-2)}')" >> $GITHUB_ENV - echo "TEST_PASSING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-3)}')" >> $GITHUB_ENV - echo "TEST_TOTAL=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-4)}')" >> $GITHUB_ENV - echo "TEST_TIME=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-5)}')" >> $GITHUB_ENV - - name: Step 11 - Post to a Slack channel - id: slack - uses: slackapi/slack-github-action@v1.19.0 - with: + echo "Information about the workflow (wzd): + wazuh-stack-version: ${{ github.event.inputs.wazuh-stack-version }} + ubuntu-cypress-version: ${{ github.event.inputs.ubuntu-cypress-version }} + url-package: ${{ github.event.inputs.url-package }}" + + - name: Step 02 - Download Project wazuh-app-environments + uses: actions/checkout@v4 + with: + repository: matiasmoreno876/wazuh-app-environments + ref: 'master' + path: wazuh-app-environments + token: ${{ secrets.FE_SECRET_TOKEN }} + - name: Step 03 - Configuring templates docker environment + run: | + cd $GITHUB_WORKSPACE/wazuh-app-environments/ + mkdir packages + cd ${{ env.PATH_TEMPLATE }} + sed -i -e 's|WAZUH_STACK_VERSION=.*|WAZUH_STACK_VERSION=${{ github.event.inputs.wazuh-stack-version }}|g' ./.env + sed -i -e 's|UBUNTU_CYPRESS_VERSION=.*|UBUNTU_CYPRESS_VERSION=${{ github.event.inputs.ubuntu-cypress-version }}|g' ./.env + cat .env + - name: Step 04 - Starting containers + run: | + cd ${{ env.PATH_TEMPLATE }} + docker-compose up -d + echo CONTINUES AFTER 30 SECONDS ... + sleep 30s + - name: Step 05 - Remove Wazuh + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q wazuh.dashboard) bin/opensearch-dashboards-plugin remove wazuh + docker-compose restart wazuh.dashboard + echo CONTINUES AFTER 30 SECONDS ... + sleep 30s + docker-compose ps + - name: Step 06 - Installing package from url + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q wazuh.dashboard) bin/opensearch-dashboards-plugin install ${{ github.event.inputs.url-package }} + docker-compose restart wazuh.dashboard + echo CONTINUES AFTER 60 SECONDS ... + sleep 60s + docker-compose ps + - name: Step 07 - Run Cypress tests + id: run-cypress-test + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:run-headless:github-actions:wzd" | tee cypress.log + continue-on-error: true + - name: Step 08 - Run Cypress reports + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:report" + - name: Step 09 - Archive reports + uses: actions/upload-artifact@v4 + with: + name: cypress-reports_WZD_${{ github.event.inputs.wazuh-stack-version }} + path: ${{ env.PATH_TEMPLATE }}/report/* + overwrite: true + - name: Step 10 - Log parsing + run: | + cd ${{ env.PATH_TEMPLATE }} + echo "TEST_SKIPPED=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF)}')" >> $GITHUB_ENV + echo "TEST_PENDING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-1)}')" >> $GITHUB_ENV + echo "TEST_FAILING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-2)}')" >> $GITHUB_ENV + echo "TEST_PASSING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-3)}')" >> $GITHUB_ENV + echo "TEST_TOTAL=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-4)}')" >> $GITHUB_ENV + echo "TEST_TIME=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-5)}')" >> $GITHUB_ENV + - name: Step 11 - Post to a Slack channel + id: slack + uses: slackapi/slack-github-action@v1.19.0 + with: # Slack channel id, channel name, or user id to post message. # See also: https://api.slack.com/methods/chat.postMessage#channels - channel-id: ${{ secrets.SLACK_CHANNEL_ID }} - # For posting a simple plain text message - slack-message: "The following workflow was executed: ${{ github.workflow }}\nWazuh stack version: ${{ github.event.inputs.wazuh-stack-version }}\nUbuntu Cypress version: ${{ github.event.inputs.ubuntu-cypress-version }}\nPackage used: ${{ github.event.inputs.url-package }}\n\nTest summary:\n\tTotal Test: ${{ env.TEST_TOTAL }}\n\tPassing: ${{ env.TEST_PASSING }}\n\tFailing: ${{ env.TEST_FAILING }}\n\tPending: ${{ env.TEST_PENDING }}\n\tSkipped: ${{ env.TEST_SKIPPED }}\n\tTotal Time: ${{ env.TEST_TIME }}\n\nFor more information visit: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - env: - SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_TOKEN }} \ No newline at end of file + channel-id: + ${{ secrets.SLACK_CHANNEL_ID }} + # For posting a simple plain text message + slack-message: "The following workflow was executed: ${{ github.workflow }}\nWazuh stack version: ${{ github.event.inputs.wazuh-stack-version }}\nUbuntu Cypress version: ${{ github.event.inputs.ubuntu-cypress-version }}\nPackage used: ${{ github.event.inputs.url-package }}\n\nTest summary:\n\tTotal Test: ${{ env.TEST_TOTAL }}\n\tPassing: ${{ env.TEST_PASSING }}\n\tFailing: ${{ env.TEST_FAILING }}\n\tPending: ${{ env.TEST_PENDING }}\n\tSkipped: ${{ env.TEST_SKIPPED }}\n\tTotal Time: ${{ env.TEST_TIME }}\n\nFor more information visit: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + env: + SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_TOKEN }} diff --git a/.github/workflows/cypress-xpack.yml b/.github/workflows/cypress-xpack.yml index a16f888eff..aa4a46be3a 100644 --- a/.github/workflows/cypress-xpack.yml +++ b/.github/workflows/cypress-xpack.yml @@ -12,18 +12,18 @@ on: description: 'Wazuh Version' default: 'v4.3.4' required: true - elastic-version: + elastic-version: description: 'Elastic Version' default: '7.16.3' required: true - ubuntu-cypress-version: + ubuntu-cypress-version: description: 'Ubuntu Cypress Version' default: '3.0.0' required: true url-package: description: 'Package Download Url' - required: false - default: 'https://packages-dev.wazuh.com/pre-release/ui/kibana/wazuh_kibana-4.3.4_7.16.3-1.zip' + required: false + default: 'https://packages-dev.wazuh.com/pre-release/ui/kibana/wazuh_kibana-4.3.4_7.16.3-1.zip' # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -31,84 +31,86 @@ jobs: name: Run setup environment wazuh kibana app runs-on: ubuntu-latest steps: - - name: Step 01 - Set up environment variables - run: | - echo "PATH_TEMPLATE=$GITHUB_WORKSPACE/wazuh-app-environments/templates_elastic_prod/es_xpack-wz_cluster-agent/" >> $GITHUB_ENV + - name: Step 01 - Set up environment variables + run: | + echo "PATH_TEMPLATE=$GITHUB_WORKSPACE/wazuh-app-environments/templates_elastic_prod/es_xpack-wz_cluster-agent/" >> $GITHUB_ENV - echo "Information about the workflow (xpack): - wazuh-version: ${{ github.event.inputs.wazuh-version }} - elastic-version: ${{ github.event.inputs.elastic-version }} - ubuntu-cypress-version: ${{ github.event.inputs.ubuntu-cypress-version }} - url-package: ${{ github.event.inputs.url-package }}" - - - name: Step 02 - Download Project wazuh-app-environments - uses: actions/checkout@v2 - with: - repository: matiasmoreno876/wazuh-app-environments - ref: 'master' - path: wazuh-app-environments - token: ${{ secrets.FE_SECRET_TOKEN }} - - name: Step 03 - Configuring templates docker environment - run: | - cd $GITHUB_WORKSPACE/wazuh-app-environments/ - mkdir packages - cd ${{ env.PATH_TEMPLATE }} - sed -i -e 's|WAZUH_VERSION=.*|WAZUH_VERSION=${{ github.event.inputs.wazuh-version }}|g' ./.env - sed -i -e 's|ELASTIC_VERSION=.*|ELASTIC_VERSION=${{ github.event.inputs.elastic-version }}|g' ./.env - sed -i -e 's|UBUNTU_CYPRESS_VERSION=.*|UBUNTU_CYPRESS_VERSION=${{ github.event.inputs.ubuntu-cypress-version }}|g' ./.env - cat .env - - name: Step 04 - Starting containers - run: | - cd ${{ env.PATH_TEMPLATE }} - sed -i -e 's|docker-compose exec elasticsearch|docker exec $(docker-compose ps -q elasticsearch)|g' ./setup.sh - sudo sh setup.sh - echo CONTINUES AFTER 15 SECONDS ... - sleep 15s - - name: Step 05 - Installing package from url - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q kibana) bin/kibana-plugin install ${{ github.event.inputs.url-package }} - docker-compose restart kibana - echo CONTINUES AFTER 60 SECONDS ... - sleep 60s - docker-compose ps - - name: Step 06 - Configuring ip container into wazuh.yml - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q kibana) sed -i -e "s/url: https:\/\/localhost/url: https:\/\/wazuh-manager-master/g" /usr/share/kibana/data/wazuh/config/wazuh.yml - docker exec $(docker-compose ps -q kibana) cat /usr/share/kibana/data/wazuh/config/wazuh.yml - - name: Step 07 - Run Cypress tests - id: run-cypress-test - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:run-headless:github-actions:xpack" | tee cypress.log - continue-on-error: true - - name: Step 08 - Run Cypress reports - run: | - cd ${{ env.PATH_TEMPLATE }} - docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:report" - - name: Step 09 - Archive reports - uses: actions/upload-artifact@v2 - with: - name: cypress-reports_XPACK_${{ github.event.inputs.wazuh-version }}-${{ github.event.inputs.elastic-version }} - path: ${{ env.PATH_TEMPLATE }}/report/* - - name: Step 10 - Log parsing - run: | - cd ${{ env.PATH_TEMPLATE }} - echo "TEST_SKIPPED=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF)}')" >> $GITHUB_ENV - echo "TEST_PENDING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-1)}')" >> $GITHUB_ENV - echo "TEST_FAILING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-2)}')" >> $GITHUB_ENV - echo "TEST_PASSING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-3)}')" >> $GITHUB_ENV - echo "TEST_TOTAL=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-4)}')" >> $GITHUB_ENV - echo "TEST_TIME=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-5)}')" >> $GITHUB_ENV - - name: Step 11 - Post to a Slack channel - id: slack - uses: slackapi/slack-github-action@v1.19.0 - with: + echo "Information about the workflow (xpack): + wazuh-version: ${{ github.event.inputs.wazuh-version }} + elastic-version: ${{ github.event.inputs.elastic-version }} + ubuntu-cypress-version: ${{ github.event.inputs.ubuntu-cypress-version }} + url-package: ${{ github.event.inputs.url-package }}" + + - name: Step 02 - Download Project wazuh-app-environments + uses: actions/checkout@v4 + with: + repository: matiasmoreno876/wazuh-app-environments + ref: 'master' + path: wazuh-app-environments + token: ${{ secrets.FE_SECRET_TOKEN }} + - name: Step 03 - Configuring templates docker environment + run: | + cd $GITHUB_WORKSPACE/wazuh-app-environments/ + mkdir packages + cd ${{ env.PATH_TEMPLATE }} + sed -i -e 's|WAZUH_VERSION=.*|WAZUH_VERSION=${{ github.event.inputs.wazuh-version }}|g' ./.env + sed -i -e 's|ELASTIC_VERSION=.*|ELASTIC_VERSION=${{ github.event.inputs.elastic-version }}|g' ./.env + sed -i -e 's|UBUNTU_CYPRESS_VERSION=.*|UBUNTU_CYPRESS_VERSION=${{ github.event.inputs.ubuntu-cypress-version }}|g' ./.env + cat .env + - name: Step 04 - Starting containers + run: | + cd ${{ env.PATH_TEMPLATE }} + sed -i -e 's|docker-compose exec elasticsearch|docker exec $(docker-compose ps -q elasticsearch)|g' ./setup.sh + sudo sh setup.sh + echo CONTINUES AFTER 15 SECONDS ... + sleep 15s + - name: Step 05 - Installing package from url + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q kibana) bin/kibana-plugin install ${{ github.event.inputs.url-package }} + docker-compose restart kibana + echo CONTINUES AFTER 60 SECONDS ... + sleep 60s + docker-compose ps + - name: Step 06 - Configuring ip container into wazuh.yml + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q kibana) sed -i -e "s/url: https:\/\/localhost/url: https:\/\/wazuh-manager-master/g" /usr/share/kibana/data/wazuh/config/wazuh.yml + docker exec $(docker-compose ps -q kibana) cat /usr/share/kibana/data/wazuh/config/wazuh.yml + - name: Step 07 - Run Cypress tests + id: run-cypress-test + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:run-headless:github-actions:xpack" | tee cypress.log + continue-on-error: true + - name: Step 08 - Run Cypress reports + run: | + cd ${{ env.PATH_TEMPLATE }} + docker exec $(docker-compose ps -q cypress) bash -c " . /home/automation/nvm/nvm.sh && nvm use && npm run cypress:report" + - name: Step 09 - Archive reports + uses: actions/upload-artifact@v4 + with: + name: cypress-reports_XPACK_${{ github.event.inputs.wazuh-version }}-${{ github.event.inputs.elastic-version }} + path: ${{ env.PATH_TEMPLATE }}/report/* + overwrite: true + - name: Step 10 - Log parsing + run: | + cd ${{ env.PATH_TEMPLATE }} + echo "TEST_SKIPPED=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF)}')" >> $GITHUB_ENV + echo "TEST_PENDING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-1)}')" >> $GITHUB_ENV + echo "TEST_FAILING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-2)}')" >> $GITHUB_ENV + echo "TEST_PASSING=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-3)}')" >> $GITHUB_ENV + echo "TEST_TOTAL=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-4)}')" >> $GITHUB_ENV + echo "TEST_TIME=$(grep -E "failed \(|passed" cypress.log | awk ' { print $(NF-5)}')" >> $GITHUB_ENV + - name: Step 11 - Post to a Slack channel + id: slack + uses: slackapi/slack-github-action@v1.19.0 + with: # Slack channel id, channel name, or user id to post message. # See also: https://api.slack.com/methods/chat.postMessage#channels - channel-id: ${{ secrets.SLACK_CHANNEL_ID }} - # For posting a simple plain text message - slack-message: "The following workflow was executed: ${{ github.workflow }}\nWazuh version: ${{ github.event.inputs.wazuh-version }}\nElastic version: ${{ github.event.inputs.elastic-version }}\nUbuntu Cypress version: ${{ github.event.inputs.ubuntu-cypress-version }}\nPackage used: ${{ github.event.inputs.url-package }}\n\nTest summary:\n\tTotal Test: ${{ env.TEST_TOTAL }}\n\tPassing: ${{ env.TEST_PASSING }}\n\tFailing: ${{ env.TEST_FAILING }}\n\tPending: ${{ env.TEST_PENDING }}\n\tSkipped: ${{ env.TEST_SKIPPED }}\n\tTotal Time: ${{ env.TEST_TIME }}\n\nFor more information visit: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - env: - SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_TOKEN }} \ No newline at end of file + channel-id: + ${{ secrets.SLACK_CHANNEL_ID }} + # For posting a simple plain text message + slack-message: "The following workflow was executed: ${{ github.workflow }}\nWazuh version: ${{ github.event.inputs.wazuh-version }}\nElastic version: ${{ github.event.inputs.elastic-version }}\nUbuntu Cypress version: ${{ github.event.inputs.ubuntu-cypress-version }}\nPackage used: ${{ github.event.inputs.url-package }}\n\nTest summary:\n\tTotal Test: ${{ env.TEST_TOTAL }}\n\tPassing: ${{ env.TEST_PASSING }}\n\tFailing: ${{ env.TEST_FAILING }}\n\tPending: ${{ env.TEST_PENDING }}\n\tSkipped: ${{ env.TEST_SKIPPED }}\n\tTotal Time: ${{ env.TEST_TIME }}\n\nFor more information visit: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + env: + SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_TOKEN }} diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index fe461b4243..0d4a01360d 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -15,6 +15,6 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Dependency Review' - uses: actions/dependency-review-action@v2 + uses: actions/dependency-review-action@v4 diff --git a/.github/workflows/dev-environment.yml b/.github/workflows/dev-environment.yml index a58e23a2fe..f38fce6fa9 100644 --- a/.github/workflows/dev-environment.yml +++ b/.github/workflows/dev-environment.yml @@ -78,7 +78,7 @@ jobs: steps: - name: Step 01 - Download the plugin's source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: wazuh/wazuh-dashboard-plugins ref: ${{ inputs.reference }} @@ -126,11 +126,12 @@ jobs: - name: Step 04 - Upload artifact to GitHub if: ${{ inputs.artifact_name && inputs.artifact_path }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ inputs.artifact_name }}_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip path: ${{ matrix.plugins.path }}/${{ inputs.artifact_path }} if-no-files-found: 'error' + overwrite: true - name: Step 05 - Upload coverage results to GitHub if: ${{ inputs.notify_jest_coverage_summary && github.event_name == 'pull_request' }} diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index f4694141d7..c162ff14a7 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -23,11 +23,11 @@ jobs: steps: # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 # - https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file - name: Install NodeJS - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index 81800fef36..a9299d1762 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -39,7 +39,7 @@ jobs: steps: - name: Step 01 - Download the plugin's source code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: wazuh/wazuh-dashboard-plugins ref: ${{ inputs.reference }} @@ -54,10 +54,11 @@ jobs: echo "versionPlatform=$(jq -r '.pluginPlatform.version' $(pwd)/wazuh/plugins/main/package.json)" >> $GITHUB_ENV - name: Step 03 - Download the plugin's source code - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: wazuh-dashboard-plugins_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip path: ${{ env.currentDir }}/wazuh/scripts/test-packages/wazuh-dashboard-plugins_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + overwrite: true - name: Step 04 - Build the Docker image run: | diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index b46b6c19c9..a21fd45041 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -10,11 +10,11 @@ jobs: steps: # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 # - https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file - name: Install NodeJS - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' diff --git a/.github/workflows/wazuh-build-push-docker-action.yml b/.github/workflows/wazuh-build-push-docker-action.yml index 74be8e29e1..e6cbcd66e2 100644 --- a/.github/workflows/wazuh-build-push-docker-action.yml +++ b/.github/workflows/wazuh-build-push-docker-action.yml @@ -56,7 +56,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Step 01 - Download wazuh-kibana-app - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: wazuh-kibana-app - name: Step 02 - Login to quay.io @@ -80,7 +80,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Step 01 - Download wazuh-kibana-app - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: wazuh-kibana-app - name: Step 02 - Login to quay.io @@ -101,7 +101,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Step 01 - Download wazuh-kibana-app - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: wazuh-kibana-app - name: Step 02 - Login to quay.io From 0a82897dce265915f0085307e801a81d1fa63f7c Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Thu, 28 Nov 2024 12:10:18 +0100 Subject: [PATCH 2/8] Unzip command not found in package generation action (#7180) * Add install unzip command * Fix unzip command * Escalate root user privileges * Fix unzip command path * Unzip in dockefile * Change for loop * Change for loop * add ls -la * Change test plugins path * change ls * change folder name * Comment the unzip process * Clean code * Format artifact name with slash * Implement githubReference * Test set -e * Remove set -e test --- .github/workflows/dev-environment.yml | 2 +- .github/workflows/manual-build.yml | 22 +++++++++++++++---- scripts/test-packages/install-plugins.sh | 8 ++++--- .../osd-test-packages.Dockerfile | 1 - 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/dev-environment.yml b/.github/workflows/dev-environment.yml index f38fce6fa9..37e6a74b97 100644 --- a/.github/workflows/dev-environment.yml +++ b/.github/workflows/dev-environment.yml @@ -128,7 +128,7 @@ jobs: if: ${{ inputs.artifact_name && inputs.artifact_path }} uses: actions/upload-artifact@v4 with: - name: ${{ inputs.artifact_name }}_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + name: ${{ inputs.artifact_name }}_${{ matrix.plugins.container_path }}_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip path: ${{ matrix.plugins.path }}/${{ inputs.artifact_path }} if-no-files-found: 'error' overwrite: true diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index a9299d1762..45bd1fc751 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -53,14 +53,28 @@ jobs: echo "revision=$(jq -r '.revision' $(pwd)/wazuh/plugins/main/package.json)" >> $GITHUB_ENV echo "versionPlatform=$(jq -r '.pluginPlatform.version' $(pwd)/wazuh/plugins/main/package.json)" >> $GITHUB_ENV - - name: Step 03 - Download the plugin's source code + - name: Step 03 - Download the main plugin's artifact uses: actions/download-artifact@v4 with: - name: wazuh-dashboard-plugins_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip - path: ${{ env.currentDir }}/wazuh/scripts/test-packages/wazuh-dashboard-plugins_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + name: wazuh-dashboard-plugins_wazuh_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + path: ${{ env.currentDir }}/wazuh/scripts/test-packages/plugins/wazuh-dashboard-plugins_wazuh_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip overwrite: true - - name: Step 04 - Build the Docker image + - name: Step 04 - Download the core plugin's artifact + uses: actions/download-artifact@v4 + with: + name: wazuh-dashboard-plugins_wazuh-core_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + path: ${{ env.currentDir }}/wazuh/scripts/test-packages/plugins/wazuh-dashboard-plugins_wazuh-core_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + overwrite: true + + - name: Step 05 - Download the check-updates plugin's artifact + uses: actions/download-artifact@v4 + with: + name: wazuh-dashboard-plugins_wazuh-check-updates_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + path: ${{ env.currentDir }}/wazuh/scripts/test-packages/plugins/wazuh-dashboard-plugins_wazuh-check-updates_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + overwrite: true + + - name: Step 06 - Build the Docker image run: | echo "current=${{ env.currentDir }}" cd ./wazuh/scripts/test-packages diff --git a/scripts/test-packages/install-plugins.sh b/scripts/test-packages/install-plugins.sh index 6e9bc5505d..411c022666 100644 --- a/scripts/test-packages/install-plugins.sh +++ b/scripts/test-packages/install-plugins.sh @@ -1,6 +1,8 @@ - plugins=$(ls /tmp) -echo $plugins +set -e + +plugins=$(ls /tmp) for plugin in $plugins; do echo $plugin - /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin install file:///tmp/$plugin + /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin install file:///tmp/$plugin/$(ls /tmp/$plugin) done +echo "All plugins installed successfully" diff --git a/scripts/test-packages/osd-test-packages.Dockerfile b/scripts/test-packages/osd-test-packages.Dockerfile index 8391eb3d2e..88cc083597 100644 --- a/scripts/test-packages/osd-test-packages.Dockerfile +++ b/scripts/test-packages/osd-test-packages.Dockerfile @@ -18,4 +18,3 @@ ADD ./${PACKAGE_NAME} /tmp/ COPY --chown=opensearch-dashboards ./install-plugins.sh / RUN chmod +x /install-plugins.sh RUN /install-plugins.sh - From 1d2a6f0ed511f4f45fb002d3a78093097dc0f9f0 Mon Sep 17 00:00:00 2001 From: Guido Modarelli <38738725+guidomodarelli@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:13:35 -0300 Subject: [PATCH 3/8] Update .github/workflows/dev-environment.yml --- .github/workflows/dev-environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev-environment.yml b/.github/workflows/dev-environment.yml index 37e6a74b97..dd8c3f6548 100644 --- a/.github/workflows/dev-environment.yml +++ b/.github/workflows/dev-environment.yml @@ -118,7 +118,7 @@ jobs: cd /home/node/kbn/plugins/${{ matrix.plugins.container_path }} && yarn && ${{ inputs.command }}; ' - - name: Get the plugin version and and format reference name + - name: Get the plugin version and format reference name run: | echo "githubReference=$(echo ${{ inputs.reference }} | sed 's/\//-/g')" >> $GITHUB_ENV echo "version=$(jq -r '.version' $(pwd)/wazuh/plugins/main/package.json)" >> $GITHUB_ENV From d8095fc9ecbac0d31672d00edd99435cf8493c9f Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Mon, 25 Nov 2024 15:23:06 +0100 Subject: [PATCH 4/8] Fix actions artifact plugins name (#7174) * Fix actions artifact plugins name * Add plugins packages to plugins folder * Unzip package zips --- .github/workflows/dev-environment.yml | 2 +- scripts/test-packages/osd-test-packages.Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-environment.yml b/.github/workflows/dev-environment.yml index dd8c3f6548..69b1574f87 100644 --- a/.github/workflows/dev-environment.yml +++ b/.github/workflows/dev-environment.yml @@ -128,7 +128,7 @@ jobs: if: ${{ inputs.artifact_name && inputs.artifact_path }} uses: actions/upload-artifact@v4 with: - name: ${{ inputs.artifact_name }}_${{ matrix.plugins.container_path }}_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + name: ${{ inputs.artifact_name }}_${{ matrix.plugins.container_path }}_${{ matrix.plugins.container_path }}_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip path: ${{ matrix.plugins.path }}/${{ inputs.artifact_path }} if-no-files-found: 'error' overwrite: true diff --git a/scripts/test-packages/osd-test-packages.Dockerfile b/scripts/test-packages/osd-test-packages.Dockerfile index 88cc083597..b7e5c7ef50 100644 --- a/scripts/test-packages/osd-test-packages.Dockerfile +++ b/scripts/test-packages/osd-test-packages.Dockerfile @@ -6,7 +6,7 @@ FROM opensearchproject/opensearch-dashboards:${OSD_VERSION} ARG PACKAGE_NAME -ADD ./${PACKAGE_NAME} /tmp/ +ADD ./plugins /tmp/ # This is needed to run it local # # USER root From 4480e5270c8748fd9acebbaaa51db6ae950e3bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Mon, 16 Dec 2024 11:57:09 +0100 Subject: [PATCH 5/8] feat: add engine and fleet to manual build GHA --- .github/workflows/manual-build.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index 45bd1fc751..f1b47cd02c 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -74,6 +74,20 @@ jobs: path: ${{ env.currentDir }}/wazuh/scripts/test-packages/plugins/wazuh-dashboard-plugins_wazuh-check-updates_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip overwrite: true + - name: Step 06 - Download the engine plugin's artifact + uses: actions/download-artifact@v4 + with: + name: wazuh-dashboard-plugins_wazuh-engine_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + path: ${{ env.currentDir }}/wazuh/scripts/test-packages/plugins/wazuh-dashboard-plugins_wazuh-engine_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + overwrite: true + + - name: Step 07 - Download the fleet plugin's artifact + uses: actions/download-artifact@v4 + with: + name: wazuh-dashboard-plugins_wazuh-fleet${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + path: ${{ env.currentDir }}/wazuh/scripts/test-packages/plugins/wazuh-dashboard-plugins_wazuh-fleet${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + overwrite: true + - name: Step 06 - Build the Docker image run: | echo "current=${{ env.currentDir }}" From 073b7ffeabaec51688486ef94916cdf693b8d3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Mon, 16 Dec 2024 12:59:04 +0100 Subject: [PATCH 6/8] fix: revert number definition --- .eslintrc.js | 1 + plugins/wazuh-core/common/constants.ts | 12 ++++++------ plugins/wazuh-core/public/services/http/constants.ts | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 16133261ff..53f46b96fc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -171,6 +171,7 @@ module.exports = { /* -------------------------------------------------------------------------- */ 'unicorn/prefer-module': 'off', 'unicorn/prefer-ternary': 'off', + 'unicorn/numeric-separators-style': 'off', // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/custom-error-definition.md 'unicorn/custom-error-definition': 'error', // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/better-regex.md diff --git a/plugins/wazuh-core/common/constants.ts b/plugins/wazuh-core/common/constants.ts index 726ac2c535..ff996a0568 100644 --- a/plugins/wazuh-core/common/constants.ts +++ b/plugins/wazuh-core/common/constants.ts @@ -101,7 +101,7 @@ export const WAZUH_SECURITY_PLUGINS = [ ]; // App configuration -export const WAZUH_CONFIGURATION_CACHE_TIME = 10_000; // time in ms; +export const WAZUH_CONFIGURATION_CACHE_TIME = 10000; // time in ms; // Reserved ids for Users/Role mapping export const WAZUH_API_RESERVED_ID_LOWER_THAN = 100; @@ -249,7 +249,7 @@ export const PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER = 'timepicker:timeDefaults'; // Default maxBuckets set by the app -export const WAZUH_PLUGIN_PLATFORM_SETTING_MAX_BUCKETS = 200_000; +export const WAZUH_PLUGIN_PLATFORM_SETTING_MAX_BUCKETS = 200000; export const PLUGIN_PLATFORM_SETTING_NAME_MAX_BUCKETS = 'timeline:max_buckets'; // Default metaFields set by the app @@ -389,7 +389,7 @@ export const NOT_TIME_FIELD_NAME_INDEX_PATTERN = 'not_time_field_name_index_pattern'; // Customization -export const CUSTOMIZATION_ENDPOINT_PAYLOAD_UPLOAD_CUSTOM_FILE_MAXIMUM_BYTES = 1_048_576; +export const CUSTOMIZATION_ENDPOINT_PAYLOAD_UPLOAD_CUSTOM_FILE_MAXIMUM_BYTES = 1048576; // Plugin settings export enum SettingCategory { @@ -1474,12 +1474,12 @@ hosts: title: 'Port', description: 'Port', type: EpluginSettingType.number, - defaultValue: 55_000, + defaultValue: 55000, isConfigurableFromSettings: true, options: { number: { min: 0, - max: 65_535, + max: 65535, integer: true, }, }, @@ -1713,7 +1713,7 @@ hosts: 'Maximum time, in milliseconds, the app will wait for an API response when making requests to it. It will be ignored if the value is set under 1500 milliseconds.', category: SettingCategory.GENERAL, type: EpluginSettingType.number, - defaultValue: 20_000, + defaultValue: 20000, isConfigurableFromSettings: true, options: { number: { diff --git a/plugins/wazuh-core/public/services/http/constants.ts b/plugins/wazuh-core/public/services/http/constants.ts index ad812bbb3d..8ea7ec6d05 100644 --- a/plugins/wazuh-core/public/services/http/constants.ts +++ b/plugins/wazuh-core/public/services/http/constants.ts @@ -2,4 +2,4 @@ export const PLUGIN_PLATFORM_REQUEST_HEADERS = { 'osd-xsrf': 'kibana', }; -export const HTTP_CLIENT_DEFAULT_TIMEOUT = 20_000; +export const HTTP_CLIENT_DEFAULT_TIMEOUT = 20000; From 8f7a3c102d100fa35dafd170b5a558c83ac970b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Mon, 16 Dec 2024 13:20:53 +0100 Subject: [PATCH 7/8] fix: revert usage of node: built-in modules --- .eslintrc.js | 1 + plugins/main/server/controllers/wazuh-api.ts | 4 ++-- plugins/wazuh-core/common/constants.ts | 2 +- plugins/wazuh-core/common/services/settings-validator.ts | 2 +- plugins/wazuh-core/server/services/server-api-client.ts | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 53f46b96fc..84f328f7c2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -172,6 +172,7 @@ module.exports = { 'unicorn/prefer-module': 'off', 'unicorn/prefer-ternary': 'off', 'unicorn/numeric-separators-style': 'off', + 'unicorn/prefer-node-protocol': 'off', // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/custom-error-definition.md 'unicorn/custom-error-definition': 'error', // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/better-regex.md diff --git a/plugins/main/server/controllers/wazuh-api.ts b/plugins/main/server/controllers/wazuh-api.ts index f0016b62b1..d4e4eb2d00 100644 --- a/plugins/main/server/controllers/wazuh-api.ts +++ b/plugins/main/server/controllers/wazuh-api.ts @@ -12,8 +12,8 @@ */ // Require some libraries -import fs from 'node:fs'; -import path from 'node:path'; +import fs from 'fs'; +import path from 'path'; import { Parser } from 'json2csv'; import jwtDecode from 'jwt-decode'; import { diff --git a/plugins/wazuh-core/common/constants.ts b/plugins/wazuh-core/common/constants.ts index ff996a0568..1950b1ec9c 100644 --- a/plugins/wazuh-core/common/constants.ts +++ b/plugins/wazuh-core/common/constants.ts @@ -9,7 +9,7 @@ * * Find more information about this on the LICENSE file. */ -import path from 'node:path'; +import path from 'path'; import { version } from '../package.json'; // import { validate as validateNodeCronInterval } from 'node-cron'; import { SettingsValidator } from '../common/services/settings-validator'; diff --git a/plugins/wazuh-core/common/services/settings-validator.ts b/plugins/wazuh-core/common/services/settings-validator.ts index 15503d6330..e030eb41f8 100644 --- a/plugins/wazuh-core/common/services/settings-validator.ts +++ b/plugins/wazuh-core/common/services/settings-validator.ts @@ -1,4 +1,4 @@ -import path from 'node:path'; +import path from 'path'; import { formatBytes } from './file-size'; export const SettingsValidator = { diff --git a/plugins/wazuh-core/server/services/server-api-client.ts b/plugins/wazuh-core/server/services/server-api-client.ts index 910d01e39e..a0bdb6f481 100644 --- a/plugins/wazuh-core/server/services/server-api-client.ts +++ b/plugins/wazuh-core/server/services/server-api-client.ts @@ -10,7 +10,7 @@ * Find more information about this on the LICENSE file. */ -import https from 'node:https'; +import https from 'https'; import axios, { AxiosInstance, AxiosResponse } from 'axios'; import { Logger } from 'opensearch-dashboards/server'; import { getCookieValueByName } from './cookie'; From 9c65b5d07a45339aad2f65555da70183a29f5f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20David=20Guti=C3=A9rrez?= Date: Mon, 16 Dec 2024 13:58:29 +0100 Subject: [PATCH 8/8] fix: GHA build --- .github/workflows/dev-environment.yml | 2 +- .github/workflows/manual-build.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-environment.yml b/.github/workflows/dev-environment.yml index 69b1574f87..dd8c3f6548 100644 --- a/.github/workflows/dev-environment.yml +++ b/.github/workflows/dev-environment.yml @@ -128,7 +128,7 @@ jobs: if: ${{ inputs.artifact_name && inputs.artifact_path }} uses: actions/upload-artifact@v4 with: - name: ${{ inputs.artifact_name }}_${{ matrix.plugins.container_path }}_${{ matrix.plugins.container_path }}_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + name: ${{ inputs.artifact_name }}_${{ matrix.plugins.container_path }}_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip path: ${{ matrix.plugins.path }}/${{ inputs.artifact_path }} if-no-files-found: 'error' overwrite: true diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml index f1b47cd02c..e062d570fe 100644 --- a/.github/workflows/manual-build.yml +++ b/.github/workflows/manual-build.yml @@ -84,7 +84,7 @@ jobs: - name: Step 07 - Download the fleet plugin's artifact uses: actions/download-artifact@v4 with: - name: wazuh-dashboard-plugins_wazuh-fleet${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip + name: wazuh-dashboard-plugins_wazuh-fleet_${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip path: ${{ env.currentDir }}/wazuh/scripts/test-packages/plugins/wazuh-dashboard-plugins_wazuh-fleet${{ env.version }}-${{ env.revision }}_${{ env.githubReference }}.zip overwrite: true