Skip to content

Add support for ESOs in the "Check Saved Objects" CI check#253470

Merged
jeramysoucy merged 12 commits intoelastic:mainfrom
gsoldevila:core/expose-plugins-start-contract
Feb 25, 2026
Merged

Add support for ESOs in the "Check Saved Objects" CI check#253470
jeramysoucy merged 12 commits intoelastic:mainfrom
gsoldevila:core/expose-plugins-start-contract

Conversation

@gsoldevila
Copy link
Copy Markdown
Member

@gsoldevila gsoldevila commented Feb 17, 2026

Summary

Closes https://github.com/elastic/kibana-team/issues/2867

The Check Saved Objects CI check performs automated upgrade and rollback testing for any updated SO types.
None of the Encrypted Saved Objects had been updated since the check was put in place, up until recently.

To add support for ESOs, the KibanaMigratorTestKit must accept an encryptedSavedObjects service, so that the underlying SOR can be built with the encryption extension.

This PR adds a workaround to support encryption / decryption in the KibanaMigratorTestKit, unblocking #252104.

Made with Cursor

@gsoldevila gsoldevila added Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Feb 17, 2026
.map(({ name }) => name),
{
encryptionExtension: encryptedSavedObjects
? encryptedSavedObjects?.__testCreateExtension(typeRegistry)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here is where you could pass in overrides for specific types, like the connector token. Something like this:

 const savedObjectsRepository = SavedObjectsRepository.createRepository(
    migrator,
    typeRegistry,
    kibanaIndex,
    client,
    loggerFactory.get('saved_objects'),
    // the toolkit's SavedObjectsRepository must allow testing hidden types
    typeRegistry
      .getAllTypes()
      .filter(({ hidden }) => hidden)
      .map(({ name }) => name),
    {
      encryptionExtension: encryptedSavedObjects
        ? encryptedSavedObjects?.__testCreateExtension(typeRegistry, [
            {
              type: 'connector_token',
              attributesToEncrypt: new Set(['token']),
              attributesToIncludeInAAD: new Set([
                'connectorId',
                'tokenType',
                'expiresAt',
                'createdAt',
                'updatedAt',
              ]),
            },
          ])
        : undefined,
    }
  );

Though, it would probably make sense to store the overrides somewhere for easier access/clarity.

@jeramysoucy jeramysoucy force-pushed the core/expose-plugins-start-contract branch from ef3c7b6 to 1fec797 Compare February 20, 2026 14:23
@gsoldevila gsoldevila changed the title Expose _plugins map on internal core start contract Add support for ESOs in the "Check Saved Objects" CI check Feb 20, 2026
fix: boolean;
}

export const encryptionOverrides: EncryptedSavedObjectTypeRegistration[] = [
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm sure someone will inject something soon! 😆

@gsoldevila gsoldevila marked this pull request as ready for review February 20, 2026 15:07
@gsoldevila gsoldevila requested review from a team as code owners February 20, 2026 15:07
@gsoldevila gsoldevila requested a review from azasypkin February 20, 2026 15:07
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-core (Team:Core)

@jeramysoucy jeramysoucy self-assigned this Feb 20, 2026
Copy link
Copy Markdown
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Approving to unblock progress, left a q about a possible simplification

Comment on lines +208 to +236
__testCreateDangerousExtension: (
typeRegistry: ISavedObjectTypeRegistry,
typeRegistrationOverrides?: EncryptedSavedObjectTypeRegistration[]
): SavedObjectsEncryptionExtension => {
const testService = new EncryptedSavedObjectsService({
primaryCrypto: this.primaryCrypto,
decryptionOnlyCryptos: this.decryptionOnlyCryptos,
logger: this.logger,
});

const registeredTypes = new Set<string>();

for (const typeRegistration of typeRegistrationOverrides ?? []) {
testService.registerType(dangerouslyExposeAttributes(typeRegistration));
registeredTypes.add(typeRegistration.type);
}

for (const typeRegistration of this.typeRegistrations) {
if (!registeredTypes.has(typeRegistration.type)) {
testService.registerType(dangerouslyExposeAttributes(typeRegistration));
}
}

return new SavedObjectsEncryptionExtension({
baseTypeRegistry: typeRegistry,
service: testService,
getCurrentUser: async () => undefined,
});
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible for this to be a stateless function exported from x-pack/platform/plugins/shared/encrypted_saved_objects/server?

Then test migrator kit can pass in typeRegistry, typeRegistry overrides and logger. Just not sure about the crypto values... are they easy to mock or create test counterparts for? We could also avoid coreStart._plugins workaround.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be possible, but we'd have to move a few things that are currently encapsulated in the ESO plugin class or define them in the test code.

  • The primary and decryption-only Crypto instances. Without providing this internally in the plugin, the test code would need to create these instances. The decryption-only cryptos would likely just be an empty array. So this could be as simple as passing in an encryption key for the primary crypto from the test code.

  • The array of registered types derived from the setup phase. Without providing this internally in the plugin, the test code would need to register all applicable ESO types, which could become a pain.

I can push a commit with these changes and ask @azasypkin if hew has a preference.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@azasypkin After discussing with Gerard, given this is a temporary solution, we're going to hold off making further changes. So, this PR is ready for review. Let us know your thoughts on JL's suggestion.


await this.plugins.start(this.coreStart);
const { contracts } = await this.plugins.start(this.coreStart);
this.coreStart._plugins = contracts;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is OK given this is all internal to Core.

gsoldevila and others added 9 commits February 24, 2026 13:01
Adds a temporary `_plugins` property to `InternalCoreStart` that
exposes the plugin start contracts map. This is intended for internal
use only and enables `kbn-check-saved-objects-cli` to access the
`encryptedSavedObjects` plugin, which is needed to add ESO support
to the saved objects check tooling.

Co-authored-by: Cursor <cursoragent@cursor.com>
Removes commented console log
@gsoldevila gsoldevila force-pushed the core/expose-plugins-start-contract branch from 226c754 to 28668af Compare February 24, 2026 12:03
@gsoldevila gsoldevila force-pushed the core/expose-plugins-start-contract branch from d3d615d to 1326be5 Compare February 24, 2026 14:05
@gsoldevila gsoldevila requested a review from a team as a code owner February 24, 2026 14:05
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

Copy link
Copy Markdown
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

Mock update looks good to me

@azasypkin
Copy link
Copy Markdown
Contributor

ACK: will review today, sorry for the delay

Copy link
Copy Markdown
Contributor

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

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

LGTM, just one non-blocking suggestion to not keep test-only registration state for production use and concentrate everything within the encryption service.

@jeramysoucy jeramysoucy enabled auto-merge (squash) February 25, 2026 10:34
@jeramysoucy jeramysoucy merged commit 3cd82b3 into elastic:main Feb 25, 2026
16 checks passed
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #6 / discover responsive sidebar search bar customization should not render CustomDataViewPicker

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/migrator-test-kit 47 49 +2
encryptedSavedObjects 47 49 +2
total +4

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
encryptedSavedObjects 1 2 +1
Unknown metric groups

API count

id before after diff
@kbn/migrator-test-kit 47 49 +2
encryptedSavedObjects 54 57 +3
total +5

History

cc @jeramysoucy

qn895 pushed a commit to qn895/kibana that referenced this pull request Mar 11, 2026
…53470)

## Summary

Closes elastic/kibana-team#2867

The `Check Saved Objects` CI check performs automated upgrade and
rollback testing for any updated SO types.
None of the Encrypted Saved Objects had been updated since the check was
put in place, up until recently.

To add support for ESOs, the `KibanaMigratorTestKit` must accept an
_encryptedSavedObjects_ service, so that the underlying SOR can be built
with the encryption extension.

This PR adds a workaround to support encryption / decryption in the
`KibanaMigratorTestKit`, unblocking
elastic#252104.

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: “jeramysoucy” <jeramy.soucy@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// Team:obs-ux-management v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants