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

[ResponseOps][Rules] Validate timezone in rule routes #201508

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cnasikas
Copy link
Member

@cnasikas cnasikas commented Nov 24, 2024

Summary

This PR adds validation only for internal routes that use the rRule schema.

Checklist

@cnasikas cnasikas added Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v9.0.0 Feature:Alerting/RulesFramework Issues related to the Alerting Rules Framework backport:prev-major Backport to (8.x, 8.17, 8.16, 8.15) the previous major branch and other branches in development v8.17.0 v8.18.0 labels Nov 24, 2024
@cnasikas cnasikas self-assigned this Nov 24, 2024
@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 24, 2024

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!

@cnasikas cnasikas added the backport:skip This commit does not require backporting label Nov 24, 2024

export function validateTimezone(timezone: string) {
if (moment.tz.names().includes(timezone)) {
if (moment.tz.zone(timezone) != null) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moment.tz.zone is faster than moment.tz.names().includes.

@@ -478,6 +478,38 @@ export default function createAlertTests({ getService }: FtrProviderContext) {
});
});

it('should return 400 if the timezone of an action is not valid', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation already existed. I added a test to avoid bugs in the future.

@@ -182,6 +182,51 @@ export default function createUpdateTests({ getService }: FtrProviderContext) {
});
});

it('should return 400 if the timezone of an action is not valid', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation already existed. I added a test to avoid bugs in the future.

Copy link
Member Author

@cnasikas cnasikas Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validations are used only in internal routes.

@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 24, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Rules, Alerts and Exceptions ResponseOps Cypress Tests on Security Solution #3 / rule snoozing Rules management table unsnoozes a rule with actions unsnoozes a rule with actions
  • [job] [logs] Serverless Rule Management - Security Solution Cypress Tests #3 / rule snoozing Rules management table unsnoozes a rule with actions unsnoozes a rule with actions
  • [job] [logs] Rule Management - Security Solution Cypress Tests #2 / rule snoozing Rules management table unsnoozes a rule with actions unsnoozes a rule with actions
  • [job] [logs] Rules, Alerts and Exceptions ResponseOps Cypress Tests on Security Solution #3 / rule snoozing Rules management table unsnoozes a rule with actions unsnoozes a rule with actions

Metrics [docs]

✅ unchanged

History

cc @cnasikas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-major Backport to (8.x, 8.17, 8.16, 8.15) the previous major branch and other branches in development backport:skip This commit does not require backporting Feature:Alerting/RulesFramework Issues related to the Alerting Rules Framework Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.17.0 v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants