Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved display of log types. #753

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
- name: Run OpenSearch-Dashboards server
run: |
cd OpenSearch-Dashboards
yarn start --no-base-path --no-watch &
yarn start --no-base-path --no-watch --server.host="0.0.0.0" &
shell: bash

# Window is slow so wait longer
Expand Down
10 changes: 5 additions & 5 deletions cypress/integration/1_detectors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import sample_windows_index_settings from '../fixtures/sample_windows_index_sett
import sample_dns_index_settings from '../fixtures/sample_dns_index_settings.json';
import dns_name_rule_data from '../fixtures/integration_tests/rule/create_dns_rule_with_name_selection.json';
import dns_type_rule_data from '../fixtures/integration_tests/rule/create_dns_rule_with_type_selection.json';
import dns_mapping_fields from '../fixtures/integration_tests/rule/sample_dns_field_mappings.json';
import _ from 'lodash';
import { getMappingFields } from '../../public/pages/Detectors/utils/helpers';
import { getLogTypeLabel } from '../../public/pages/LogTypes/utils/helpers';

const cypressIndexDns = 'cypress-index-dns';
const cypressIndexWindows = 'cypress-index-windows';
Expand Down Expand Up @@ -115,9 +115,9 @@ const validatePendingFieldMappingsPanel = (mappings) => {
const fillDetailsForm = (detectorName, dataSource) => {
getNameField().type(detectorName);
getDataSourceField().selectComboboxItem(dataSource);
getDataSourceField().blur();
getLogTypeField().selectComboboxItem(cypressLogTypeDns);
getLogTypeField().blur();
getDataSourceField().focus().blur();
getLogTypeField().selectComboboxItem(getLogTypeLabel(cypressLogTypeDns));
getLogTypeField().focus().blur();
};

const createDetector = (detectorName, dataSource, expectFailure) => {
Expand All @@ -127,7 +127,7 @@ const createDetector = (detectorName, dataSource, expectFailure) => {

cy.getElementByText('.euiAccordion .euiTitle', 'Detection rules (14 selected)')
.click({ force: true, timeout: 5000 })
.then(() => cy.contains('.euiTable .euiTableRow', 'Dns'));
.then(() => cy.contains('.euiTable .euiTableRow', getLogTypeLabel(cypressLogTypeDns)));

cy.getElementByText('.euiAccordion .euiTitle', 'Field mapping - optional');
cy.get('[aria-controls="mappedTitleFieldsAccordion"]').then(($btn) => {
Expand Down
17 changes: 11 additions & 6 deletions cypress/integration/2_rules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { OPENSEARCH_DASHBOARDS_URL } from '../support/constants';
import { getLogTypeLabel } from '../../public/pages/LogTypes/utils/helpers';

const uniqueId = Cypress._.random(0, 1e6);
const SAMPLE_RULE = {
Expand Down Expand Up @@ -55,7 +56,9 @@ const checkRulesFlyout = () => {
cy.get('[data-test-subj="rule_flyout_rule_name"]').contains(SAMPLE_RULE.name);

// Validate log type
cy.get('[data-test-subj="rule_flyout_rule_log_type"]').contains(SAMPLE_RULE.logType);
cy.get('[data-test-subj="rule_flyout_rule_log_type"]').contains(
getLogTypeLabel(SAMPLE_RULE.logType)
);

// Validate description
cy.get('[data-test-subj="rule_flyout_rule_description"]').contains(SAMPLE_RULE.description);
Expand Down Expand Up @@ -161,7 +164,7 @@ const fillCreateForm = () => {
getAuthorField().type(`${SAMPLE_RULE.author}`);

// rule details
getLogTypeField().selectComboboxItem(SAMPLE_RULE.logType);
getLogTypeField().selectComboboxItem(getLogTypeLabel(SAMPLE_RULE.logType));
getRuleLevelField().selectComboboxItem(SAMPLE_RULE.severity);

// rule detection
Expand Down Expand Up @@ -284,7 +287,7 @@ describe('Rules', () => {
getLogTypeField().focus().blur();
getLogTypeField().containsError('Log type is required');

getLogTypeField().selectComboboxItem(SAMPLE_RULE.logType);
getLogTypeField().selectComboboxItem(getLogTypeLabel(SAMPLE_RULE.logType));
getLogTypeField().focus().blur().shouldNotHaveError();
});

Expand Down Expand Up @@ -425,7 +428,7 @@ describe('Rules', () => {
// log field
getLogTypeField().clearCombobox();
toastShouldExist();
getLogTypeField().selectComboboxItem(SAMPLE_RULE.logType);
getLogTypeField().selectComboboxItem(getLogTypeLabel(SAMPLE_RULE.logType));

// severity field
getRuleLevelField().clearCombobox();
Expand Down Expand Up @@ -550,8 +553,10 @@ describe('Rules', () => {
SAMPLE_RULE.logType = 'dns';
YAML_RULE_LINES[2] = `product: ${SAMPLE_RULE.logType}`;
YAML_RULE_LINES[3] = `title: ${SAMPLE_RULE.name}`;
getLogTypeField().selectComboboxItem(SAMPLE_RULE.logType);
getLogTypeField().containsValue(SAMPLE_RULE.logType).contains(SAMPLE_RULE.logType);
getLogTypeField().selectComboboxItem(getLogTypeLabel(SAMPLE_RULE.logType));
getLogTypeField()
.containsValue(SAMPLE_RULE.logType)
.contains(getLogTypeLabel(SAMPLE_RULE.logType));

SAMPLE_RULE.description += ' edited';
YAML_RULE_LINES[4] = `description: ${SAMPLE_RULE.description}`;
Expand Down
9 changes: 7 additions & 2 deletions cypress/integration/3_alerts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import aliasMappings from '../fixtures/sample_alias_mappings.json';
import indexDoc from '../fixtures/sample_document.json';
import ruleSettings from '../fixtures/integration_tests/rule/create_windows_usb_rule.json';
import { createDetector } from '../support/helpers';
import { getLogTypeLabel } from '../../public/pages/LogTypes/utils/helpers';

const indexName = 'test-index';
const detectorName = 'test-detector';
Expand Down Expand Up @@ -118,7 +119,9 @@ describe('Alerts', () => {
expect($tr, `timestamp`).to.contain(date);
expect($tr, `rule name`).to.contain('Cypress USB Rule');
expect($tr, `detector name`).to.contain(testDetector.name);
expect($tr, `log type`).to.contain('System Activity: Windows');
expect($tr, `log type`).to.contain(
`System Activity: ${getLogTypeLabel(testDetector.detector_type)}`
);
});

// Close the flyout
Expand Down Expand Up @@ -189,7 +192,9 @@ describe('Alerts', () => {
cy.get('[data-test-subj="finding-details-flyout-rule-severity"]').contains('High');

// Confirm the rule category
cy.get('[data-test-subj="finding-details-flyout-rule-category"]').contains('Windows');
cy.get('[data-test-subj="finding-details-flyout-rule-category"]').contains(
getLogTypeLabel(testDetector.detector_type)
);

// Confirm the rule description
cy.get('[data-test-subj="finding-details-flyout-rule-description"]').contains(
Expand Down
3 changes: 2 additions & 1 deletion cypress/integration/4_findings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import aliasMappings from '../fixtures/sample_alias_mappings.json';
import indexDoc from '../fixtures/sample_document.json';
import ruleSettings from '../fixtures/integration_tests/rule/create_windows_usb_rule.json';
import { createDetector } from '../support/helpers';
import { getLogTypeLabel } from '../../public/pages/LogTypes/utils/helpers';

const indexName = 'test-index';
const detectorName = 'test-detector';
Expand Down Expand Up @@ -52,7 +53,7 @@ describe('Findings', () => {
cy.contains('No items found').should('not.exist');

// Check for expected findings
cy.contains('System Activity: Windows');
cy.contains(`System Activity: ${getLogTypeLabel(testDetector.detector_type)}`);
cy.contains('High');
});

Expand Down
142 changes: 0 additions & 142 deletions cypress/integration/5_integrations.spec.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export const CreateCorrelationRule: React.FC<CreateCorrelationRuleProps> = (
label:
ruleTypes.find(
(logType) =>
logType.label.toLowerCase() === query.logType.toLowerCase()
logType.value.toLowerCase() === query.logType.toLowerCase()
)?.label || query.logType,
},
]
Expand Down
4 changes: 2 additions & 2 deletions public/pages/Correlations/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ruleSeverity, ruleTypes } from '../../Rules/utils/constants';
import { FilterItem } from '../components/FilterGroup';
import { EuiIcon, EuiTitle } from '@elastic/eui';
import { logTypeCategories, logTypesByCategories } from '../../../utils/constants';
import _ from 'lodash';
import { getLogTypeLabel } from '../../LogTypes/utils/helpers';

export const graphRenderOptions = {
nodes: {
Expand Down Expand Up @@ -67,7 +67,7 @@ export const getDefaultLogTypeFilterItemOptions: () => FilterItem[] = () => {

logTypes.forEach(({ name }) => {
options.push({
name: _.capitalize(name),
name: getLogTypeLabel(name),
id: name,
checked: 'on',
visible: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EuiBasicTableColumn, EuiLink, EuiSwitch } from '@elastic/eui';
import { capitalizeFirstLetter } from '../../../../../../../utils/helpers';
import React, { ReactNode } from 'react';
import { RuleItem } from '../types/interfaces';
import { getLogTypeLabel } from '../../../../../../LogTypes/utils/helpers';

export type ActiveToggleOnChangeEvent = React.BaseSyntheticEvent<
React.MouseEvent<HTMLButtonElement>,
Expand Down Expand Up @@ -51,7 +52,7 @@ export const getRulesColumns = (
name: 'Log type',
width: '10%',
sortable: true,
render: (logType: string) => capitalizeFirstLetter(logType),
render: (logType: string) => getLogTypeLabel(logType),
},
{
field: 'library',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ruleTypes } from '../../../../../Rules/utils/constants';
import ConfigureFieldMapping from '../../../ConfigureFieldMapping';
import { ConfigureFieldMappingProps } from '../../../ConfigureFieldMapping/containers/ConfigureFieldMapping';
import { getLogTypeOptions } from '../../../../../../utils/helpers';
import { getLogTypeLabel } from '../../../../../LogTypes/utils/helpers';

interface DetectorTypeProps {
detectorType: string;
Expand Down Expand Up @@ -97,9 +98,11 @@ export default class DetectorType extends Component<DetectorTypeProps, DetectorT
options={this.detectorTypeOptions}
singleSelection={{ asPlainText: true }}
onChange={(e) => {
this.onChange(e[0]?.label || '');
this.onChange(e[0]?.value || '');
}}
selectedOptions={detectorType ? [{ value: detectorType, label: detectorType }] : []}
selectedOptions={
detectorType ? [{ value: detectorType, label: getLogTypeLabel(detectorType) }] : []
}
/>
</EuiFormRow>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { createTextDetailsGroup, parseSchedule } from '../../../../utils/helpers
import moment from 'moment';
import { DEFAULT_EMPTY_DATA, logTypesWithDashboards } from '../../../../utils/constants';
import { Detector } from '../../../../../types';
import { getLogTypeLabel } from '../../../LogTypes/utils/helpers';

export interface DetectorBasicDetailsViewProps {
detector: Detector;
Expand Down Expand Up @@ -77,7 +78,7 @@ export const DetectorBasicDetailsView: React.FC<DetectorBasicDetailsViewProps> =
</>
),
},
{ label: 'Log type', content: detector_type.toLowerCase() },
{ label: 'Log type', content: getLogTypeLabel(detector_type.toLowerCase()) },
{
label: 'Detector dashboard',
content: (dashboardId ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ Object {
data-test-subj="text-details-group-content-log-type"
id="some_html_id"
>
detector_type
Detector Type
</div>
</div>
</div>
Expand Down Expand Up @@ -684,7 +684,7 @@ Object {
data-test-subj="text-details-group-content-log-type"
id="some_html_id"
>
detector_type
Detector Type
</div>
</div>
</div>
Expand Down
Loading
Loading