diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 95c619969c..38954d9028 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -11,42 +11,40 @@ name: ESLint on: pull_request: - branches: - - 'master' - - '[345].[0-9]+' # Minor branches - - '[345].[0-9]+.[0-9]+' # Patch branches - - '[345].[0-9]+.[0-9]+-7.[0-9]+' # Minor branches - Kibana jobs: - eslint: - name: Run eslint scanning + linter: + name: Ensure the code format on the changed files runs-on: ubuntu-latest - permissions: - contents: read - security-events: write - actions: read - steps: - # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs - name: Checkout code uses: actions/checkout@v3 # - https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file - - name: Install ESLint + - name: Install NodeJS uses: actions/setup-node@v3 with: node-version-file: '.nvmrc' - - run: yarn - - name: Run ESLint - run: yarn lint >> eslint-results.log - continue-on-error: true - - # https://github.com/marketplace/actions/upload-a-build-artifact - - name: Upload analysis results to GitHub - uses: actions/upload-artifact@v3 - with: - name: eslint-results - path: eslint-results.log - retention-days: 5 + - name: Verify the changed files + run: | + REMOTE_NAME=origin + echo "Base ref: $GITHUB_BASE_REF" + echo "Head ref: $GITHUB_HEAD_REF" + echo "Fetching branch: $GITHUB_BASE_REF" + git fetch origin $GITHUB_BASE_REF + echo "Fetching branch: $GITHUB_HEAD_REF" + git fetch origin $GITHUB_HEAD_REF + echo "Listing branches" + git branch -a + echo "Getting diff files ignoring deleted and getting the changed or renamed files" + CHANGED_FILES=$(git diff --name-status --diff-filter d ${REMOTE_NAME}/${GITHUB_BASE_REF}..${REMOTE_NAME}/${GITHUB_HEAD_REF} | awk '{print $2}') + echo "Changed files:" + echo "${CHANGED_FILES}" + git checkout $GITHUB_HEAD_REF + plugin_package_json=$(ls -d plugins/* | head -n1) + echo "Installing dependencies from plugin: ${plugin_package_json}" + yarn --cwd "${plugin_package_json}" --modules-folder ../../node_modules + echo "Running eslint on the changed files" + npx eslint ${CHANGED_FILES} diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 0000000000..9c1748cd4b --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,41 @@ +name: Prettier + +on: + pull_request: + +jobs: + prettier: + name: Ensure the code format on the changed files + runs-on: ubuntu-latest + steps: + # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + - name: Checkout code + uses: actions/checkout@v3 + + # - https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file + - name: Install NodeJS + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + + - name: Verify the changed files + run: | + REMOTE_NAME=origin + echo "Base ref: $GITHUB_BASE_REF" + echo "Head ref: $GITHUB_HEAD_REF" + echo "Fetching branch: $GITHUB_BASE_REF" + git fetch origin $GITHUB_BASE_REF + echo "Fetching branch: $GITHUB_HEAD_REF" + git fetch origin $GITHUB_HEAD_REF + echo "Listing branches" + git branch -a + echo "Getting diff files ignoring deleted and getting the changed or renamed files" + CHANGED_FILES=$(git diff --name-status --diff-filter d ${REMOTE_NAME}/${GITHUB_BASE_REF}..${REMOTE_NAME}/${GITHUB_HEAD_REF} | awk '{print $2}') + echo "Changed files:" + echo "${CHANGED_FILES}" + git checkout $GITHUB_HEAD_REF + plugin_package_json=$(ls -d plugins/* | head -n1) + echo "Installing dependencies from plugin: ${plugin_package_json}" + yarn --cwd "${plugin_package_json}" --modules-folder ../../node_modules + echo "Running prettier on the changed files" + npx prettier ${CHANGED_FILES} --check --ignore-unknown diff --git a/CHANGELOG.md b/CHANGELOG.md index ffaef30a39..41a752e277 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,12 +68,18 @@ All notable changes to the Wazuh app project will be documented in this file. - Removed custom EuiSuggestItem component in favor of OUI's native component [#6714](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6714) - Removed API endpoint unused endpoints from creation of old visualisations: GET /elastic/visualizations/{tab}/{pattern} and GET /elastic/visualizations/{tab}/{pattern} [#6782](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6782) -## Wazuh v4.8.1 - OpenSearch Dashboards 2.10.0 - Revision 00 +## Wazuh v4.8.1 - OpenSearch Dashboards 2.10.0 - Revision 02 ### Added - Support for Wazuh 4.8.1 +### Fixed + +- Removed the unexpected `delay` parameter on the server API requests [#6778](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6778) +- Fixed home KPI links with custom or index pattern whose title is different to the id [#6777](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6777) +- Fixed colors related to vulnerability severity levels on Vulnerability Detection dashboard [#6793](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6793) + ## Wazuh v4.8.0 - OpenSearch Dashboards 2.10.0 - Revision 12 ### Added diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx index 74ec75a6c2..b0145425be 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard.tsx @@ -105,7 +105,7 @@ const DashboardVulsComponent: React.FC = ({ ) : null}
0 ? '' : 'wz-no-display' }`} > diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels.ts b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels.ts index 252d60d65a..e38847b33a 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels.ts +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels.ts @@ -350,6 +350,19 @@ const getVisStateAccumulationMostDetectedVulnerabilities = ( color: '#E7664C', }, }, + uiState: { + vis: { + /* These colors should match the specified on the metric visualizations + public/components/overview/vulnerabilities/dashboards/overview/vulnerability_detector_filters.scss + */ + colors: { + Critical: '#CC5642', + High: '#F5A700', + Medium: '#6092C0', + Low: '#209280', + }, + }, + }, data: { searchSource: { query: { diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts index 45e31b0ffc..c2d213b401 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels_kpis.ts @@ -98,7 +98,7 @@ const getVisStateSeverityHigh = (indexPatternId: string) => { metric: { percentageMode: false, useRanges: false, - colorSchema: 'Blues', + colorSchema: 'Yellow to Red', metricColorMode: 'Labels', colorsRange: [ { @@ -113,7 +113,7 @@ const getVisStateSeverityHigh = (indexPatternId: string) => { labels: { show: true, }, - invertColors: false, + invertColors: true, style: { bgFill: '#000', bgColor: false, @@ -123,13 +123,6 @@ const getVisStateSeverityHigh = (indexPatternId: string) => { }, }, }, - uiState: { - vis: { - colors: { - 'High Severity - Count': '#38D1BA', - }, - }, - }, data: { searchSource: { query: { @@ -190,7 +183,7 @@ const getVisStateSeverityMedium = (indexPatternId: string) => { metric: { percentageMode: false, useRanges: false, - colorSchema: 'Yellow to Red', + colorSchema: 'Blues', metricColorMode: 'Labels', colorsRange: [ { @@ -205,7 +198,7 @@ const getVisStateSeverityMedium = (indexPatternId: string) => { labels: { show: true, }, - invertColors: true, + invertColors: false, style: { bgFill: '#000', bgColor: false, diff --git a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/vulnerability_detector_filters.scss b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/vulnerability_detector_filters.scss index c953f43a4f..996f0272b2 100644 --- a/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/vulnerability_detector_filters.scss +++ b/plugins/main/public/components/overview/vulnerabilities/dashboards/overview/vulnerability_detector_filters.scss @@ -18,3 +18,74 @@ } } } + +/* WORKAROUND: Overwrite the color of the vulnerability severity metric color on + Vulnerabilities Detection dashboard. + + The metric visualization do not allow to define the specific color. + + */ +.wz-app div.vulnerability-dashboard-metrics > div:nth-child(1) > div > div { + /* Vulnerability severity metric: Critical */ + & + > div:nth-child(1) + > div + > div + > div.embPanel__content + > div + > div + > div + > div.mtrVis__value { + /* ATTENTION: any change on this color needs to historic visualization related to + vulneravility severity should be changed too to match the colors on the dashboard */ + color: #cc5642 !important; + } + /* Vulnerability severity metric: High */ + & + > div:nth-child(2) + > div + > div + > div.embPanel__content + > div + > div + > div + > div.mtrVis__value { + /* ATTENTION: any change on this color needs to historic visualization related to + vulneravility severity should be changed too to match the colors on the dashboard + public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels.ts + */ + color: #f5a700 !important; + } + /* Vulnerability severity metric: Medium */ + & + > div:nth-child(3) + > div + > div + > div.embPanel__content + > div + > div + > div + > div.mtrVis__value { + /* ATTENTION: any change on this color needs to historic visualization related to + vulneravility severity should be changed too to match the colors on the dashboard + public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels.ts + */ + color: #6092c0 !important; + } + /* Vulnerability severity metric: Low */ + & + > div:nth-child(4) + > div + > div + > div.embPanel__content + > div + > div + > div + > div.mtrVis__value { + /* ATTENTION: any change on this color needs to historic visualization related to + vulneravility severity should be changed too to match the colors on the dashboard + public/components/overview/vulnerabilities/dashboards/overview/dashboard_panels.ts + */ + color: #209280 !important; + } +} diff --git a/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-service.ts b/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-service.ts index 20e584130c..d997c07f50 100644 --- a/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-service.ts +++ b/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-service.ts @@ -9,7 +9,7 @@ interface Last24HoursAlerts { field: string; name: string; }; - indexPatternName: string; + indexPatternId: string; } /** @@ -44,7 +44,7 @@ export const getLast24HoursAlerts = async ( field: isCluster ? 'cluster.name' : 'manager.name', name: clusterValue, }, - indexPatternName: currentIndexPattern.id, + indexPatternId: currentIndexPattern.id, }; } catch (error) { return Promise.reject(error); diff --git a/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-stat.tsx b/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-stat.tsx index 63b6bf2202..e1113790d5 100644 --- a/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-stat.tsx +++ b/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-stat.tsx @@ -60,7 +60,7 @@ export function LastAlertsStat({ severity }: { severity: string }) { useEffect(() => { const getCountLastAlerts = async () => { try { - const { indexPatternName, cluster, count } = await getLast24HoursAlerts( + const { indexPatternId, cluster, count } = await getLast24HoursAlerts( severityLabel[severity].ruleLevelRange, ); setCountLastAlerts(count); @@ -76,7 +76,7 @@ export function LastAlertsStat({ severity }: { severity: string }) { FILTER_OPERATOR.IS, cluster.field, cluster.name, - indexPatternName, + indexPatternId, ); const ruleLevelRangeFilter = PatternDataSourceFilterManager.createFilter( @@ -86,7 +86,7 @@ export function LastAlertsStat({ severity }: { severity: string }) { severityLabel[severity].ruleLevelRange.minRuleLevel, severityLabel[severity].ruleLevelRange.maxRuleLevel, ], - indexPatternName, + indexPatternId, ); const predefinedFilters = PatternDataSourceFilterManager.filtersToURLFormat([ @@ -95,7 +95,7 @@ export function LastAlertsStat({ severity }: { severity: string }) { ]); const destURL = core.application.getUrlForApp(discoverLocation.app, { - path: `${discoverLocation.basePath}#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${indexPatternName}',view:discover))&_g=${predefinedFilters}&_q=(filters:!(),query:(language:kuery,query:''))`, + path: `${discoverLocation.basePath}#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${indexPatternId}',view:discover))&_g=${predefinedFilters}&_q=(filters:!(),query:(language:kuery,query:''))`, }); setDiscoverLocation(destURL); } catch (error) { diff --git a/plugins/main/public/controllers/overview/components/stats.test.tsx b/plugins/main/public/controllers/overview/components/stats.test.tsx index 058cb2c953..0e03c26535 100644 --- a/plugins/main/public/controllers/overview/components/stats.test.tsx +++ b/plugins/main/public/controllers/overview/components/stats.test.tsx @@ -32,7 +32,7 @@ jest.mock('./last-alerts-stat/last-alerts-service', () => ({ field: 'cluster.name', name: 'master', }, - indexPatternName: 'wazuh-alerts-*', + indexPatternId: 'wazuh-alerts-*', }), })); diff --git a/plugins/main/server/controllers/wazuh-api.ts b/plugins/main/server/controllers/wazuh-api.ts index 40d93a8a57..fffdef42bb 100644 --- a/plugins/main/server/controllers/wazuh-api.ts +++ b/plugins/main/server/controllers/wazuh-api.ts @@ -620,6 +620,11 @@ export class WazuhApiCtrl { } const delay = (data || {}).delay || 0; if (delay) { + // Remove the delay parameter that is used to add the sever API request to the queue job. + // This assumes the delay parameter is not used as part of the server API request. If it + // was expected to do a request with a 'delay' parameter then we would have to search a + // way to differenciate if the parameter is related to job queue or API request. + delete data.delay; addJobToQueue({ startAt: new Date(Date.now() + delay), run: async contextJob => {