Skip to content

Commit

Permalink
Merge 4.8.1 into 4.9.0 (#6815)
Browse files Browse the repository at this point in the history
Merge 4.8.1 into 4.9.0
  • Loading branch information
asteriscos authored Jul 8, 2024
2 parents f46916b + 9ce4312 commit 768b86b
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 46 deletions.
50 changes: 24 additions & 26 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
41 changes: 41 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const DashboardVulsComponent: React.FC<DashboardVulsProps> = ({
<DiscoverNoResults />
) : null}
<div
className={`vulnerability-dashboard-responsive ${
className={`vulnerability-dashboard-responsive vulnerability-dashboard-metrics ${
dataSource && results?.hits?.total > 0 ? '' : 'wz-no-display'
}`}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const getVisStateSeverityHigh = (indexPatternId: string) => {
metric: {
percentageMode: false,
useRanges: false,
colorSchema: 'Blues',
colorSchema: 'Yellow to Red',
metricColorMode: 'Labels',
colorsRange: [
{
Expand All @@ -113,7 +113,7 @@ const getVisStateSeverityHigh = (indexPatternId: string) => {
labels: {
show: true,
},
invertColors: false,
invertColors: true,
style: {
bgFill: '#000',
bgColor: false,
Expand All @@ -123,13 +123,6 @@ const getVisStateSeverityHigh = (indexPatternId: string) => {
},
},
},
uiState: {
vis: {
colors: {
'High Severity - Count': '#38D1BA',
},
},
},
data: {
searchSource: {
query: {
Expand Down Expand Up @@ -190,7 +183,7 @@ const getVisStateSeverityMedium = (indexPatternId: string) => {
metric: {
percentageMode: false,
useRanges: false,
colorSchema: 'Yellow to Red',
colorSchema: 'Blues',
metricColorMode: 'Labels',
colorsRange: [
{
Expand All @@ -205,7 +198,7 @@ const getVisStateSeverityMedium = (indexPatternId: string) => {
labels: {
show: true,
},
invertColors: true,
invertColors: false,
style: {
bgFill: '#000',
bgColor: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Last24HoursAlerts {
field: string;
name: string;
};
indexPatternName: string;
indexPatternId: string;
}

/**
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -76,7 +76,7 @@ export function LastAlertsStat({ severity }: { severity: string }) {
FILTER_OPERATOR.IS,
cluster.field,
cluster.name,
indexPatternName,
indexPatternId,
);
const ruleLevelRangeFilter =
PatternDataSourceFilterManager.createFilter(
Expand All @@ -86,7 +86,7 @@ export function LastAlertsStat({ severity }: { severity: string }) {
severityLabel[severity].ruleLevelRange.minRuleLevel,
severityLabel[severity].ruleLevelRange.maxRuleLevel,
],
indexPatternName,
indexPatternId,
);
const predefinedFilters =
PatternDataSourceFilterManager.filtersToURLFormat([
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jest.mock('./last-alerts-stat/last-alerts-service', () => ({
field: 'cluster.name',
name: 'master',
},
indexPatternName: 'wazuh-alerts-*',
indexPatternId: 'wazuh-alerts-*',
}),
}));

Expand Down
5 changes: 5 additions & 0 deletions plugins/main/server/controllers/wazuh-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 768b86b

Please sign in to comment.