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

[CTI] Adds indicator match rule improvements #97310

Merged
merged 2 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('get_threat_signals', () => {
index: ['index-123'],
listItemIndex: 'list-index-123',
});
expect(sortOrder).toEqual([{ '@timestamp': 'asc' }]);
expect(sortOrder).toEqual([{ '@timestamp': 'desc' }]);
});

test('it should return sort field of just tie_breaker_id if given no sort order for a list item index', () => {
Expand All @@ -29,14 +29,14 @@ describe('get_threat_signals', () => {
expect(sortOrder).toEqual([{ tie_breaker_id: 'asc' }]);
});

test('it should return sort field of timestamp with asc even if sortOrder is changed as it is hard wired in', () => {
test('it should return sort field of timestamp with desc even if sortOrder is changed as it is hard wired in', () => {
const sortOrder = getSortWithTieBreaker({
sortField: undefined,
sortOrder: 'desc',
index: ['index-123'],
listItemIndex: 'list-index-123',
});
expect(sortOrder).toEqual([{ '@timestamp': 'asc' }]);
expect(sortOrder).toEqual([{ '@timestamp': 'desc' }]);
});

test('it should return sort field of tie_breaker_id with asc even if sortOrder is changed as it is hard wired in for a list item index', () => {
Expand All @@ -56,7 +56,7 @@ describe('get_threat_signals', () => {
index: ['index-123'],
listItemIndex: 'list-index-123',
});
expect(sortOrder).toEqual([{ 'some-field': 'asc', '@timestamp': 'asc' }]);
expect(sortOrder).toEqual([{ 'some-field': 'asc', '@timestamp': 'desc' }]);
});

test('it should return sort field of an extra field if given one for a list item index', () => {
Expand All @@ -76,7 +76,7 @@ describe('get_threat_signals', () => {
index: ['index-123'],
listItemIndex: 'list-index-123',
});
expect(sortOrder).toEqual([{ 'some-field': 'desc', '@timestamp': 'asc' }]);
expect(sortOrder).toEqual([{ 'some-field': 'desc', '@timestamp': 'desc' }]);
});

test('it should return sort field of desc if given one for a list item index', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const getThreatList = async ({
listItemIndex: listClient.getListItemIndex(),
}),
},
track_total_hits: false,
ignore_unavailable: true,
index,
size: calculatedPerPage,
Expand Down Expand Up @@ -101,9 +102,9 @@ export const getSortWithTieBreaker = ({
}
} else {
if (sortField != null) {
return [{ [sortField]: ascOrDesc, '@timestamp': 'asc' }];
return [{ [sortField]: ascOrDesc, '@timestamp': 'desc' }];
} else {
return [{ '@timestamp': 'asc' }];
return [{ '@timestamp': 'desc' }];
}
}
};
Expand Down