Skip to content

Commit

Permalink
Skip failing serverless tests in release branch (#201248)
Browse files Browse the repository at this point in the history
## Summary

- Skips serverless cypress tests in release branch, since they are
failing
  • Loading branch information
paul-tavares authored Nov 21, 2024
1 parent 3fb1bd5 commit 5c06edc
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 356 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,72 +19,84 @@ import { login, ROLE } from '../tasks/login';
import { EXECUTE_ROUTE } from '../../../../common/endpoint/constants';
import { waitForActionToComplete } from '../tasks/response_actions';

describe('Endpoint generated alerts', { tags: ['@ess', '@serverless'] }, () => {
let indexedPolicy: IndexedFleetEndpointPolicyResponse;
let policy: PolicyData;
let createdHost: CreateAndEnrollEndpointHostResponse;
describe(
'Endpoint generated alerts',
{
tags: [
'@ess',
'@serverless',
'@brokenInServerless',
'@skipInServerless',
'@skipInServerlessMKI',
],
},
() => {
let indexedPolicy: IndexedFleetEndpointPolicyResponse;
let policy: PolicyData;
let createdHost: CreateAndEnrollEndpointHostResponse;

beforeEach(() => {
login(ROLE.soc_manager);
getEndpointIntegrationVersion().then((version) => {
createAgentPolicyTask(version, 'alerts test').then((data) => {
indexedPolicy = data;
policy = indexedPolicy.integrationPolicies[0];
beforeEach(() => {
login(ROLE.soc_manager);
getEndpointIntegrationVersion().then((version) => {
createAgentPolicyTask(version, 'alerts test').then((data) => {
indexedPolicy = data;
policy = indexedPolicy.integrationPolicies[0];

return enableAllPolicyProtections(policy.id).then(() => {
// Create and enroll a new Endpoint host
return createEndpointHost(policy.policy_ids[0]).then((host) => {
createdHost = host as CreateAndEnrollEndpointHostResponse;
return enableAllPolicyProtections(policy.id).then(() => {
// Create and enroll a new Endpoint host
return createEndpointHost(policy.policy_ids[0]).then((host) => {
createdHost = host as CreateAndEnrollEndpointHostResponse;
});
});
});
});
});
});

afterEach(() => {
if (createdHost) {
cy.task('destroyEndpointHost', createdHost);
}
afterEach(() => {
if (createdHost) {
cy.task('destroyEndpointHost', createdHost);
}

if (indexedPolicy) {
cy.task('deleteIndexedFleetEndpointPolicies', indexedPolicy);
}
if (indexedPolicy) {
cy.task('deleteIndexedFleetEndpointPolicies', indexedPolicy);
}

if (createdHost) {
deleteAllLoadedEndpointData({ endpointAgentIds: [createdHost.agentId] });
}
});
if (createdHost) {
deleteAllLoadedEndpointData({ endpointAgentIds: [createdHost.agentId] });
}
});

it('should create a Detection Engine alert from an endpoint alert', () => {
// Triggers a Malicious Behaviour alert on Linux system (`grep *` was added only to identify this specific alert)
const executeMaliciousCommand = `bash -c cat /dev/tcp/foo | grep ${Math.random()
.toString(16)
.substring(2)}`;
it('should create a Detection Engine alert from an endpoint alert', () => {
// Triggers a Malicious Behaviour alert on Linux system (`grep *` was added only to identify this specific alert)
const executeMaliciousCommand = `bash -c cat /dev/tcp/foo | grep ${Math.random()
.toString(16)
.substring(2)}`;

// Send `execute` command that triggers malicious behaviour using the `execute` response action
request<ResponseActionApiResponse>({
method: 'POST',
url: EXECUTE_ROUTE,
body: {
endpoint_ids: [createdHost.agentId],
parameters: {
command: executeMaliciousCommand,
},
},
})
.then((response) => waitForActionToComplete(response.body.data.id))
.then(() => {
return waitForEndpointAlerts(createdHost.agentId, [
{
term: { 'process.group_leader.args': executeMaliciousCommand },
// Send `execute` command that triggers malicious behaviour using the `execute` response action
request<ResponseActionApiResponse>({
method: 'POST',
url: EXECUTE_ROUTE,
body: {
endpoint_ids: [createdHost.agentId],
parameters: {
command: executeMaliciousCommand,
},
]);
},
})
.then(() => {
return navigateToAlertsList(
`query=(language:kuery,query:'agent.id: "${createdHost.agentId}" ')`
);
});
getAlertsTableRows().should('have.length.greaterThan', 0);
});
});
.then((response) => waitForActionToComplete(response.body.data.id))
.then(() => {
return waitForEndpointAlerts(createdHost.agentId, [
{
term: { 'process.group_leader.args': executeMaliciousCommand },
},
]);
})
.then(() => {
return navigateToAlertsList(
`query=(language:kuery,query:'agent.id: "${createdHost.agentId}" ')`
);
});
getAlertsTableRows().should('have.length.greaterThan', 0);
});
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -21,54 +21,66 @@ import { enableAllPolicyProtections } from '../../../tasks/endpoint_policy';
import { createEndpointHost } from '../../../tasks/create_endpoint_host';
import { deleteAllLoadedEndpointData } from '../../../tasks/delete_all_endpoint_data';

describe('Response console', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
login();
});
describe(
'Response console',
{
tags: [
'@ess',
'@serverless',
'@brokenInServerless',
'@skipInServerless',
'@skipInServerlessMKI',
],
},
() => {
beforeEach(() => {
login();
});

describe('Execute operations:', () => {
const homeFilePath = process.env.CI || true ? '/home/vagrant' : `/home/ubuntu`;
describe('Execute operations:', () => {
const homeFilePath = process.env.CI || true ? '/home/vagrant' : `/home/ubuntu`;

let indexedPolicy: IndexedFleetEndpointPolicyResponse;
let policy: PolicyData;
let createdHost: CreateAndEnrollEndpointHostResponse;
let indexedPolicy: IndexedFleetEndpointPolicyResponse;
let policy: PolicyData;
let createdHost: CreateAndEnrollEndpointHostResponse;

before(() => {
getEndpointIntegrationVersion().then((version) =>
createAgentPolicyTask(version).then((data) => {
indexedPolicy = data;
policy = indexedPolicy.integrationPolicies[0];
before(() => {
getEndpointIntegrationVersion().then((version) =>
createAgentPolicyTask(version).then((data) => {
indexedPolicy = data;
policy = indexedPolicy.integrationPolicies[0];

return enableAllPolicyProtections(policy.id).then(() => {
// Create and enroll a new Endpoint host
return createEndpointHost(policy.policy_ids[0]).then((host) => {
createdHost = host as CreateAndEnrollEndpointHostResponse;
return enableAllPolicyProtections(policy.id).then(() => {
// Create and enroll a new Endpoint host
return createEndpointHost(policy.policy_ids[0]).then((host) => {
createdHost = host as CreateAndEnrollEndpointHostResponse;
});
});
});
})
);
});
})
);
});

after(() => {
if (createdHost) {
cy.task('destroyEndpointHost', createdHost);
}
after(() => {
if (createdHost) {
cy.task('destroyEndpointHost', createdHost);
}

if (indexedPolicy) {
cy.task('deleteIndexedFleetEndpointPolicies', indexedPolicy);
}
if (indexedPolicy) {
cy.task('deleteIndexedFleetEndpointPolicies', indexedPolicy);
}

if (createdHost) {
deleteAllLoadedEndpointData({ endpointAgentIds: [createdHost.agentId] });
}
});
if (createdHost) {
deleteAllLoadedEndpointData({ endpointAgentIds: [createdHost.agentId] });
}
});

it('"execute --command" - should execute a command', () => {
waitForEndpointListPageToBeLoaded(createdHost.hostname);
openResponseConsoleFromEndpointList();
inputConsoleCommand(`execute --command "ls -al ${homeFilePath}"`);
submitCommand();
waitForCommandToBeExecuted('execute');
it('"execute --command" - should execute a command', () => {
waitForEndpointListPageToBeLoaded(createdHost.hostname);
openResponseConsoleFromEndpointList();
inputConsoleCommand(`execute --command "ls -al ${homeFilePath}"`);
submitCommand();
waitForCommandToBeExecuted('execute');
});
});
});
});
}
);
Loading

0 comments on commit 5c06edc

Please sign in to comment.