From b802a5ac821b49772878e41f865e663f62f45c19 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 00:06:42 -0800 Subject: [PATCH] [Backport 2.10] Ignore correlated findings whose detector is deleted (#813) * ignore correlated findings whose detector is deleted (#811) Signed-off-by: Amardeepsingh Siglani (cherry picked from commit 059c2915e28428c87ad8547d204e9743eb3a984f) * updated workflow files Signed-off-by: Amardeepsingh Siglani * updated cypress workflow Signed-off-by: Amardeepsingh Siglani * updated tests Signed-off-by: Amardeepsingh Siglani --------- Signed-off-by: Amardeepsingh Siglani Co-authored-by: Amardeepsingh Siglani --- .github/workflows/cypress-workflow.yml | 6 +++--- .github/workflows/unit-tests-workflow.yml | 2 +- cypress/support/helpers.js | 2 ++ public/store/CorrelationsStore.ts | 14 +++++++++----- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cypress-workflow.yml b/.github/workflows/cypress-workflow.yml index bc680ce68..b0cc4e9db 100644 --- a/.github/workflows/cypress-workflow.yml +++ b/.github/workflows/cypress-workflow.yml @@ -7,8 +7,8 @@ on: branches: - "*" env: - OPENSEARCH_DASHBOARDS_VERSION: '2.x' - SECURITY_ANALYTICS_BRANCH: '2.x' + OPENSEARCH_DASHBOARDS_VERSION: '2.10.0' + SECURITY_ANALYTICS_BRANCH: '2.10' jobs: tests: name: Run Cypress E2E tests @@ -87,7 +87,7 @@ jobs: - name: Run OpenSearch-Dashboards server run: | cd OpenSearch-Dashboards - yarn start --no-base-path --no-watch & + yarn start --no-base-path --no-watch --server.host="0.0.0.0" & shell: bash # Window is slow so wait longer diff --git a/.github/workflows/unit-tests-workflow.yml b/.github/workflows/unit-tests-workflow.yml index 3df667806..c7dc2437a 100644 --- a/.github/workflows/unit-tests-workflow.yml +++ b/.github/workflows/unit-tests-workflow.yml @@ -7,7 +7,7 @@ on: branches: - "*" env: - OPENSEARCH_DASHBOARDS_VERSION: '2.x' + OPENSEARCH_DASHBOARDS_VERSION: '2.10' jobs: tests: name: Run unit tests diff --git a/cypress/support/helpers.js b/cypress/support/helpers.js index c3b990892..745074117 100644 --- a/cypress/support/helpers.js +++ b/cypress/support/helpers.js @@ -307,6 +307,8 @@ export const createDetector = ( }); }); + // Wait for the first run to execute before ingesting data + cy.wait(65000); // Ingest documents to the test index for (let i = 0; i < indexDocsCount; i++) { cy.insertDocumentToIndex(indexName, '', indexDoc); diff --git a/public/store/CorrelationsStore.ts b/public/store/CorrelationsStore.ts index ba2a53240..3d806cbd3 100644 --- a/public/store/CorrelationsStore.ts +++ b/public/store/CorrelationsStore.ts @@ -268,12 +268,16 @@ export class CorrelationsStore implements ICorrelationsStore { ); if (response?.ok) { - const correlatedFindings = response.response.findings.map((f) => { - return { - ...allFindings[f.finding], - correlationScore: f.score < 0.01 ? '0.01' : f.score.toFixed(2), - }; + const correlatedFindings: CorrelationFinding[] = []; + response.response.findings.forEach((f) => { + if (allFindings[f.finding]) { + correlatedFindings.push({ + ...allFindings[f.finding], + correlationScore: f.score < 0.01 ? '0.01' : f.score.toFixed(2), + }); + } }); + return { finding: allFindings[finding], correlatedFindings,