Skip to content

Commit

Permalink
Filtered findings shown in alert details (opensearch-project#229)
Browse files Browse the repository at this point in the history
* filtered findings

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* fixed cypress test

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* removed breaking change

Signed-off-by: Amardeepsingh Siglani <[email protected]>

Signed-off-by: Amardeepsingh Siglani <[email protected]>
  • Loading branch information
amsiglan authored Dec 20, 2022
1 parent be6ac4a commit 8d9e370
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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
5 changes: 4 additions & 1 deletion public/pages/Alerts/components/AlertFlyout/AlertFlyout.tsx
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

0 comments on commit 8d9e370

Please sign in to comment.