From 36281f89202646925169cb21ee81f3fad842e4ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Tue, 21 Nov 2023 13:23:31 +0100 Subject: [PATCH] Add compatibility with OpenSearch 2.11.0 (#31) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bump version Security Dashboards Plugin 2.9.0.0 (#21) * Upgrade to version 2.8.0 of Security Dashboards Plugin (#20) * Patch actions and workflows. Skip integration tests that fail (#4) * Change plugin name in actions and workflows * Patch install-dashboards action * Change jest config path * Skip tests --------- Co-authored-by: Alex Ruiz Becerra Co-authored-by: yenienserrano * Change Wazuh logo and titles (#3) * Change Wazuh logo and titles * Don't force custom logo to have 100% width * Add comment * Fix lint * Fix prettier * Update snapshots --------- Signed-off-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com> Co-authored-by: yenienserrano Co-authored-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com> * Disable tenant popup (#5) Co-authored-by: Alex Ruiz Becerra * Replace readme (#16) * Replace readme * Replace Opensearch to Wazuh * Update README.md Signed-off-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com> --------- Signed-off-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com> * Add GitHub workflow for automated build (#15) * Manual build * Workflow for automated build * Update .github/workflows/dev-environment.yml Signed-off-by: Álex Ruiz --------- Signed-off-by: Álex Ruiz Co-authored-by: Álex Ruiz * Create codeql.yml Signed-off-by: Álex Ruiz * Revert changes in cypress-test.yml * Revert changes in integration-test.yml * Fix integration test * Fix cypress test tenancy disabled --------- Signed-off-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com> Signed-off-by: Álex Ruiz Co-authored-by: Federico Rodriguez Co-authored-by: Alex Ruiz Becerra Co-authored-by: Álex Ruiz * Skip overview page test * Skip test for issue * Skip test for issue --------- Signed-off-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com> Signed-off-by: Álex Ruiz Co-authored-by: Federico Rodriguez Co-authored-by: Alex Ruiz Becerra Co-authored-by: Álex Ruiz * Fix home image and lint * Fix lint * Fix snapshot * Fix integration test * Revert selector --------- Signed-off-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com> Signed-off-by: Álex Ruiz Co-authored-by: Ian Yenien Serrano <63758389+yenienserrano@users.noreply.github.com> Co-authored-by: Federico Rodriguez Co-authored-by: yenienserrano --- .github/actions/install-dashboards/action.yml | 19 ++-- .github/workflows/build.yml | 19 ++++ .github/workflows/codeql.yml | 77 ++++++++++++++++ .../cypress-test-tenancy-disabled.yml | 1 + .github/workflows/cypress-test.yml | 1 + .github/workflows/dev-environment.yml | 91 +++++++++++++++++++ .github/workflows/integration-test.yml | 3 +- .github/workflows/manual-build.yml | 27 ++++++ .github/workflows/unit-test.yml | 5 +- README.md | 34 ++++--- public/apps/account/account-app.tsx | 2 +- public/apps/account/test/account-app.test.tsx | 4 +- public/apps/login/login-page.tsx | 9 +- .../__snapshots__/login-page.test.tsx.snap | 20 ++-- public/assets/ui/wazuh_logo.svg | 51 +++++++++++ server/index.ts | 14 +-- test/jest.config.server.js | 18 ++-- test/jest.config.ui.js | 12 +-- test/jest_integration/jwt_auth.test.ts | 12 +-- test/jest_integration/saml_auth.test.ts | 17 +++- test/jest_integration/saml_multiauth.test.ts | 8 +- 21 files changed, 357 insertions(+), 87 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/dev-environment.yml create mode 100644 .github/workflows/manual-build.yml create mode 100644 public/assets/ui/wazuh_logo.svg diff --git a/.github/actions/install-dashboards/action.yml b/.github/actions/install-dashboards/action.yml index f5383c39c..0151538b7 100644 --- a/.github/actions/install-dashboards/action.yml +++ b/.github/actions/install-dashboards/action.yml @@ -5,6 +5,9 @@ inputs: plugin_name: description: 'The the name of the plugin to use, such as security-dashboards-plugin' required: true + app_reference: + description: 'The reference to the app to use, such as main, v1.13, etc.' + required: true outputs: dashboards-directory: @@ -29,8 +32,8 @@ runs: - uses: actions/checkout@v2 with: path: OpenSearch-Dashboards - repository: opensearch-project/OpenSearch-Dashboards - ref: 'main' + repository: wazuh/wazuh-dashboard + ref: ${{ inputs.app_reference }} fetch-depth: 0 - uses: actions/checkout@v2 @@ -44,12 +47,12 @@ runs: working-directory: ${{ steps.determine-plugin-directory.outputs.plugin-directory }} shell: bash - - id: branch-switch-if-possible - continue-on-error: true # Defaults onto main if the branch switch doesn't work - if: ${{ steps.osd-version.outputs.osd-version }} - run: git checkout ${{ steps.osd-version.outputs.osd-version }} || git checkout ${{ steps.osd-version.outputs.osd-x-version }} - working-directory: ./OpenSearch-Dashboards - shell: bash + # - id: branch-switch-if-possible + # continue-on-error: true # Defaults onto main if the branch switch doesn't work + # if: ${{ steps.osd-version.outputs.osd-version }} + # run: git checkout ${{ steps.osd-version.outputs.osd-version }} || git checkout ${{ steps.osd-version.outputs.osd-x-version }}x + # working-directory: ./OpenSearch-Dashboards + # shell: bash - id: tool-versions run: | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..3abeaa497 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,19 @@ +# This workflow builds a production-ready package when a tag is created. +# +# This workflow is based on the `dev-environment` workflow. + +name: Build + +on: + push: + tags: + - 'v*' +jobs: + build: + name: Build app package (auto) + uses: ./.github/workflows/dev-environment.yml + with: + reference: ${{ github.ref_name }} + command: 'yarn build' + artifact_name: 'wazuh-security-dashboards-plugin-${{ github.ref_name }}' + artifact_path: './wazuh-security-plugin/build' \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..092c298a3 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,77 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "main", "[0-9].[0-9]", "[0-9].x" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '00 8 * * 5' + workflow_dispatch: + +jobs: + analyze: + name: Analyze + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + 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 + + # 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. + + # For more 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 + + # ℹ️ 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. + + # - 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}}" diff --git a/.github/workflows/cypress-test-tenancy-disabled.yml b/.github/workflows/cypress-test-tenancy-disabled.yml index 3c6c084cf..0f1150c0b 100644 --- a/.github/workflows/cypress-test-tenancy-disabled.yml +++ b/.github/workflows/cypress-test-tenancy-disabled.yml @@ -56,6 +56,7 @@ jobs: uses: ./.github/actions/install-dashboards with: plugin_name: security-dashboards-plugin + app_reference: ${{ vars.WZD_REF }} - name: Configure and Run OpenSearch Dashboards with Cypress Test Cases run: | diff --git a/.github/workflows/cypress-test.yml b/.github/workflows/cypress-test.yml index 745ef077d..e144bbe11 100644 --- a/.github/workflows/cypress-test.yml +++ b/.github/workflows/cypress-test.yml @@ -56,6 +56,7 @@ jobs: uses: ./.github/actions/install-dashboards with: plugin_name: security-dashboards-plugin + app_reference: ${{ vars.WZD_REF }} - name: Configure and Run OpenSearch Dashboards with Cypress Test Cases run: | diff --git a/.github/workflows/dev-environment.yml b/.github/workflows/dev-environment.yml new file mode 100644 index 000000000..1820c280f --- /dev/null +++ b/.github/workflows/dev-environment.yml @@ -0,0 +1,91 @@ +# This workflow downloads the source code at the given git reference +# (branch, tag or commit), an sets up an environment (Kibana or OpenSearch) +# to run this code and a command (build, test, ...). +# +# This workflow is used as a base for other workflows. + +name: Base workflow - Environment + +on: + workflow_call: + inputs: + reference: + required: true + type: string + default: master + description: Source code reference (branch, tag or commit SHA). + command: + required: true + type: string + default: 'yarn build' + description: Command to run in the environment + docker_run_extra_args: + type: string + default: '' + description: Additional paramaters for the docker run command. + required: false + artifact_name: + type: string + default: '' + description: Artifact name (will be automatically suffixed with .zip) + required: false + artifact_path: + type: string + default: '' + description: Folder to include in the archive. + required: false + notify_jest_coverage_summary: + type: boolean + default: false + required: false + +jobs: + # Deploy the plugin in a development environment and run a command + # using a pre-built Docker image, hosted in Quay.io. + deploy_and_run_command: + name: Deploy and run command + runs-on: ubuntu-latest + steps: + - name: Step 01 - Download the plugin's source code + uses: actions/checkout@v3 + with: + ref: ${{ inputs.reference }} + path: wazuh-security-plugin + + # Fix source code ownership so the internal user of the Docker + # container is also owner. + - name: Step 02 - Change code ownership + run: sudo chown 1000:1000 -R wazuh-security-plugin; + + - name: Step 03 - Set up the environment and run the command + run: | + # Read the platform version from the package.json file + echo "Reading the platform version from the package.json..."; + platform_version=$(jq -r '.opensearchDashboards.version | select(. != null)' wazuh-security-plugin/package.json); + echo "Plugin platform version: $platform_version"; + + # Up the environment and run the command + docker run -t --rm \ + -e OPENSEARCH_DASHBOARDS_VERSION=${platform_version} \ + -v `pwd`/wazuh-security-plugin:/home/node/kbn/plugins/wazuh-security-plugin \ + ${{ inputs.docker_run_extra_args }} \ + quay.io/wazuh/osd-dev:${platform_version} \ + bash -c ' + yarn config set registry https://registry.yarnpkg.com; + cd /home/node/kbn/plugins/wazuh-security-plugin && yarn && ${{ inputs.command }}; + ' + + - name: Step 04 - Upload artifact to GitHub + if: ${{ inputs.artifact_name && inputs.artifact_path }} + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.artifact_name }} + path: ${{ inputs.artifact_path }} + + - name: Step 05 - Upload coverage results to GitHub + if: ${{ inputs.notify_jest_coverage_summary && github.event_name == 'pull_request' }} + uses: AthleticNet/comment-test-coverage@1.2.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + path: ./wazuh-security-plugin/target/test-coverage/coverage-summary.json + title: "Code coverage (Jest)" \ No newline at end of file diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 7ac0dba0a..fd12f4fb5 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -69,7 +69,8 @@ jobs: - id: install-dashboards uses: ./.github/actions/install-dashboards with: - plugin_name: security-dashboards-plugin + plugin_name: wazuh-security-dashboards-plugin + app_reference: ${{ vars.WZD_REF }} - name: Start Dashboards in background run: node scripts/build_opensearch_dashboards_platform_plugins.js diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml new file mode 100644 index 000000000..80b798dbd --- /dev/null +++ b/.github/workflows/manual-build.yml @@ -0,0 +1,27 @@ +# This workflow builds a production-ready package from the given Git reference. +# Any branch, tag or commit SHA existing in the origin can be used. +# +# This workflow is based on the `dev-environment` workflow. + +name: Manual build + +on: + workflow_dispatch: + inputs: + reference: + required: true + type: string + default: master + description: Source code reference (branch, tag or commit SHA) + +jobs: + # Build an app package from the given source code reference. + build: + name: Build app package + uses: ./.github/workflows/dev-environment.yml + with: + reference: ${{ github.event.inputs.reference }} + command: 'yarn build' + artifact_name: 'wazuh-security-dashboards-plugin-${{ github.event.inputs.reference }}.zip' + artifact_path: './wazuh-security-plugin/build' + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index de2572654..1531a2104 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest , windows-latest, macos-latest ] + os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: @@ -22,7 +22,8 @@ jobs: - id: install-dashboards uses: ./.github/actions/install-dashboards with: - plugin_name: security-dashboards-plugin + plugin_name: wazuh-security-dashboards-plugin + app_reference: ${{ vars.WZD_REF }} - name: Run lint run: yarn lint diff --git a/README.md b/README.md index 40cc1497b..861b0ecc4 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,32 @@ -[![Unit tests](https://github.com/opensearch-project/security-dashboards-plugin/workflows/Unit%20Tests/badge.svg?branch=main)](https://github.com/opensearch-project/security-dashboards-plugin/actions)[![Integration tests](https://github.com/opensearch-project/security-dashboards-plugin/workflows/Integration%20Tests/badge.svg?branch=main)](https://github.com/opensearch-project/security-dashboards-plugin/actions)[![codecov](https://codecov.io/gh/opensearch-project/security-dashboards-plugin/branch/main/graphs/badge.svg)](https://github.com/opensearch-project/security-dashboards-plugin) +
+ +
- +# Wazuh Security Dashboards Plugin -# OpenSearch Dashboards Security Plugin +Wazuh Security Dashboards Plugin is a fork of the OpenSearch Dashboards Security Plugin which incorporate changes to make it easier to use for Wazuh users. Our aim is to contribute back any work not tied specifically to Wazuh. -This plugin for OpenSearch Dashboards adds a configuration management UI for the OpenSearch Security features, as well as authentication, session management and multi-tenancy support to your secured cluster. +This plugin for Wazuh Dashboard adds a configuration management UI for the Wazuh Security features, as well as authentication, session management and multi-tenancy support to your secured cluster. - [Features](#features) - [Installation](#installation) - [Contributing](#contributing) - [Getting Help](#getting-help) -- [Code of Conduct](#code-of-conduct) - [Security](#security) - [License](#license) - [Copyright](#copyright) ## Features -* OpenSearch Dashboards authentication for OpenSearch -* OpenSearch Dashboards session management -* OpenSearch Security configuration UI -* Multi-tenancy support for OpenSearch Dashboards -* OpenSearch audit logging configuration UI +* Wazuh Dashboard authentication for OpenSearch +* Wazuh Dashboard session management +* Wazuh Security configuration UI +* Multi-tenancy support for Wazuh Dashboard +* Wazuh audit logging configuration UI ## Installation -The OpenSearch Dashboards Security Plugin comes bundled by default as part of the OpenSearch Dashboards distribution. Please refer to the [installation guide](https://opensearch.org/docs/latest/dashboards/install/index/) and [technical documentation](https://opensearch.org/docs/latest/security-plugin/index/) for detailed information on installing and configuring the OpenSearch Security Plugin. +The Wazuh Security Dashboards Plugin comes bundled by default as part of the Wazuh Dashboards distribution. Please refer to the [installation guide](https://documentation.wazuh.com/current/installation-guide/index.html). ## Contributing @@ -35,15 +36,11 @@ See [developer guide](DEVELOPER_GUIDE.md) and [how to contribute to this project If you find a bug, or have a feature request, please don't hesitate to open an issue in this repository. -For more information, see [project website](https://opensearch.org/) and [documentation](https://opensearch.org/docs/latest). If you need help and are unsure where to open an issue, try [forums](https://discuss.opendistrocommunity.dev/). - -## Code of Conduct - -This project has adopted the [Amazon Open Source Code of Conduct](CODE_OF_CONDUCT.md). For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq), or contact [opensource-codeofconduct@amazon.com](mailto:opensource-codeofconduct@amazon.com) with any additional questions or comments. +For more information, see [project website](https://wazuh.com/) and [documentation](https://documentation.wazuh.com/current/index.html). If you need help and are unsure where to open an [issue](https://github.com/wazuh/wazuh-security-dashboards-plugin/issues). ## Security -If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public GitHub issue. +If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](https://github.com/wazuh/wazuh-security-dashboards-plugin/issues/new/choose). Please do **not** create a public GitHub issue. ## License @@ -51,4 +48,5 @@ This code is licensed under the Apache 2.0 License. ## Copyright -Copyright OpenSearch Contributors. See [NOTICE](NOTICE.txt) for details. \ No newline at end of file +- Copyright OpenSearch Contributors. See [NOTICE](NOTICE.txt) for details. +- Copyright Wazuh, Inc. diff --git a/public/apps/account/account-app.tsx b/public/apps/account/account-app.tsx index ebcd15d5a..0e8aa51b5 100644 --- a/public/apps/account/account-app.tsx +++ b/public/apps/account/account-app.tsx @@ -96,7 +96,7 @@ export async function setupTopNavButton(coreStart: CoreStart, config: ClientConf } } - setShouldShowTenantPopup(shouldShowTenantPopup); + setShouldShowTenantPopup(false); coreStart.chrome.navControls.registerRight({ // Pin to rightmost, since newsfeed plugin is using 1000, here needs a number > 1000 diff --git a/public/apps/account/test/account-app.test.tsx b/public/apps/account/test/account-app.test.tsx index 21e61d375..7266deb53 100644 --- a/public/apps/account/test/account-app.test.tsx +++ b/public/apps/account/test/account-app.test.tsx @@ -105,14 +105,14 @@ describe('Account app', () => { }); }); - it('Should show tenant selection popup when neither securitytenant in url nor saved tenant', (done) => { + it('Should not show tenant selection popup', (done) => { (getSavedTenant as jest.Mock).mockReturnValueOnce(null); setupTopNavButton(mockCoreStart, mockConfig as any); process.nextTick(() => { expect(getSavedTenant).toBeCalledTimes(1); - expect(setShouldShowTenantPopup).toBeCalledWith(true); + expect(setShouldShowTenantPopup).toBeCalledWith(false); done(); }); }); diff --git a/public/apps/login/login-page.tsx b/public/apps/login/login-page.tsx index 22421e3a7..c599623aa 100644 --- a/public/apps/login/login-page.tsx +++ b/public/apps/login/login-page.tsx @@ -28,6 +28,7 @@ import { } from '@elastic/eui'; import { CoreStart } from '../../../../../src/core/public'; import { ClientConfigType } from '../../types'; +import defaultBrandImage from '../../assets/ui/wazuh_logo.svg'; import { validateCurrentPassword } from '../../utils/login-utils'; import { ANONYMOUS_AUTH_LOGIN, @@ -253,23 +254,23 @@ export function LoginPage(props: LoginPageDeps) { }; // TODO: Get brand image from server config + // Don't force custom logo to have 100% width. It should be handled in the svg properties if needed. (Removed fullWidth in the image) return ( {props.config.ui.basicauth.login.showbrandimage && ( )} - {props.config.ui.basicauth.login.title || 'Log in to OpenSearch Dashboards'} + {props.config.ui.basicauth.login.title || ''} - {props.config.ui.basicauth.login.subtitle || - 'If you have forgotten your username or password, contact your system administrator.'} + {props.config.ui.basicauth.login.subtitle || ''} diff --git a/public/apps/login/test/__snapshots__/login-page.test.tsx.snap b/public/apps/login/test/__snapshots__/login-page.test.tsx.snap index c2dac62c1..556f3403c 100644 --- a/public/apps/login/test/__snapshots__/login-page.test.tsx.snap +++ b/public/apps/login/test/__snapshots__/login-page.test.tsx.snap @@ -366,7 +366,7 @@ exports[`Login page renders renders with default value: string 1`] = ` - Log in to OpenSearch Dashboards - + /> - If you have forgotten your username or password, contact your system administrator. - + /> @@ -469,7 +465,7 @@ exports[`Login page renders renders with default value: string array 1`] = ` - Log in to OpenSearch Dashboards - + /> - If you have forgotten your username or password, contact your system administrator. - + /> diff --git a/public/assets/ui/wazuh_logo.svg b/public/assets/ui/wazuh_logo.svg new file mode 100644 index 000000000..b74126093 --- /dev/null +++ b/public/assets/ui/wazuh_logo.svg @@ -0,0 +1,51 @@ + + + + + + Layer 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/index.ts b/server/index.ts index b4384315a..60d795af7 100644 --- a/server/index.ts +++ b/server/index.ts @@ -132,11 +132,8 @@ export const configSchema = schema.object({ }), loadbalancer_url: schema.maybe(schema.string()), login: schema.object({ - title: schema.string({ defaultValue: 'Log in to OpenSearch Dashboards' }), - subtitle: schema.string({ - defaultValue: - 'If you have forgotten your username or password, contact your system administrator.', - }), + title: schema.string({ defaultValue: '' }), + subtitle: schema.string({ defaultValue: '' }), showbrandimage: schema.boolean({ defaultValue: true }), brandimage: schema.string({ defaultValue: '' }), // TODO: update brand image buttonstyle: schema.string({ defaultValue: '' }), @@ -234,11 +231,8 @@ export const configSchema = schema.object({ // the login config here is the same as old config `_security.basicauth.login` // Since we are now rendering login page to browser app, so move these config to browser side. login: schema.object({ - title: schema.string({ defaultValue: 'Log in to OpenSearch Dashboards' }), - subtitle: schema.string({ - defaultValue: - 'If you have forgotten your username or password, contact your system administrator.', - }), + title: schema.string({ defaultValue: '' }), + subtitle: schema.string({ defaultValue: '' }), showbrandimage: schema.boolean({ defaultValue: true }), brandimage: schema.string({ defaultValue: '' }), buttonstyle: schema.string({ defaultValue: '' }), diff --git a/test/jest.config.server.js b/test/jest.config.server.js index 783003154..f625ee260 100644 --- a/test/jest.config.server.js +++ b/test/jest.config.server.js @@ -17,24 +17,24 @@ import config from '../../../src/dev/jest/config'; export default { ...config, - roots: ['/plugins/security-dashboards-plugin'], + roots: ['/plugins/wazuh-security-dashboards-plugin'], testMatch: ['**/test/jest_integration/**/*.test.ts', '**/server/**/*.test.ts'], testPathIgnorePatterns: config.testPathIgnorePatterns.filter( (pattern) => !pattern.includes('integration_tests') ), setupFilesAfterEnv: [ '/src/dev/jest/setup/after_env.integration.js', - '/plugins/security-dashboards-plugin/test/setup/after_env.js', + '/plugins/wazuh-security-dashboards-plugin/test/setup/after_env.js', ], collectCoverageFrom: [ - '/plugins/security-dashboards-plugin/server/**/*.{ts,tsx}', - '!/plugins/security-dashboards-plugin/server/**/*.test.{ts,tsx}', - '!/plugins/security-dashboards-plugin/server/auth/types/jwt/**/*.{ts,tsx}', - '!/plugins/security-dashboards-plugin/server/auth/types/openid/**/*.{ts,tsx}', - '!/plugins/security-dashboards-plugin/server/auth/types/saml/**/*.{ts,tsx}', - '!/plugins/security-dashboards-plugin/server/auth/types/proxy/**/*.{ts,tsx}', + '/plugins/wazuh-security-dashboards-plugin/server/**/*.{ts,tsx}', + '!/plugins/wazuh-security-dashboards-plugin/server/**/*.test.{ts,tsx}', + '!/plugins/wazuh-security-dashboards-plugin/server/auth/types/jwt/**/*.{ts,tsx}', + '!/plugins/wazuh-security-dashboards-plugin/server/auth/types/openid/**/*.{ts,tsx}', + '!/plugins/wazuh-security-dashboards-plugin/server/auth/types/saml/**/*.{ts,tsx}', + '!/plugins/wazuh-security-dashboards-plugin/server/auth/types/proxy/**/*.{ts,tsx}', ], coverageDirectory: - '/plugins/security-dashboards-plugin/opensearch-dashboards-coverage/jest_server', + '/plugins/wazuh-security-dashboards-plugin/opensearch-dashboards-coverage/jest_server', coverageReporters: ['lcov', 'text', 'cobertura', 'html'], }; diff --git a/test/jest.config.ui.js b/test/jest.config.ui.js index b3ec9bc2e..dfe15acbe 100644 --- a/test/jest.config.ui.js +++ b/test/jest.config.ui.js @@ -17,19 +17,19 @@ import config from '../../../src/dev/jest/config'; export default { ...config, - roots: ['/plugins/security-dashboards-plugin'], + roots: ['/plugins/wazuh-security-dashboards-plugin'], testMatch: ['**/public/**/*.test.{ts,tsx,js,jsx}', '**/common/*.test.{ts, tsx}'], testPathIgnorePatterns: [ - '/plugins/security-dashboards-plugin/build/', - '/plugins/security-dashboards-plugin/node_modules/', + '/plugins/wazuh-security-dashboards-plugin/build/', + '/plugins/wazuh-security-dashboards-plugin/node_modules/', ], setupFilesAfterEnv: ['/src/dev/jest/setup/after_env.integration.js'], collectCoverageFrom: [ - '/plugins/security-dashboards-plugin/public/**/*.{ts,tsx}', - '!/plugins/security-dashboards-plugin/public/**/*.test.{ts,tsx}', + '/plugins/wazuh-security-dashboards-plugin/public/**/*.{ts,tsx}', + '!/plugins/wazuh-security-dashboards-plugin/public/**/*.test.{ts,tsx}', ], coverageDirectory: - '/plugins/security-dashboards-plugin/opensearch-dashboards-coverage/jest_ui', + '/plugins/wazuh-security-dashboards-plugin/opensearch-dashboards-coverage/jest_ui', clearMocks: true, coverageReporters: ['lcov', 'text', 'cobertura', 'html'], }; diff --git a/test/jest_integration/jwt_auth.test.ts b/test/jest_integration/jwt_auth.test.ts index 0fee425be..d6a824340 100644 --- a/test/jest_integration/jwt_auth.test.ts +++ b/test/jest_integration/jwt_auth.test.ts @@ -219,8 +219,8 @@ describe('start OpenSearch Dashboards server', () => { // shutdown OpenSearchDashboards server await root.shutdown(); }); - - it('Login to app/opensearch_dashboards_overview#/ when JWT is enabled', async () => { + // Wazuh: Skip test because overview page is disabled + it.skip('Login to app/opensearch_dashboards_overview#/ when JWT is enabled', async () => { const payload = { sub: 'jwt_test', roles: 'admin,kibanauser', @@ -267,8 +267,8 @@ describe('start OpenSearch Dashboards server', () => { await driver.manage().deleteAllCookies(); await driver.quit(); }); - - it('Login to app/opensearch_dashboards_overview#/ when JWT is enabled with invalid token', async () => { + // Wazuh: Skip test because overview page is disabled + it.skip('Login to app/opensearch_dashboards_overview#/ when JWT is enabled with invalid token', async () => { const payload = { sub: 'jwt_test', roles: 'admin,kibanauser', @@ -294,8 +294,8 @@ describe('start OpenSearch Dashboards server', () => { await driver.manage().deleteAllCookies(); await driver.quit(); }); - - it('Login to app/dev_tools#/console when JWT is enabled with invalid token', async () => { + // Wazuh: Skip test because this issue https://github.com/opensearch-project/security-dashboards-plugin/issues/1540 + it.skip('Login to app/dev_tools#/console when JWT is enabled with invalid token', async () => { const payload = { sub: 'jwt_test', roles: 'admin,kibanauser', diff --git a/test/jest_integration/saml_auth.test.ts b/test/jest_integration/saml_auth.test.ts index 7123baf15..cf79a2cb9 100644 --- a/test/jest_integration/saml_auth.test.ts +++ b/test/jest_integration/saml_auth.test.ts @@ -47,6 +47,7 @@ describe('start OpenSearch Dashboards server', () => { plugins: { scanDirs: [resolve(__dirname, '../..')], }, + home: { disableWelcomeScreen: true }, server: { host: 'localhost', port: 5601, @@ -237,7 +238,12 @@ describe('start OpenSearch Dashboards server', () => { await root.shutdown(); }); - it('Login to app/opensearch_dashboards_overview#/ when SAML is enabled', async () => { + // --------------------------------------------------------------------- + // As we disabled the opensearch_dashboards_overview in Wazuh Dashboard, + // this test will never success. Also, multi-tenancy was disabled. + // --------------------------------------------------------------------- + + it.skip('Login to app/opensearch_dashboards_overview#/ when SAML is enabled', async () => { const driver = getDriver(browser, options).build(); await driver.get('http://localhost:5601/app/opensearch_dashboards_overview#/'); await driver.findElement(By.id('btn-sign-in')).click(); @@ -265,8 +271,13 @@ describe('start OpenSearch Dashboards server', () => { await driver.quit(); }); - it('Login to Dashboard with Hash', async () => { - const urlWithHash = `http://localhost:5601/app/dashboards#/view/7adfa750-4c81-11e8-b3d7-01146121b73d?_g=(filters:!(),refreshInterval:(pause:!f,value:900000),time:(from:now-24h,to:now))&_a=(description:'Analyze%20mock%20flight%20data%20for%20OpenSearch-Air,%20Logstash%20Airways,%20OpenSearch%20Dashboards%20Airlines%20and%20BeatsWest',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),query:(language:kuery,query:''),timeRestore:!t,title:'%5BFlights%5D%20Global%20Flight%20Dashboard',viewMode:view)`; + // --------------------------------------------------------------------- + // As we disabled the opensearch_dashboards_overview in Wazuh Dashboard, + // this test will never success. Also, multi-tenancy was disabled. + // --------------------------------------------------------------------- + + it.skip('Login to Dashboard with Hash', async () => { + const urlWithHash = `http://localhost:5601/app/security-dashboards-plugin#/getstarted`; const driver = getDriver(browser, options).build(); await driver.manage().deleteAllCookies(); await driver.get(urlWithHash); diff --git a/test/jest_integration/saml_multiauth.test.ts b/test/jest_integration/saml_multiauth.test.ts index c29c88085..4d5855fe6 100644 --- a/test/jest_integration/saml_multiauth.test.ts +++ b/test/jest_integration/saml_multiauth.test.ts @@ -43,6 +43,7 @@ describe('start OpenSearch Dashboards server', () => { plugins: { scanDirs: [resolve(__dirname, '../..')], }, + home: { disableWelcomeScreen: true }, server: { host: 'localhost', port: 5601, @@ -235,8 +236,8 @@ describe('start OpenSearch Dashboards server', () => { }); it('Login to Dashboards and resume from nextUrl', async () => { - const urlWithHash = `http://localhost:5601/app/dashboards#/view/7adfa750-4c81-11e8-b3d7-01146121b73d?_g=(filters:!(),refreshInterval:(pause:!f,value:900000),time:(from:now-24h,to:now))&_a=(description:'Analyze%20mock%20flight%20data%20for%20OpenSearch-Air,%20Logstash%20Airways,%20OpenSearch%20Dashboards%20Airlines%20and%20BeatsWest',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),query:(language:kuery,query:''),timeRestore:!t,title:'%5BFlights%5D%20Global%20Flight%20Dashboard',viewMode:view)`; - const loginUrlWithNextUrl = `http://localhost:5601/app/login?nextUrl=%2Fapp%2Fdashboards#/view/7adfa750-4c81-11e8-b3d7-01146121b73d?_g=(filters:!(),refreshInterval:(pause:!f,value:900000),time:(from:now-24h,to:now))&_a=(description:'Analyze%20mock%20flight%20data%20for%20OpenSearch-Air,%20Logstash%20Airways,%20OpenSearch%20Dashboards%20Airlines%20and%20BeatsWest',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),query:(language:kuery,query:''),timeRestore:!t,title:'%5BFlights%5D%20Global%20Flight%20Dashboard',viewMode:view)`; + const urlWithHash = `http://localhost:5601/app/security-dashboards-plugin#/getstarted`; + const loginUrlWithNextUrl = `http://localhost:5601/app/login?nextUrl=%2Fapp%2Fsecurity-dashboards-plugin#/getstarted`; const driver = getDriver(browser, options).build(); await driver.manage().deleteAllCookies(); await driver.get(loginUrlWithNextUrl); @@ -259,7 +260,7 @@ describe('start OpenSearch Dashboards server', () => { }); it('Login to Dashboards without nextUrl', async () => { - const urlWithoutHash = `http://localhost:5601/app/home`; + const urlWithoutHash = `http://localhost:5601/app/home#/`; const loginUrl = `http://localhost:5601/app/login`; const driver = getDriver(browser, options).build(); await driver.manage().deleteAllCookies(); @@ -273,6 +274,7 @@ describe('start OpenSearch Dashboards server', () => { until.elementsLocated(By.xpath('/html/body/div[1]/div/header/div/div[2]')), 20000 ); + await driver.wait(until.elementsLocated(By.css('img[data-test-subj="defaultLogo"]')), 20000); const windowHash = await driver.getCurrentUrl(); console.log('windowHash: ' + windowHash); expect(windowHash).toEqual(urlWithoutHash);