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

Filtered findings shown in alert details #229

Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions cypress/integration/3_alerts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ describe('Alerts', () => {
cy.get('[data-test-subj="text-details-group-content-detector"]').contains(testDetector.name);

// Wait for the findings table to finish loading
cy.contains('Findings (4)', TWENTY_SECONDS_TIMEOUT);
cy.contains('Findings (1)', TWENTY_SECONDS_TIMEOUT);
cy.contains('USB Device Plugged', TWENTY_SECONDS_TIMEOUT);

// Confirm alert findings contain expected values
cy.get('tbody > tr', TWENTY_SECONDS_TIMEOUT)
.should(($tr) => expect($tr, '4 rows').to.have.length(4))
.should(($tr) => expect($tr, '1 row').to.have.length(1))
.each(($el, $index) => {
expect($el, `row number ${$index} timestamp`).to.contain(date);
expect($el, `row number ${$index} rule name`).to.contain('USB Device Plugged');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export class AlertFlyout extends React.Component<AlertFlyoutProps, AlertFlyoutSt
try {
const findingRes = await findingsService.getFindings({ detectorId: detector_id });
if (findingRes.ok) {
this.setState({ findingItems: findingRes.response.findings });
const relatedFindings = findingRes.response.findings.filter((finding) =>
this.props.alertItem.finding_ids.includes(finding.id)
);
this.setState({ findingItems: relatedFindings });
} else {
errorNotificationToast(notifications, 'retrieve', 'findings', findingRes.error);
}
Expand Down