Enhance Wazuh integration by adding version, revision, and stage on wz dashboard - #1327
Conversation
…data. Update related interfaces and mocks to support new properties across the application.
❌ 16 Jest Test Failure(s)📄
|
…faces This commit introduces a new step in the build workflow to set the production flag in VERSION.json based on the deployment stage. Additionally, it updates various interfaces and mocks across the application to include the new property, ensuring consistent handling of this metadata throughout the codebase.
This commit removes the production flag handling from the build workflow and integrates it directly into the package.json during the build process. It also introduces a new WazuhBuildInfo interface to encapsulate version, revision, stage, and production status, updating various components and mocks across the application to utilize this new structure for consistent metadata management.
There was a problem hiding this comment.
🔴 Tests:
I'm getting the following error when installing the wazuh-dashboard dependencies:
Server output:
wazuh-dashboard enhancement/8550-enhance-the-download-and-install-the-agent-command ? ✗ yarn osd bootstrap
yarn run v1.22.19
$ scripts/use_node scripts/osd bootstrap
info [opensearch-dashboards] running yarn
$ scripts/use_node ./preinstall_check
[1/5] Validating package.json...
[2/5] Resolving packages...
warning Resolution field "typescript@4.6.4" is incompatible with requested version "typescript@^5.3.3"
warning Resolution field "typescript@4.6.4" is incompatible with requested version "typescript@~4.5.2"
warning Lockfile has incorrect entry for "serialize-javascript@^6.0.2". Ignoring it.
(node:220735) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
warning Resolution field "langsmith@0.4.7" is incompatible with requested version "langsmith@^0.3.67"
[3/5] Fetching packages...
warning bare-fs@4.0.1: The engine "bare" appears to be invalid.
warning bare-os@3.5.1: The engine "bare" appears to be invalid.
warning @zip.js/zip.js@2.8.16: The engine "deno" appears to be invalid.
warning @zip.js/zip.js@2.8.16: The engine "bun" appears to be invalid.
[4/5] Linking dependencies...
warning "workspace-aggregator-ef4ea71e-e774-4e34-9aae-3927edc79b45 > osd_tp_run_pipeline > @elastic/eui@1.22.1" has incorrect peer dependency "@types/react@^16.9.34".
warning "workspace-aggregator-ef4ea71e-e774-4e34-9aae-3927edc79b45 > osd_tp_run_pipeline > @elastic/eui@1.22.1" has incorrect peer dependency "@types/react-dom@^16.9.6".
warning "workspace-aggregator-ef4ea71e-e774-4e34-9aae-3927edc79b45 > osd_tp_run_pipeline > @elastic/eui@1.22.1" has incorrect peer dependency "react@^16.12".
warning "workspace-aggregator-ef4ea71e-e774-4e34-9aae-3927edc79b45 > osd_tp_run_pipeline > @elastic/eui@1.22.1" has incorrect peer dependency "react-dom@^16.12".
warning "@elastic/eui > react-ace@7.0.5" has incorrect peer dependency "react@^0.13.0 || ^0.14.0 || ^15.0.1 || ^16.0.0".
warning "@elastic/eui > react-ace@7.0.5" has incorrect peer dependency "react-dom@^0.13.0 || ^0.14.0 || ^15.0.1 || ^16.0.0".
warning "@elastic/eui > react-beautiful-dnd > use-memo-one@1.1.2" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
warning "@elastic/eui > react-focus-on > react-style-singleton@2.1.1" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
warning "@elastic/eui > react-focus-on > use-callback-ref@1.2.5" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
warning "@elastic/eui > react-focus-on > use-sidecar@1.0.5" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
warning "@elastic/eui > react-focus-on > react-focus-lock > react-clientside-effect@1.2.5" has incorrect peer dependency "react@^15.3.0 || ^16.0.0 || ^17.0.0".
warning "@elastic/eui > react-focus-on > react-remove-scroll > react-remove-scroll-bar@2.2.0" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
warning "@osd/apm-topology > @osd/i18n > react-intl@2.9.0" has incorrect peer dependency "react@^0.14.9 || ^15.0.0 || ^16.0.0".
warning "@osd/interpreter > url-loader@2.3.0" has incorrect peer dependency "webpack@^4.0.0".
warning " > @elastic/charts@31.1.0" has incorrect peer dependency "react@^16.12.0".
warning " > @elastic/charts@31.1.0" has incorrect peer dependency "react-dom@^16.12.0".
warning "@osd/ui-framework > @osd/optimizer > @osd/ui-shared-deps > react-router > mini-create-react-context@0.4.1" has incorrect peer dependency "react@^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0".
warning "workspace-aggregator-ef4ea71e-e774-4e34-9aae-3927edc79b45 > http-aws-es@6.0.1" has unmet peer dependency "aws-sdk@^2.138.0".
warning "workspace-aggregator-ef4ea71e-e774-4e34-9aae-3927edc79b45 > http-aws-es@6.0.1" has incorrect peer dependency "elasticsearch@^15.0.0".
warning " > @cypress/webpack-preprocessor@6.0.2" has unmet peer dependency "@babel/preset-env@^7.0.0".
warning " > @cypress/webpack-preprocessor@6.0.2" has incorrect peer dependency "babel-loader@^8.3 || ^9".
warning "react-grid-layout > react-resizable@1.11.1" has incorrect peer dependency "react@0.14.x || 15.x || 16.x || 17.x".
warning "react-grid-layout > react-resizable@1.11.1" has incorrect peer dependency "react-dom@0.14.x || 15.x || 16.x || 17.x".
warning " > react-sizeme@2.6.12" has incorrect peer dependency "react@^0.14.0 || ^15.0.0-0 || ^16.0.0".
warning " > react-sizeme@2.6.12" has incorrect peer dependency "react-dom@^0.14.0 || ^15.0.0-0 || ^16.0.0".
warning Workspaces can only be enabled in private projects.
warning Workspaces can only be enabled in private projects.
[5/5] Building fresh packages...
success Saved lockfile.
$ scripts/use_node scripts/postinstall
Patching node_modules/font-awesome/scss/_variables.scss
Patching node_modules/@elastic/charts/dist/theme.scss
Patching node_modules/rison-node/js/rison.js
succ yarn.lock analysis completed without any issues
info [@osd/cross-platform] running [osd:bootstrap] script
info [@osd/stylelint-plugin-stylelint] running [osd:bootstrap] script
info [@osd/test-subj-selector] running [osd:bootstrap] script
info [@osd/utility-types] running [osd:bootstrap] script
(node:220720) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
succ [@osd/test-subj-selector] bootstrap complete
succ [@osd/utility-types] bootstrap complete
succ [@osd/stylelint-plugin-stylelint] bootstrap complete
succ [@osd/cross-platform] bootstrap complete
info [@osd/config-schema] running [osd:bootstrap] script
info [@osd/std] running [osd:bootstrap] build targets
succ [@osd/config-schema] bootstrap complete
(node:222019) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:222018) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
succ [@osd/std] bootstrap complete
info [@osd/logging] running [osd:bootstrap] script
info [@osd/utils] running [osd:bootstrap] script
succ [@osd/logging] bootstrap complete
succ [@osd/utils] bootstrap complete
info [@osd/apm-config-loader] running [osd:bootstrap] script
info [@osd/dev-utils] running [osd:bootstrap] script
succ [@osd/apm-config-loader] bootstrap complete
succ [@osd/dev-utils] bootstrap complete
info [@osd/ace] running [osd:bootstrap] build targets
info [@osd/analytics] running [osd:bootstrap] script
info [@osd/antlr-grammar] running [osd:bootstrap] script
info [@osd/config] running [osd:bootstrap] script
(node:222469) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
succ [@osd/analytics] bootstrap complete
info [@osd/i18n] running [osd:bootstrap] build targets
succ [@osd/config] bootstrap complete
info [@osd/opensearch] running [osd:bootstrap] script
succ [@osd/ace] bootstrap complete
info [@osd/plugin-generator] running [osd:bootstrap] script
(node:222572) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:222571) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
succ [@osd/opensearch] bootstrap complete
info [@osd/telemetry-tools] running [osd:bootstrap] script
succ [@osd/i18n] bootstrap complete
info [@osd/test] running [osd:bootstrap] script
succ [@osd/plugin-generator] bootstrap complete
succ [@osd/telemetry-tools] bootstrap complete
succ [@osd/antlr-grammar] bootstrap complete
succ [@osd/test] bootstrap complete
info [@osd/apm-topology] running [osd:bootstrap] script
info [@osd/interpreter] running [osd:bootstrap] script
info [@osd/monaco] running [osd:bootstrap] script
info [@osd/opensearch-archiver] running [osd:bootstrap] script
succ [@osd/interpreter] bootstrap complete
succ [@osd/opensearch-archiver] bootstrap complete
succ [@osd/monaco] bootstrap complete
succ [@osd/apm-topology] bootstrap complete
info [@osd/ui-shared-deps] running [osd:bootstrap] script
succ [@osd/ui-shared-deps] bootstrap complete
info [@osd/optimizer] running [osd:bootstrap] script
^[[D succ [@osd/optimizer] bootstrap complete
info [@osd/plugin-helpers] running [osd:bootstrap] script
succ [@osd/plugin-helpers] bootstrap complete
info [opensearch-dashboards] running [osd:bootstrap] script
ERROR [bootstrap] failed:
ERROR Error: Command failed with exit code 1: /home/runner/.local/share/mise/installs/yarn/1.22.19/bin/yarn.js run osd:bootstrap
error Command failed with exit code 1.
$ scripts/use_node scripts/build_ts_refs && scripts/use_node scripts/register_git_hook
ERROR Error: Command failed with exit code 2: /home/runner/Documents/Wazuh/repos/wazuh-dashboard/node_modules/typescript/bin/tsc -b tsconfig.refs.json --pretty
src/core/public/injected_metadata/injected_metadata_service.mock.ts:81:48 - error TS2345: Argument of type '{ enabled: true; checks_enabled: string; retries_delay: number; interval: number; server_not_ready_troubleshooting_link: string; }' is not assignable to parameter of type 'HealthCheckConfig'.
Property 'max_retries' is missing in type '{ enabled: true; checks_enabled: string; retries_delay: number; interval: number; server_not_ready_troubleshooting_link: string; }' but required in type 'Omit<HealthCheckConfigDefinition, "interval" | "retries_delay">'.
81 setupContract.getHealthCheck.mockReturnValue({
~
82 enabled: true,
~~~~~~~~~~~~~~~~~~
...
86 server_not_ready_troubleshooting_link: 'https://example.healthcheck-docs.com',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87 });
~~~
src/core/common/healthcheck/types.ts:31:3
31 max_retries: number;
~~~~~~~~~~~
'max_retries' is declared here.
src/core/public/plugins/plugins_service.test.ts:127:7 - error TS2322: Type 'Pick<Mocked<InjectedMetadataSetup>, "getInjectedVar" | "getBranding">' is not assignable to type 'Mocked<{ getInjectedVar: (name: string, defaultValue?: any) => unknown; getBranding: () => Branding; getWazuhBuildInfo: () => WazuhBuildInfo; }>'.
Property 'getWazuhBuildInfo' is missing in type 'Pick<Mocked<InjectedMetadataSetup>, "getInjectedVar" | "getBranding">' but required in type '{ getInjectedVar: MockInstance<unknown, [name: string, defaultValue?: any]>; getBranding: MockInstance<Branding, []>; getWazuhBuildInfo: MockInstance<WazuhBuildInfo, []>; }'.
127 injectedMetadata: pick(mockSetupDeps.injectedMetadata, 'getInjectedVar', 'getBranding'),
~~~~~~~~~~~~~~~~
src/core/public/index.ts:294:5
294 getWazuhBuildInfo: () => WazuhBuildInfo;
~~~~~~~~~~~~~~~~~
'getWazuhBuildInfo' is declared here.
src/core/public/index.ts:290:3
290 injectedMetadata: {
~~~~~~~~~~~~~~~~
The expected type comes from property 'injectedMetadata' which is declared here on type 'DeeplyMocked<CoreSetup<object, unknown>>'
src/core/public/plugins/plugins_service.test.ts:151:7 - error TS2322: Type 'Pick<Mocked<InjectedMetadataSetup>, "getInjectedVar" | "getBranding">' is not assignable to type 'Mocked<{ getInjectedVar: (name: string, defaultValue?: any) => unknown; getBranding: () => Branding; getWazuhBuildInfo: () => WazuhBuildInfo; }>'.
Property 'getWazuhBuildInfo' is missing in type 'Pick<Mocked<InjectedMetadataSetup>, "getInjectedVar" | "getBranding">' but required in type '{ getInjectedVar: MockInstance<unknown, [name: string, defaultValue?: any]>; getBranding: MockInstance<Branding, []>; getWazuhBuildInfo: MockInstance<WazuhBuildInfo, []>; }'.
151 injectedMetadata: pick(mockStartDeps.injectedMetadata, 'getInjectedVar', 'getBranding'),
~~~~~~~~~~~~~~~~
src/core/public/index.ts:363:5
363 getWazuhBuildInfo: () => WazuhBuildInfo;
~~~~~~~~~~~~~~~~~
'getWazuhBuildInfo' is declared here.
src/core/public/index.ts:359:3
359 injectedMetadata: {
~~~~~~~~~~~~~~~~
The expected type comes from property 'injectedMetadata' which is declared here on type 'DeeplyMocked<CoreStart>'
Found 3 errors.
at makeError (/home/runner/Documents/Wazuh/repos/wazuh-dashboard/node_modules/execa/lib/error.js:59:11)
at handlePromise (/home/runner/Documents/Wazuh/repos/wazuh-dashboard/node_modules/execa/index.js:114:26)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at buildRefs (/home/runner/Documents/Wazuh/repos/wazuh-dashboard/src/dev/typescript/build_refs.ts:41:5)
at buildAllRefs (/home/runner/Documents/Wazuh/repos/wazuh-dashboard/src/dev/typescript/build_refs.ts:35:3)
at description (/home/runner/Documents/Wazuh/repos/wazuh-dashboard/src/dev/typescript/build_refs.ts:51:7)
at /home/runner/Documents/Wazuh/repos/wazuh-dashboard/packages/osd-dev-utils/target/run/run.js:64:13
at withProcRunner (/home/runner/Documents/Wazuh/repos/wazuh-dashboard/packages/osd-dev-utils/target/proc_runner/with_proc_runner.js:45:9)
at run (/home/runner/Documents/Wazuh/repos/wazuh-dashboard/packages/osd-dev-utils/target/run/run.js:63:9)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
at makeError (/home/runner/Documents/Wazuh/repos/wazuh-dashboard/packages/osd-pm/dist/index.js:27527:11)
at handlePromise (/home/runner/Documents/Wazuh/repos/wazuh-dashboard/packages/osd-pm/dist/index.js:26461:26)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async /home/runner/Documents/Wazuh/repos/wazuh-dashboard/packages/osd-pm/dist/index.js:9283:11
at async scheduleItem (/home/runner/Documents/Wazuh/repos/wazuh-dashboard/packages/osd-pm/dist/index.js:11336:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.This commit replaces the hardcoded health check configuration in the injected metadata service mock with a reference to the centralized healthCheckConfig. Additionally, it updates the PluginsService tests to include the new 'getWazuhBuildInfo' method in the injected metadata mock, ensuring consistency across the application.
…stall-the-agent-command
…z dashboard (#1327) * Enhance Wazuh integration by adding version, revision, and stage metadata. Update related interfaces and mocks to support new properties across the application. * Add production flag handling in VERSION.json and update related interfaces This commit introduces a new step in the build workflow to set the production flag in VERSION.json based on the deployment stage. Additionally, it updates various interfaces and mocks across the application to include the new property, ensuring consistent handling of this metadata throughout the codebase. * Refactor Wazuh build metadata handling and update related interfaces This commit removes the production flag handling from the build workflow and integrates it directly into the package.json during the build process. It also introduces a new WazuhBuildInfo interface to encapsulate version, revision, stage, and production status, updating various components and mocks across the application to utilize this new structure for consistent metadata management. * Update health check mock and enhance injected metadata in tests This commit replaces the hardcoded health check configuration in the injected metadata service mock with a reference to the centralized healthCheckConfig. Additionally, it updates the PluginsService tests to include the new 'getWazuhBuildInfo' method in the injected metadata mock, ensuring consistency across the application. * fix prettier * tmp change on workflow * restore file

























Description
Removes the hardcoded release suffix from the Deploy new agent wizard. Package names and download URLs now use the Wazuh build metadata from
core.injectedMetadata(getWazuhStage/getWazuhRevision), initialized in pluginsetupviainitWazuhBuildInfoFromCore.beta2) and staging URLs.01) and production URLs.Requires a companion
wazuh-dashboardPR that exposesgetWazuhStage()andgetWazuhRevision()to plugins and setswazuh.stagein the dashboardpackage.json.Issues Resolved
Evidence
wazuh-agent-<version>-<stage>.x86_64.rpmand matching staging URLwazuh.stageinwazuh-dashboard/package.jsonand restart OSDstageempty)packages.wazuh.com/production/...URLTest
"stage": "beta x"underwazuhinwazuh-dashboard/Version.json.yarn start --no-base-pathin the dev container).beta x.Check List
yarn test:jest)--signoffwazuh-dashboardPR linked