[Security Solution][Exceptions] Adds error catch to Exceptions toString method (#105928)
This commit is contained in:
parent
dadeb78b44
commit
fcd515f942
|
@ -26,8 +26,9 @@ import {
|
||||||
getProcessCodeSignature,
|
getProcessCodeSignature,
|
||||||
retrieveAlertOsTypes,
|
retrieveAlertOsTypes,
|
||||||
filterIndexPatterns,
|
filterIndexPatterns,
|
||||||
|
getCodeSignatureValue,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
import { AlertData } from './types';
|
import { AlertData, Flattened } from './types';
|
||||||
import {
|
import {
|
||||||
ListOperatorTypeEnum as OperatorTypeEnum,
|
ListOperatorTypeEnum as OperatorTypeEnum,
|
||||||
EntriesArray,
|
EntriesArray,
|
||||||
|
@ -41,6 +42,7 @@ import { getCommentsArrayMock } from '../../../../../lists/common/schemas/types/
|
||||||
import { fields } from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks';
|
import { fields } from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks';
|
||||||
import { ENTRIES, OLD_DATE_RELATIVE_TO_DATE_NOW } from '../../../../../lists/common/constants.mock';
|
import { ENTRIES, OLD_DATE_RELATIVE_TO_DATE_NOW } from '../../../../../lists/common/constants.mock';
|
||||||
import { IFieldType, IIndexPattern } from 'src/plugins/data/common';
|
import { IFieldType, IIndexPattern } from 'src/plugins/data/common';
|
||||||
|
import { CodeSignature } from '../../../../common/ecs/file';
|
||||||
|
|
||||||
jest.mock('uuid', () => ({
|
jest.mock('uuid', () => ({
|
||||||
v4: jest.fn().mockReturnValue('123'),
|
v4: jest.fn().mockReturnValue('123'),
|
||||||
|
@ -340,6 +342,17 @@ describe('Exception helpers', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getCodeSignatureValue', () => {
|
||||||
|
test('it should return empty string if code_signature nested value are undefined', () => {
|
||||||
|
// Using the unsafe casting because with our types this shouldn't be possible but there have been issues with old data having undefined values in these fields
|
||||||
|
const payload = ([{ trusted: undefined, subject_name: undefined }] as unknown) as Flattened<
|
||||||
|
CodeSignature[]
|
||||||
|
>;
|
||||||
|
const result = getCodeSignatureValue(payload);
|
||||||
|
expect(result).toEqual([{ trusted: '', subjectName: '' }]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#entryHasNonEcsType', () => {
|
describe('#entryHasNonEcsType', () => {
|
||||||
const mockEcsIndexPattern = {
|
const mockEcsIndexPattern = {
|
||||||
title: 'testIndex',
|
title: 'testIndex',
|
||||||
|
|
|
@ -325,8 +325,8 @@ export const getCodeSignatureValue = (
|
||||||
if (Array.isArray(codeSignature) && codeSignature.length > 0) {
|
if (Array.isArray(codeSignature) && codeSignature.length > 0) {
|
||||||
return codeSignature.map((signature) => {
|
return codeSignature.map((signature) => {
|
||||||
return {
|
return {
|
||||||
subjectName: signature.subject_name ?? '',
|
subjectName: signature?.subject_name ?? '',
|
||||||
trusted: signature.trusted.toString() ?? '',
|
trusted: signature?.trusted?.toString() ?? '',
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue