From ecc572192595bff5289aca9c2d66a02264ebb41a Mon Sep 17 00:00:00 2001 From: Federico Rodriguez Date: Thu, 20 Apr 2023 19:12:09 +0200 Subject: [PATCH 1/6] Change Wazuh logo and titles --- public/apps/login/login-page.tsx | 7 ++- .../__snapshots__/login-page.test.tsx.snap | 16 ++---- public/assets/ui/wazuh_logo.svg | 51 +++++++++++++++++++ server/index.ts | 8 +-- test/jest.config.server.js | 16 +++--- test/jest.config.ui.js | 12 ++--- test/jest_integration/saml_auth.test.ts | 12 +++++ 7 files changed, 88 insertions(+), 34 deletions(-) create mode 100644 public/assets/ui/wazuh_logo.svg diff --git a/public/apps/login/login-page.tsx b/public/apps/login/login-page.tsx index 3179ad1be..8cd626a79 100644 --- a/public/apps/login/login-page.tsx +++ b/public/apps/login/login-page.tsx @@ -28,7 +28,7 @@ import { } from '@elastic/eui'; import { CoreStart } from '../../../../../src/core/public'; import { ClientConfigType } from '../../types'; -import defaultBrandImage from '../../assets/opensearch_logo_h.svg'; +import defaultBrandImage from '../../assets/ui/wazuh_logo.svg'; import { validateCurrentPassword } from '../../utils/login-utils'; import { ANONYMOUS_AUTH_LOGIN, @@ -250,12 +250,11 @@ export function LoginPage(props: LoginPageDeps) { )} - {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 4381088ee..77f0d138e 100644 --- a/public/apps/login/test/__snapshots__/login-page.test.tsx.snap +++ b/public/apps/login/test/__snapshots__/login-page.test.tsx.snap @@ -374,18 +374,14 @@ 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. - + /> @@ -477,18 +473,14 @@ 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 c6cab52b6..8f23807e0 100644 --- a/server/index.ts +++ b/server/index.ts @@ -132,10 +132,10 @@ export const configSchema = schema.object({ }), loadbalancer_url: schema.maybe(schema.string()), login: schema.object({ - title: schema.string({ defaultValue: 'Log in to OpenSearch Dashboards' }), + title: schema.string({ defaultValue: '' }), subtitle: schema.string({ defaultValue: - 'If you have forgotten your username or password, contact your system administrator.', + '', }), showbrandimage: schema.boolean({ defaultValue: true }), brandimage: schema.string({ defaultValue: '' }), // TODO: update brand image @@ -220,10 +220,10 @@ 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' }), + title: schema.string({ defaultValue: '' }), subtitle: schema.string({ defaultValue: - 'If you have forgotten your username or password, contact your system administrator.', + '', }), showbrandimage: schema.boolean({ defaultValue: true }), brandimage: schema.string({ defaultValue: '' }), diff --git a/test/jest.config.server.js b/test/jest.config.server.js index 85b3c81ad..30c8c27c9 100644 --- a/test/jest.config.server.js +++ b/test/jest.config.server.js @@ -17,21 +17,21 @@ 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'], 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/saml_auth.test.ts b/test/jest_integration/saml_auth.test.ts index 53d2a951e..29173dcc5 100644 --- a/test/jest_integration/saml_auth.test.ts +++ b/test/jest_integration/saml_auth.test.ts @@ -236,6 +236,11 @@ describe('start OpenSearch Dashboards server', () => { await root.shutdown(); }); + // --------------------------------------------------------------------- + // As we disabled the opensearch_dashboards_overview in Wazuh Dashboard, + // this test will never success. Also, multi-tenancy was disabled. + // --------------------------------------------------------------------- + /** it('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#/'); @@ -247,6 +252,7 @@ describe('start OpenSearch Dashboards server', () => { await driver.manage().deleteAllCookies(); await driver.quit(); }); + */ it('Login to app/dev_tools#/console when SAML is enabled', async () => { const driver = getDriver(browser, options).build(); @@ -264,6 +270,11 @@ describe('start OpenSearch Dashboards server', () => { await driver.quit(); }); + // --------------------------------------------------------------------- + // As we disabled the opensearch_dashboards_overview in Wazuh Dashboard, + // this test will never success. Also, multi-tenancy was disabled. + // --------------------------------------------------------------------- + /** 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)`; const driver = getDriver(browser, options).build(); @@ -331,6 +342,7 @@ describe('start OpenSearch Dashboards server', () => { expect(tenantName).toEqual('Global'); }); + */ }); function getDriver(browser: string, options: Options) { From 316949db77204d4ad72f9bc75c390de4d031590b Mon Sep 17 00:00:00 2001 From: yenienserrano Date: Tue, 9 May 2023 16:42:34 +0200 Subject: [PATCH 2/6] Don't force custom logo to have 100% width --- public/apps/login/login-page.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/public/apps/login/login-page.tsx b/public/apps/login/login-page.tsx index 8cd626a79..6b8484ab0 100644 --- a/public/apps/login/login-page.tsx +++ b/public/apps/login/login-page.tsx @@ -242,11 +242,7 @@ export function LoginPage(props: LoginPageDeps) { return ( {props.config.ui.basicauth.login.showbrandimage && ( - + )} From 80ec6e97585c3bb06594a1f10f3116d4433681e5 Mon Sep 17 00:00:00 2001 From: yenienserrano Date: Tue, 9 May 2023 16:45:56 +0200 Subject: [PATCH 3/6] Add comment --- public/apps/login/login-page.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/apps/login/login-page.tsx b/public/apps/login/login-page.tsx index 6b8484ab0..2aaf4d712 100644 --- a/public/apps/login/login-page.tsx +++ b/public/apps/login/login-page.tsx @@ -239,6 +239,7 @@ 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 && ( @@ -250,7 +251,7 @@ export function LoginPage(props: LoginPageDeps) { - {props.config.ui.basicauth.login.subtitle ||''} + {props.config.ui.basicauth.login.subtitle || ''} From bf8041f45bd30e9aa3acb1e975b32c87cebf7a46 Mon Sep 17 00:00:00 2001 From: yenienserrano Date: Tue, 9 May 2023 17:35:33 +0200 Subject: [PATCH 4/6] Fix lint --- server/index.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/server/index.ts b/server/index.ts index 8f23807e0..b8ea21925 100644 --- a/server/index.ts +++ b/server/index.ts @@ -133,10 +133,7 @@ export const configSchema = schema.object({ loadbalancer_url: schema.maybe(schema.string()), login: schema.object({ title: schema.string({ defaultValue: '' }), - subtitle: schema.string({ - defaultValue: - '', - }), + subtitle: schema.string({ defaultValue: '' }), showbrandimage: schema.boolean({ defaultValue: true }), brandimage: schema.string({ defaultValue: '' }), // TODO: update brand image buttonstyle: schema.string({ defaultValue: '' }), @@ -221,10 +218,7 @@ export const configSchema = schema.object({ // Since we are now rendering login page to browser app, so move these config to browser side. login: schema.object({ title: schema.string({ defaultValue: '' }), - subtitle: schema.string({ - defaultValue: - '', - }), + subtitle: schema.string({ defaultValue: '' }), showbrandimage: schema.boolean({ defaultValue: true }), brandimage: schema.string({ defaultValue: '' }), buttonstyle: schema.string({ defaultValue: '' }), From e86ec44c585ed66e3c6aa5ef9d718a1614e87362 Mon Sep 17 00:00:00 2001 From: yenienserrano Date: Wed, 10 May 2023 14:11:13 +0200 Subject: [PATCH 5/6] Fix prettier --- test/jest_integration/saml_auth.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/jest_integration/saml_auth.test.ts b/test/jest_integration/saml_auth.test.ts index 39a22bd64..b5f2e3cda 100644 --- a/test/jest_integration/saml_auth.test.ts +++ b/test/jest_integration/saml_auth.test.ts @@ -253,7 +253,6 @@ describe('start OpenSearch Dashboards server', () => { await driver.quit(); }); - it('Login to app/dev_tools#/console when SAML is enabled', async () => { const driver = getDriver(browser, options).build(); await driver.get('http://localhost:5601/app/dev_tools#/console'); From c53e44c651f3fa2413e8eaa75cab50fdf57bee27 Mon Sep 17 00:00:00 2001 From: yenienserrano Date: Wed, 10 May 2023 14:31:31 +0200 Subject: [PATCH 6/6] Update snapshots --- .../apps/login/test/__snapshots__/login-page.test.tsx.snap | 5 ----- 1 file changed, 5 deletions(-) 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 77f0d138e..f0ed90a38 100644 --- a/public/apps/login/test/__snapshots__/login-page.test.tsx.snap +++ b/public/apps/login/test/__snapshots__/login-page.test.tsx.snap @@ -6,7 +6,6 @@ exports[`Login page renders renders with config value for multiauth 1`] = ` >