Skip to content

Conversation

@jbanety
Copy link
Contributor

@jbanety jbanety commented Oct 29, 2025

Proposed changes

  • Add environment variable xtmhub_connectivity_email_enabled to control Hub connectivity lost email notifications
  • Modify checkXTMHubConnectivity() to check configuration before sending emails
  • Add unit test to verify emails are not sent when configuration is disabled
  • Keep connectivity check and UI status display active regardless of email configuration

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case (coverage and e2e)
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

Context:
On demo instances that are reset daily, the Hub connectivity check fails regularly because the registration state becomes invalid after each reset. This triggers automated emails to administrators every 24 hours, causing email spam.

Solution:
This PR adds a new environment variable OPENCTI__XTM__XTMHUB_CONNECTIVITY_EMAIL_ENABLED (default: true) to control email notifications while keeping all other functionality intact:

What continues to work:

  • Hub connectivity check runs every hour (via hub_registration_manager)
  • Connection status is updated in the database
  • Status remains visible in the UI
  • Connectivity restoration triggers re-enable email notifications

What can be disabled:

  • Email notifications to administrators when connectivity is lost

Usage for demo instances:
Set environment variable: OPENCTI__XTM__XTMHUB_CONNECTIVITY_EMAIL_ENABLED=false

Files changed:

  • config/default.json - Added configuration with default value true
  • src/domain/xtm-hub.ts - Added configuration check before sending emails
  • tests/01-unit/domain/xtm-hub-test.ts - Added test case for disabled emails scenario

Backward compatibility:
The default value is true, preserving the current behavior for all existing instances. Only instances that explicitly set the variable to false will have emails disabled.

Testing:
Added unit test should not send connectivity email when email sending is disabled via configuration that verifies:

  • When configuration is set to false
  • And all other conditions for sending email are met (24h passed, connectivity lost, settings flag true)
  • Then no email is sent and no settings update occurs

@jbanety jbanety added this to the Release 6.9.0 milestone Oct 29, 2025
@jbanety jbanety requested a review from Kroustille October 29, 2025 08:21
@jbanety jbanety self-assigned this Oct 29, 2025
@jbanety jbanety added the filigran team use to identify PR from the Filigran team label Oct 29, 2025
@jbanety jbanety requested review from aHenryJard and delemaf October 29, 2025 08:25
@aHenryJard aHenryJard changed the title feat(hub): add configuration to disable connectivity email notifications [backend] xtm-hub: add configuration to disable connectivity email notifications (#12988) Oct 29, 2025
@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.19%. Comparing base (babcb3e) to head (a17251d).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12990      +/-   ##
==========================================
+ Coverage   16.17%   16.19%   +0.01%     
==========================================
  Files        2841     2841              
  Lines      411583   411800     +217     
  Branches    11359    11417      +58     
==========================================
+ Hits        66563    66673     +110     
- Misses     345020   345127     +107     
Flag Coverage Δ
opencti 16.19% <100.00%> (+0.01%) ⬆️
opencti-front 3.91% <ø> (+0.01%) ⬆️
opencti-graphql 67.07% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

context: AuthContext,
user: AuthUser,
): Promise<{
status: XtmHubRegistrationStatus;
Copy link
Member

Choose a reason for hiding this comment

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

why all these formatting changes ? do you have a different formatter ? It makes it difficult to read the PR and see the changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry I don't know what happened. It's fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team use to identify PR from the Filigran team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants