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

[Defend Workflows] Fix artifact entries list FTR #189961

Merged
merged 20 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2f7116c
re-enable artifact entries FTR
gergoabraham Aug 6, 2024
4912d83
add a new function layer to create any type of artifact
gergoabraham Aug 6, 2024
dd2b848
create artifacts via http request instead of ui when it's not relevan…
gergoabraham Aug 6, 2024
acfccba
enable tests for serverless
gergoabraham Aug 6, 2024
e0858a5
temp: run only artifact_entries_list test
gergoabraham Aug 6, 2024
77455d7
testing some options to decrease flakiness
gergoabraham Aug 9, 2024
f7af355
fix for quick checks
gergoabraham Aug 9, 2024
c8c6e56
increase sample size on flaky runner
gergoabraham Aug 9, 2024
dd034ed
increase timout + fail so logs are reported
gergoabraham Aug 12, 2024
d39dbbf
try more wait
gergoabraham Aug 12, 2024
c4f2020
try to enter input instead of selecting from dropdown
gergoabraham Aug 13, 2024
a0e0e99
increase timeout + re-enable data indexing
gergoabraham Aug 13, 2024
254363a
remove non-existing params
gergoabraham Aug 13, 2024
37fb27f
cleanup: use `input` instead of `customClick`
gergoabraham Aug 14, 2024
6433a8e
Revert "temp: run only artifact_entries_list test"
gergoabraham Aug 15, 2024
0eaf88d
Merge branch 'main' into fix-artifact-entries-list-ftr
gergoabraham Aug 15, 2024
43be25e
Merge branch 'main' into fix-artifact-entries-list-ftr
elasticmachine Aug 15, 2024
6066595
Merge branch 'main' into fix-artifact-entries-list-ftr
elasticmachine Aug 19, 2024
9a2172c
Merge branch 'main' into fix-artifact-entries-list-ftr
elasticmachine Aug 23, 2024
520fd90
Merge branch 'main' into fix-artifact-entries-list-ftr
elasticmachine Aug 26, 2024
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 @@ -35,7 +35,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const retry = getService('retry');
const esClient = getService('es');
const supertest = getService('supertest');
const find = getService('find');
const toasts = getService('toasts');
const policyTestResources = getService('policyTestResources');
const unzipPromisify = promisify(unzip);
Expand All @@ -52,12 +51,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
.set('kbn-xsrf', 'true');
};

// Failing: See https://github.com/elastic/kibana/issues/187314
// Failing: See https://github.com/elastic/kibana/issues/187383
// Failing: See https://github.com/elastic/kibana/issues/188131
// Failing: See https://github.com/elastic/kibana/issues/188125
describe.skip('For each artifact list under management', function () {
targetTags(this, ['@ess', '@skipInServerless']);
describe('For each artifact list under management', function () {
targetTags(this, ['@ess', '@serverless']);
this.timeout(60_000 * 5);

let indexedData: IndexedHostsAndAlertsResponse;
Expand Down Expand Up @@ -154,9 +149,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
suffix?: string
) => {
for (const formAction of actions) {
if (formAction.type === 'customClick') {
await find.clickByCssSelector(formAction.selector, testSubjects.FIND_TIME);
} else if (formAction.type === 'click') {
if (formAction.type === 'click') {
await testSubjects.click(formAction.selector);
} else if (formAction.type === 'input') {
const newValue = (formAction.value || '') + (suffix ? suffix : '');
Expand Down Expand Up @@ -265,7 +258,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

it(`should be able to update an existing ${testData.title} entry`, async () => {
await createArtifact(testData);
await endpointArtifactsTestResources.createArtifact(testData.listId, testData.createBody);
await browser.refresh();

await updateArtifact(testData, { policyId: policyInfo.packagePolicy.id });

// Check edited artifact is in the list with new values (wait for list to be updated)
Expand Down Expand Up @@ -299,7 +294,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

it(`should be able to delete the existing ${testData.title} entry`, async () => {
await createArtifact(testData);
await endpointArtifactsTestResources.createArtifact(testData.listId, testData.createBody);
await browser.refresh();

await deleteArtifact(testData);
// We only expect one artifact to have been visible
await testSubjects.missingOrFail(testData.delete.card);
Expand Down Expand Up @@ -336,7 +333,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

const testData = getCreateMultipleData();
it(`should get correct atifact when multiple entries are created`, async () => {
it(`should get correct artifact when multiple entries are created`, async () => {
// Create first trusted app
await createArtifact(testData, {
policyId: firstPolicy.packagePolicy.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@

import { FullAgentPolicy } from '@kbn/fleet-plugin/common/types';
import { ArtifactElasticsearchProperties } from '@kbn/fleet-plugin/server/services/artifacts/types';
import { GLOBAL_ARTIFACT_TAG } from '@kbn/security-solution-plugin/common/endpoint/service/artifacts';
import { InternalUnifiedManifestBaseSchema } from '@kbn/security-solution-plugin/server/endpoint/schemas/artifacts';
import { TranslatedExceptionListItem } from '@kbn/security-solution-plugin/server/endpoint/schemas/artifacts/lists';
import { CreateExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types';
import { ENDPOINT_ARTIFACT_LISTS } from '@kbn/securitysolution-list-constants';

export interface AgentPolicyResponseType {
_index: string;
Expand Down Expand Up @@ -119,6 +122,19 @@ export const getArtifactsListTestsData = () => [
confirmSelector: 'trustedAppsListPage-deleteModal-submitButton',
card: 'trustedAppsListPage-card',
},
listId: ENDPOINT_ARTIFACT_LISTS.trustedApps.id,
createBody: {
entries: [
{
type: 'match',
field: 'process.hash.sha256',
value: 'a4370c0cf81686c0b696fa6261c9d3e0d810ae704ab8301839dffd5d5112f476',
operator: 'included',
},
],
tags: [GLOBAL_ARTIFACT_TAG],
os_types: ['windows'],
} as Partial<CreateExceptionListItemSchema>,
urlPath: 'trusted_apps',
pageObject: 'trustedApps',
fleetArtifact: {
Expand Down Expand Up @@ -206,8 +222,9 @@ export const getArtifactsListTestsData = () => [
selector: 'fieldAutocompleteComboBox',
},
{
type: 'customClick',
selector: 'button[title="agent.ephemeral_id"]',
type: 'input',
selector: 'fieldAutocompleteComboBox',
value: 'agent.ephemeral_id',
},
{
type: 'click',
Expand Down Expand Up @@ -247,10 +264,6 @@ export const getArtifactsListTestsData = () => [
selector: 'fieldAutocompleteComboBox',
value: 'agent.id',
},
{
type: 'customClick',
selector: 'button[title="agent.id"]',
},
{
type: 'input',
selector: 'valuesAutocompleteMatch',
Expand Down Expand Up @@ -281,6 +294,19 @@ export const getArtifactsListTestsData = () => [
confirmSelector: 'EventFiltersListPage-deleteModal-submitButton',
card: 'EventFiltersListPage-card',
},
listId: ENDPOINT_ARTIFACT_LISTS.eventFilters.id,
createBody: {
entries: [
{
field: 'agent.ephemeral_id',
value: 'endpoint',
type: 'match',
operator: 'included',
},
],
tags: [GLOBAL_ARTIFACT_TAG],
os_types: ['windows'],
} as Partial<CreateExceptionListItemSchema>,
urlPath: 'event_filters',
pageObject: 'eventFilters',
fleetArtifact: {
Expand Down Expand Up @@ -456,6 +482,31 @@ export const getArtifactsListTestsData = () => [
card: 'blocklistCard',
},
pageObject: 'blocklist',
listId: ENDPOINT_ARTIFACT_LISTS.blocklists.id,
createBody: {
entries: [
{
type: 'match_any',
field: 'file.hash.md5',
value: ['741462ab431a22233c787baab9b653c7'],
operator: 'included',
},
{
type: 'match_any',
field: 'file.hash.sha1',
value: ['aedb279e378bed6c2db3c9dc9e12ba635e0b391c'],
operator: 'included',
},
{
type: 'match_any',
field: 'file.hash.sha256',
value: ['a4370c0cf81686c0b696fa6261c9d3e0d810ae704ab8301839dffd5d5112f476'],
operator: 'included',
},
],
tags: [GLOBAL_ARTIFACT_TAG],
os_types: ['windows'],
} as Partial<CreateExceptionListItemSchema>,
urlPath: 'blocklist',
fleetArtifact: {
identifier: 'endpoint-blocklist-windows-v1',
Expand Down Expand Up @@ -610,6 +661,19 @@ export const getArtifactsListTestsData = () => [
confirmSelector: 'hostIsolationExceptionsDeletionConfirm',
card: 'hostIsolationExceptionsCard',
},
listId: ENDPOINT_ARTIFACT_LISTS.hostIsolationExceptions.id,
createBody: {
entries: [
{
type: 'match',
field: 'destination.ip',
value: '1.1.1.1',
operator: 'included',
},
],
tags: [GLOBAL_ARTIFACT_TAG],
os_types: ['windows', 'linux', 'macos'],
} as Partial<CreateExceptionListItemSchema>,
pageObject: 'hostIsolationExceptions',
urlPath: 'host_isolation_exceptions',
fleetArtifact: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import type {
CreateExceptionListSchema,
ExceptionListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
import { EXCEPTION_LIST_ITEM_URL, EXCEPTION_LIST_URL } from '@kbn/securitysolution-list-constants';
import {
ENDPOINT_ARTIFACT_LISTS,
ENDPOINT_ARTIFACT_LIST_IDS,
EXCEPTION_LIST_ITEM_URL,
EXCEPTION_LIST_URL,
} from '@kbn/securitysolution-list-constants';
import { Response } from 'superagent';
import { ExceptionsListItemGenerator } from '@kbn/security-solution-plugin/common/endpoint/data_generators/exceptions_list_item_generator';
import { TRUSTED_APPS_EXCEPTION_LIST_DEFINITION } from '@kbn/security-solution-plugin/public/management/pages/trusted_apps/constants';
Expand Down Expand Up @@ -122,6 +127,26 @@ export class EndpointArtifactsTestResources extends FtrService {
return this.createExceptionItem(blocklist);
}

async createArtifact(
listId: (typeof ENDPOINT_ARTIFACT_LIST_IDS)[number],
overrides: Partial<CreateExceptionListItemSchema> = {}
): Promise<ArtifactTestData | undefined> {
switch (listId) {
case ENDPOINT_ARTIFACT_LISTS.trustedApps.id: {
return this.createTrustedApp(overrides);
}
case ENDPOINT_ARTIFACT_LISTS.eventFilters.id: {
return this.createEventFilter(overrides);
}
case ENDPOINT_ARTIFACT_LISTS.blocklists.id: {
return this.createBlocklist(overrides);
}
case ENDPOINT_ARTIFACT_LISTS.hostIsolationExceptions.id: {
return this.createHostIsolationException(overrides);
}
}
}

async getArtifactsFromUnifiedManifestSO(): Promise<
Array<
InternalUnifiedManifestSchemaResponseType['_source']['endpoint:unified-user-artifact-manifest']
Expand Down