Skip to content

Commit 4ce9ad0

Browse files
authored
[8.19] [Detection Engine] Prevent test data from rolling outside of Cypress rules' query (#220923) (#221439)
# Backport This will backport the following commits from `main` to `8.19`: - [[Detection Engine] Prevent test data from rolling outside of Cypress rules' query (#220923)](#220923) <!--- Backport version: 10.0.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ryland Herrick","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-05-23T20:16:26Z","message":"[Detection Engine] Prevent test data from rolling outside of Cypress rules' query (#220923)\n\n## Summary\n\nOur tests rely on static test data, and our cypress suite was running\nrules with a large lookback (50000h) against them. Recently, tests have\nbegun failing because we've exceeded 50000h since the data's\n`@timestamp`. This PR updates the cypress rules to use a fixed `from`\nfield wherever possible, in order to \"fix\" that query window's starting\npoint, ensuring that this issue does not recur. This is already how our\nintegration tests are creating similar rules, so as an added bonus we're\nnow more consistent across test suites, as well.\n\nThis unskips and thus resolves the following issues:\n\n* https://github.com/elastic/kibana/issues/201334\n* https://github.com/elastic/kibana/issues/220822\n* https://github.com/elastic/kibana/issues/207913\n* https://github.com/elastic/kibana/issues/199905\n\nNote that there may be more instances of skipped tests that were failing\ndue to this issue (with e.g. data with an earlier date than the\n`2019-09-02` here); the above tests were just the most obvious and most\nrecent (within the last week).\n\n### Flaky Runner\n* Detection Engine Cypress (x150):\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8291\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"1f6777c40130e9804faa1b7a4a33f5e1655053a7","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","backport:prev-major","Team:Detection Engine","backport:current-major","Test:Cypress","v9.1.0"],"title":"[Detection Engine] Prevent test data from rolling outside of Cypress rules' query","number":220923,"url":"https://github.com/elastic/kibana/pull/220923","mergeCommit":{"message":"[Detection Engine] Prevent test data from rolling outside of Cypress rules' query (#220923)\n\n## Summary\n\nOur tests rely on static test data, and our cypress suite was running\nrules with a large lookback (50000h) against them. Recently, tests have\nbegun failing because we've exceeded 50000h since the data's\n`@timestamp`. This PR updates the cypress rules to use a fixed `from`\nfield wherever possible, in order to \"fix\" that query window's starting\npoint, ensuring that this issue does not recur. This is already how our\nintegration tests are creating similar rules, so as an added bonus we're\nnow more consistent across test suites, as well.\n\nThis unskips and thus resolves the following issues:\n\n* https://github.com/elastic/kibana/issues/201334\n* https://github.com/elastic/kibana/issues/220822\n* https://github.com/elastic/kibana/issues/207913\n* https://github.com/elastic/kibana/issues/199905\n\nNote that there may be more instances of skipped tests that were failing\ndue to this issue (with e.g. data with an earlier date than the\n`2019-09-02` here); the above tests were just the most obvious and most\nrecent (within the last week).\n\n### Flaky Runner\n* Detection Engine Cypress (x150):\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8291\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"1f6777c40130e9804faa1b7a4a33f5e1655053a7"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/220923","number":220923,"mergeCommit":{"message":"[Detection Engine] Prevent test data from rolling outside of Cypress rules' query (#220923)\n\n## Summary\n\nOur tests rely on static test data, and our cypress suite was running\nrules with a large lookback (50000h) against them. Recently, tests have\nbegun failing because we've exceeded 50000h since the data's\n`@timestamp`. This PR updates the cypress rules to use a fixed `from`\nfield wherever possible, in order to \"fix\" that query window's starting\npoint, ensuring that this issue does not recur. This is already how our\nintegration tests are creating similar rules, so as an added bonus we're\nnow more consistent across test suites, as well.\n\nThis unskips and thus resolves the following issues:\n\n* https://github.com/elastic/kibana/issues/201334\n* https://github.com/elastic/kibana/issues/220822\n* https://github.com/elastic/kibana/issues/207913\n* https://github.com/elastic/kibana/issues/199905\n\nNote that there may be more instances of skipped tests that were failing\ndue to this issue (with e.g. data with an earlier date than the\n`2019-09-02` here); the above tests were just the most obvious and most\nrecent (within the last week).\n\n### Flaky Runner\n* Detection Engine Cypress (x150):\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8291\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"1f6777c40130e9804faa1b7a4a33f5e1655053a7"}}]}] BACKPORT-->
1 parent 5ba8acb commit 4ce9ad0

File tree

6 files changed

+23
-39
lines changed

6 files changed

+23
-39
lines changed

x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/alerts_table_flow/rule_exceptions/closing_all_matching_alerts.cy.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ const getExceptionList1 = () => ({
4848
list_id: 'exception_list_1',
4949
});
5050

51-
// Failing: See https://github.com/elastic/kibana/issues/199905
52-
// Failing: See https://github.com/elastic/kibana/issues/199905
53-
describe.skip('Close matching Alerts ', { tags: ['@ess', '@serverless'] }, () => {
51+
describe('Close matching Alerts ', { tags: ['@ess', '@serverless'] }, () => {
5452
const ITEM_NAME = 'Sample Exception Item';
5553

5654
beforeEach(() => {

x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/entry/match_any.cy.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ describe('Exceptions match_any', { tags: ['@ess', '@serverless'] }, () => {
4545
index: ['auditbeat-exceptions-*'],
4646
enabled: false,
4747
query: '*',
48-
from: 'now-438300h',
4948
})
5049
).then((rule) => visitRuleDetailsPage(rule.body.id, { tab: 'rule_exceptions' }));
5150
cy.get(RULE_STATUS).should('have.text', '—');

x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/rule_details_flow/add_edit_exception.cy.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ import {
5858
} from '../../../../../tasks/api_calls/exceptions';
5959
import { waitForAlertsToPopulate } from '../../../../../tasks/create_new_rule';
6060

61-
// TODO: https://github.com/elastic/kibana/issues/161539
62-
// Failing: See https://github.com/elastic/kibana/issues/220822
63-
// Failing: See https://github.com/elastic/kibana/issues/220822
64-
describe.skip(
61+
describe(
6562
'Add/edit exception from rule details',
6663
{ tags: ['@ess', '@serverless', '@skipInServerless'] },
6764
() => {

x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/exceptions/rule_details_flow/add_edit_exception_data_view.cy.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ import { waitForAlertsToPopulate } from '../../../../../tasks/create_new_rule';
4747

4848
const DATAVIEW = 'auditbeat-exceptions-*';
4949

50-
// Failing: See https://github.com/elastic/kibana/issues/207913
51-
// Failing: See https://github.com/elastic/kibana/issues/207913
52-
describe.skip(
50+
describe(
5351
'Add exception using data views from rule details',
5452
{ tags: ['@ess', '@serverless'] },
5553
() => {

x-pack/test/security_solution_cypress/cypress/e2e/detection_response/detection_engine/rule_creation/indicator_match_rule.cy.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
import { formatMitreAttackDescription, getHumanizedDuration } from '../../../../helpers/rules';
8+
import { formatMitreAttackDescription } from '../../../../helpers/rules';
99
import {
1010
getIndexPatterns,
1111
getNewThreatIndicatorRule,
@@ -31,7 +31,6 @@ import {
3131
ABOUT_DETAILS,
3232
ABOUT_INVESTIGATION_NOTES,
3333
ABOUT_RULE_DESCRIPTION,
34-
ADDITIONAL_LOOK_BACK_DETAILS,
3534
CUSTOM_QUERY_DETAILS,
3635
DEFINITION_DETAILS,
3736
FALSE_POSITIVES_DETAILS,
@@ -488,13 +487,6 @@ describe(
488487
getDetails(RUNS_EVERY_DETAILS)
489488
.find(INTERVAL_ABBR_VALUE)
490489
.should('have.text', `${rule.interval}`);
491-
const humanizedDuration = getHumanizedDuration(
492-
rule.from ?? 'now-6m',
493-
rule.interval ?? '5m'
494-
);
495-
getDetails(ADDITIONAL_LOOK_BACK_DETAILS)
496-
.find(INTERVAL_ABBR_VALUE)
497-
.should('have.text', `${humanizedDuration}`);
498490
});
499491

500492
waitForTheRuleToBeExecuted();

x-pack/test/security_solution_cypress/cypress/objects/rule.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const getDataViewRule = (
132132
threat: [getMitre1(), getMitre2()],
133133
note: '# test markdown',
134134
interval: '100m',
135-
from: 'now-50000h',
135+
from: '1900-01-01T00:00:00.000Z',
136136
max_signals: 100,
137137
...rewrites,
138138
});
@@ -153,7 +153,7 @@ export const getNewRule = (
153153
threat: [getMitre1(), getMitre2()],
154154
note: '# test markdown',
155155
interval: '100m',
156-
from: 'now-50000h',
156+
from: '1900-01-01T00:00:00.000Z',
157157
max_signals: 100,
158158
...rewrites,
159159
});
@@ -168,7 +168,7 @@ export const getSavedQueryRule = (
168168
name: 'New Rule Test',
169169
description: 'The new rule description.',
170170
interval: '100m',
171-
from: 'now-50000h',
171+
from: '1900-01-01T00:00:00.000Z',
172172
severity: 'low',
173173
risk_score: 21,
174174
...rewrites,
@@ -183,7 +183,7 @@ export const getSimpleCustomQueryRule = (
183183
name: 'New Rule Test',
184184
description: 'The new rule description.',
185185
interval: '100m',
186-
from: 'now-50000h',
186+
from: '1900-01-01T00:00:00.000Z',
187187
severity: 'low',
188188
risk_score: 21,
189189
...rewrites,
@@ -205,7 +205,7 @@ export const getBuildingBlockRule = (
205205
threat: [getMitre1(), getMitre2()],
206206
note: '# test markdown',
207207
interval: '100m',
208-
from: 'now-50000h',
208+
from: '1900-01-01T00:00:00.000Z',
209209
max_signals: 100,
210210
building_block_type: 'default',
211211
...rewrites,
@@ -227,7 +227,7 @@ export const getUnmappedRule = (
227227
threat: [getMitre1(), getMitre2()],
228228
note: '# test markdown',
229229
interval: '100m',
230-
from: 'now-50000h',
230+
from: '1900-01-01T00:00:00.000Z',
231231
max_signals: 100,
232232
...rewrites,
233233
});
@@ -248,7 +248,7 @@ export const getUnmappedCCSRule = (
248248
threat: [getMitre1(), getMitre2()],
249249
note: '# test markdown',
250250
interval: '100m',
251-
from: 'now-50000h',
251+
from: '1900-01-01T00:00:00.000Z',
252252
max_signals: 100,
253253
...rewrites,
254254
});
@@ -269,7 +269,7 @@ export const getExistingRule = (
269269
threat: [],
270270
note: 'This is my note',
271271
interval: '100m',
272-
from: 'now-50000h',
272+
from: '1900-01-01T00:00:00.000Z',
273273
// Please do not change, or if you do, needs
274274
// to be any number other than default value
275275
max_signals: 500,
@@ -303,7 +303,7 @@ export const getNewOverrideRule = (
303303
rule_name_override: 'agent.type',
304304
timestamp_override: '@timestamp',
305305
interval: '100m',
306-
from: 'now-50000h',
306+
from: '1900-01-01T00:00:00.000Z',
307307
max_signals: 100,
308308
...rewrites,
309309
});
@@ -328,7 +328,7 @@ export const getNewThresholdRule = (
328328
value: 1,
329329
},
330330
interval: '100m',
331-
from: 'now-50000h',
331+
from: '1900-01-01T00:00:00.000Z',
332332
max_signals: 100,
333333
...rewrites,
334334
});
@@ -349,9 +349,9 @@ export const getNewTermsRule = (
349349
threat: [getMitre1(), getMitre2()],
350350
note: '# test markdown',
351351
new_terms_fields: ['host.name'],
352-
history_window_start: 'now-51000h',
352+
history_window_start: `now-${365 * 150}d`,
353353
interval: '100m',
354-
from: 'now-50000h',
354+
from: '1900-01-01T00:00:00.000Z',
355355
max_signals: 100,
356356
...rewrites,
357357
});
@@ -375,7 +375,7 @@ export const getMachineLearningRule = (
375375
threat: [getMitre1()],
376376
note: '# test markdown',
377377
interval: '100m',
378-
from: 'now-50000h',
378+
from: '1900-01-01T00:00:00.000Z',
379379
...rewrites,
380380
});
381381

@@ -396,7 +396,7 @@ export const getEqlRule = (
396396
threat: [getMitre1(), getMitre2()],
397397
note: '# test markdown',
398398
interval: '100m',
399-
from: 'now-50000h',
399+
from: '1900-01-01T00:00:00.000Z',
400400
max_signals: 100,
401401
...rewrites,
402402
});
@@ -417,7 +417,7 @@ export const getEsqlRule = (
417417
threat: [getMitre1(), getMitre2()],
418418
note: '# test markdown',
419419
interval: '100m',
420-
from: 'now-50000h',
420+
from: '1900-01-01T00:00:00.000Z',
421421
max_signals: 100,
422422
...rewrites,
423423
});
@@ -439,7 +439,7 @@ export const getCCSEqlRule = (
439439
threat: [getMitre1(), getMitre2()],
440440
note: '# test markdown',
441441
interval: '100m',
442-
from: 'now-50000h',
442+
from: '1900-01-01T00:00:00.000Z',
443443
max_signals: 100,
444444
...rewrites,
445445
});
@@ -464,7 +464,7 @@ export const getEqlSequenceRule = (
464464
threat: [getMitre1(), getMitre2()],
465465
note: '# test markdown',
466466
interval: '100m',
467-
from: 'now-50000h',
467+
from: '1900-01-01T00:00:00.000Z',
468468
max_signals: 100,
469469
...rewrites,
470470
});
@@ -487,7 +487,7 @@ export const getNewThreatIndicatorRule = (
487487
threat: [getMitre1(), getMitre2()],
488488
note: '# test markdown',
489489
interval: '100m',
490-
from: 'now-50000h',
490+
from: '2000-01-01T00:00:00.000Z',
491491
threat_index: ['filebeat-*'],
492492
threat_mapping: [
493493
{
@@ -673,7 +673,7 @@ export const getEndpointRule = (): QueryRuleCreateProps => ({
673673
severity: 'high',
674674
risk_score: 17,
675675
interval: '1m',
676-
from: 'now-50000h',
676+
from: '1900-01-01T00:00:00.000Z',
677677
max_signals: 100,
678678
exceptions_list: [
679679
{

0 commit comments

Comments
 (0)