Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Tests to verify command and beacon counts (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccarpenter28 authored Nov 15, 2022
1 parent cf217c2 commit caa1009
Show file tree
Hide file tree
Showing 23 changed files with 450 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ export const BeaconRow = observer<BeaconProps>(({ beacon, ...props }) => {
<RowMuted className={skeletonClass}>{beacon.meta?.[0]?.maybeCurrent?.username}</RowMuted>
<FlexSplitter />
<MitreTechniqueIcons mitreAttackIds={beacon.mitreTechniques} />
<IconLabel title="Commands" value={beacon.commandsCount} icon={semanticIcons.commands} className={skeletonClass} />
<IconLabel
cy-test="row-command-count"
title="Commands"
value={beacon.commandsCount}
icon={semanticIcons.commands}
className={skeletonClass}
/>
</InfoRow>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const HostRow = observer<HostRowProps>(({ host, ...props }) => {
<FlexSplitter />
{!host.cobaltStrikeServer && (
<>
<IconLabel title="Commands" value={host.commandsCount} icon={semanticIcons.commands} />
<IconLabel value={host.beaconCount} title="Beacons" icon={semanticIcons.beacon} />
<IconLabel cy-test="row-command-count" title="Commands" value={host.commandsCount} icon={semanticIcons.commands} />
<IconLabel cy-test="row-beacon-count" value={host.beaconCount} title="Beacons" icon={semanticIcons.beacon} />
</>
)}
</InfoRow>
Expand Down
16 changes: 13 additions & 3 deletions applications/client/src/views/Campaign/Explore/Panels/Operator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,25 @@ export const Operators = observer<OperatorsProps>(({ ...props }) => {
<MessageRow>No Operators</MessageRow>
) : (
operators.map((operator) => (
<InfoRow cy-test="operators" key={operator.name} onClick={async () => await operator.select()}>
<InfoRow cy-test="operator-row" key={operator.name} onClick={async () => await operator.select()}>
<RowTime cy-test="operator-time" state={operator.state}>
{store.settings.momentTz(operator.startTime)?.format(dateShortFormat)}&mdash;
{store.settings.momentTz(operator.endTime)?.format(dateShortFormat)}
</RowTime>
<RowTitle>{operator.name}</RowTitle>
<FlexSplitter />
<IconLabel value={operator.logIds?.length} title="Commands" icon={semanticIcons.commands} />
<IconLabel value={operator.beaconIds?.length} title="Beacons" icon={semanticIcons.beacon} />
<IconLabel
cy-test="row-command-count"
value={operator.logIds?.length}
title="Commands"
icon={semanticIcons.commands}
/>
<IconLabel
cy-test="row-beacon-count"
value={operator.beaconIds?.length}
title="Beacons"
icon={semanticIcons.beacon}
/>
</InfoRow>
))
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export const OverviewCommandTypes = observer<OverviewProps>(({ sort }) => {
<InfoRow cy-test="commands" key={commandTypeCount.id} onClick={() => commandTypeCount.select()}>
<RowTitle>{commandTypeCount.text}</RowTitle>
<FlexSplitter />
<IconLabel title="Commands" value={commandTypeCount.count} icon={semanticIcons.commands} />
<IconLabel
cy-test="row-command-count"
title="Commands"
value={commandTypeCount.count}
icon={semanticIcons.commands}
/>
</InfoRow>
))
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,25 @@ export const OverviewOperators = observer<OverviewProps>(({ sort }) => {
<MessageRow>No Operators</MessageRow>
) : (
operators.map((operator) => (
<InfoRow cy-test="operators" key={operator.name} onClick={() => operator.select()}>
<InfoRow cy-test="operator-row" key={operator.name} onClick={() => operator.select()}>
<RowTime cy-test="operator-time" state={operator.state}>
{store.settings.momentTz(operator.startTime)?.format(dateShortFormat)}&mdash;
{store.settings.momentTz(operator.endTime)?.format(dateShortFormat)}
</RowTime>
<RowTitle>{operator.name}</RowTitle>
<FlexSplitter />
<IconLabel value={operator.logIds?.length} title="Commands" icon={semanticIcons.commands} />
<IconLabel value={operator.beaconIds?.length} title="Beacons" icon={semanticIcons.beacon} />
<IconLabel
cy-test="row-command-count"
value={operator.logIds?.length}
title="Commands"
icon={semanticIcons.commands}
/>
<IconLabel
cy-test="row-beacon-count"
value={operator.beaconIds?.length}
title="Beacons"
icon={semanticIcons.beacon}
/>
</InfoRow>
))
)}
Expand Down
139 changes: 139 additions & 0 deletions applications/redeye-e2e/src/integration/e2e/beacon-count.skip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/// <reference types="cypress" />

// PENDING BUG FIX FOR FIRST 2 TESTS BELOW

describe('Beacon counts', () => {
const camp = 'beaconcounts';
const fileName = 'gt.redeye';

it('Verify beacon counts on campaign card against counts on Hosts tab of campaign', () => {
cy.uploadCampaign(camp, fileName);
cy.searchForCampaign(camp);

// Log starting number of campaign comments on campaign card
cy.get('[cy-test=beacon-count]').then((number1) => {
const beaconTotal = number1.text().split(' ').shift();
cy.get('[cy-test=beacon-count]').should('contain', beaconTotal);

// Open campaign and add up counts of beacons by host - should equal number showing on campaign
cy.selectCampaign(camp);
cy
.get('[cy-test=row-beacon-count]')
.eq(0)
.invoke('text')
.then((countRow1) => {
// cy.log(countRow1);

cy
.get('[cy-test=row-beacon-count]')
.eq(1)
.invoke('text')
.then((countRow2) => {
// cy.log(countRow2);

expect(+countRow1 + +countRow2).to.eq(+beaconTotal);
});
});
});
});

it('Verify beacon counts on campaign card against number on Beacons tab of campaign', () => {
cy.searchForCampaign(camp);

// Log starting number of campaign comments on campaign card
cy.get('[cy-test=beacon-count]').then((number1) => {
const beaconTotal = number1.text().split(' ').shift();
cy.get('[cy-test=beacon-count]').should('contain', beaconTotal);

// Open campaign and count number of beacons showing under Beacons tab - should equal number showing on campaign card
cy.selectCampaign(camp);
cy.clickBeaconsTab();
cy
.get('[cy-test=beacons-row]')
.its('length')
.then((countBeaconRows) => {
// cy.log(countBeaconRows);

expect(+countBeaconRows).to.eq(+beaconTotal);
});
});
});

it('Verify beacon counts on Hosts tab are accurate', () => {
cy.selectCampaign(camp);

// Open campaign and log beacon count for first host
cy
.get('[cy-test=row-beacon-count]')
.eq(0)
.invoke('text')
.then((countHost1) => {
cy.log(countHost1);

// Click host to open details
cy.get('[cy-test=info-row]').eq(1).click();

// Go to Beacons tab and log number of beacons showing - should match count in host row
cy.clickBeaconsTab();
cy
.get('[cy-test=info-row]')
.its('length')
.then((countBeaconsHost1) => {
// cy.log(countBeaconsHost1);
expect(+countBeaconsHost1).to.eq(+countHost1);
});
});
// Go back to Hosts and log beacon count for second host
cy.get('[cy-test=explorer-mode]').click();
cy
.get('[cy-test=row-beacon-count]')
.eq(1)
.invoke('text')
.then((countHost2) => {
cy.log(countHost2);

// Click host to open deatails
cy.get('[cy-test=info-row]').eq(2).click();

// Go to Beacons tab and log number of beacons showing - should match count in host row
cy.clickBeaconsTab();
cy
.get('[cy-test=info-row]')
.its('length')
.then((countBeaconsHost2) => {
// cy.log(countBeaconsHost2);
expect(+countBeaconsHost2).to.eq(+countHost2);
});
});
});

it('Verify beacon counts on Operator tab are accurate', () => {
cy.selectCampaign(camp);

// Open campaign and go to Operator tab; log beacon count
cy.get('[cy-test=operators]').click();
cy
.get('[cy-test=row-beacon-count]')
.invoke('text')
.then((countRow) => {
cy.log(countRow);

// Open operator and go to Beacons tab
cy.get('[cy-test=operator-row]').click();
cy.get('[cy-test=beacons]').click();

// Log number of beacons showing - should match number from Operator tab count
cy
.get('[cy-test=info-row]')
.its('length')
.then((countOperatorBeacons) => {
cy.log(countOperatorBeacons);
expect(+countOperatorBeacons).to.eq(+countRow);
});
});
});

after(() => {
cy.deleteCampaignGraphQL(camp);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Campaign comments', () => {
// Add a new comment
cy.clickExplorerMode();

cy.clickCommandsTypesTab();
cy.clickCommandTypesTab();

cy.selectCommandType(cmd);

Expand Down Expand Up @@ -129,7 +129,7 @@ describe('Campaign comments', () => {
// Delete comment
cy.clickExplorerMode();

cy.clickCommandsTypesTab();
cy.clickCommandTypesTab();

cy.selectCommandType(cmd);

Expand Down Expand Up @@ -186,7 +186,7 @@ describe('Campaign comments', () => {
// Open the campaign and add a new comment
cy.selectCampaign(camp);

cy.clickCommandsTypesTab();
cy.clickCommandTypesTab();

cy.selectCommandType(cmd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Check and verify screenshots are available', () => {

cy.selectCampaign(camp);

cy.clickCommandsTypesTab();
cy.clickCommandTypesTab();

cy.selectCommandType('screenshot');

Expand Down
Loading

0 comments on commit caa1009

Please sign in to comment.