Skip to content

[Cloud Security] [Fleet] Add var_group components and validation#249449

Merged
seanrathier merged 15 commits intoelastic:mainfrom
seanrathier:var_groups
Jan 28, 2026
Merged

[Cloud Security] [Fleet] Add var_group components and validation#249449
seanrathier merged 15 commits intoelastic:mainfrom
seanrathier:var_groups

Conversation

@seanrathier
Copy link
Copy Markdown
Contributor

@seanrathier seanrathier commented Jan 16, 2026

Parent: https://github.com/elastic/security-team/issues/15396

Summary

This PR implements var_groups recognition, add the VarGroupsSelector component, and persistence for var_group_selections at both the package level and stream level in Fleet package policies. Variable groups (var_groups) allow package authors to define mutually exclusive sets of variables, enabling users to choose between different configuration options (e.g., API Key vs OAuth authentication).

Blocked to merge by

Integration manifest example

var_groups:
  - name: credential_type
    required: true
    title: Setup Access
    selector_title: Preferred method
    description: Utilize AWS Access Keys or assume role to set up access for assessing your AWS environment's security posture. Refer to our Getting Started guide for details.
    options:
      - name: cloud_connectors
        title: Cloud Connector
        vars: [cloud_connector_account_type, cloud_connector_name, role_arn, external_id]
        hide_in_deployment_modes: [default]
      - name: direct_access_key
        title: Direct Access Keys
        vars: [access_key_id, secret_access_key]
      - name: temporary_access_key
        title: Temporary Access Keys
        vars: [access_key_id, secret_access_key, session_token]
      - name: assume_role
        title: Assume Role
        vars: [role_arn]
      - name: assume_role_external_id
        title: Assume Role with External ID
        vars: [role_arn, external_id]
      - name: shared_credentials
        title: Shared Credentials
        vars: [shared_credential_file, credential_profile_name]
        hide_in_deployment_modes: [agentless]

Fleet UI example

Screenshot 2026-01-23 at 9 37 52 AM
Screen.Recording.2026-01-23.at.10.06.07.AM.mov

Key changes:

  • Added var_group_selections field to NewPackagePolicy and NewPackagePolicyInputStream types
  • Package-level selections are stored in packagePolicy.var_group_selections
  • Stream-level selections are stored in packagePolicyInputStream.var_group_selections
  • Created useVarGroupSelections hook for consistent state management across both levels
  • Implemented computeDefaultVarGroupSelections to initialize defaults based on deployment mode
  • Added VarGroupSelector component for UI rendering of var_group options
  • Server-side parsing already supports var_groups from package manifests

Validation enhancements (form validation):

  • Added required?: boolean field to RegistryVarGroup type
  • Added isVarRequiredByVarGroup helper function
  • Updated validatePackagePolicy to skip validation for hidden vars and treat vars in required var_groups as required
  • Updated hasInvalidButRequiredVar to support var_groups context
  • Updated PackagePolicyInputVarField to show required indicator for var_group required fields

Related Issues

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

Identify risks

Low - Medium

@seanrathier seanrathier added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:Cloud Security Cloud Security team related ci:cloud-deploy Create or update a Cloud deployment labels Jan 19, 2026
@seanrathier seanrathier self-assigned this Jan 19, 2026
@seanrathier seanrathier marked this pull request as ready for review January 20, 2026 00:53
@seanrathier seanrathier requested review from a team as code owners January 20, 2026 00:53
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/contextual-security-apps (Team:Cloud Security)

@seanrathier seanrathier requested review from a team and Omolola-Akinleye January 20, 2026 00:53
@botelastic botelastic Bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Jan 20, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/fleet (Team:Fleet)

@seanrathier seanrathier requested a review from Copilot January 20, 2026 01:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements persistence and validation for var_group_selections in Fleet package policies. Variable groups enable package authors to define mutually exclusive sets of variables, allowing users to select between different configuration options (e.g., API Key vs OAuth authentication). The implementation includes both package-level and stream-level selections, UI components for selection, and enhanced validation logic.

Changes:

  • Added var_group_selections field to package policy types and schemas at both package and stream levels
  • Implemented UI components (VarGroupSelector) and state management hooks (useVarGroupSelections) for selecting and persisting var group options
  • Enhanced validation to skip hidden variables and treat variables in required var groups as required
  • Added comprehensive test coverage for var group functionality including selection, validation, and visibility logic

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
server/types/so_attributes.ts Added var_group_selections field to package policy saved object attributes
server/types/rest_spec/epm.ts Added schema validation for var_groups in package manifest
server/services/package_policy.ts Persisted var_group_selections during package policy updates
server/services/epm/archive/parse.ts Added var_groups as optional package property for parsing
server/routes/package_policy/handlers.ts Updated handlers to preserve var_group_selections during updates
public/types/index.ts Exported var group types for public use
public/applications/.../edit_package_policy_page/index.tsx Computed default var group selections for edit mode
public/applications/.../single_page_layout/index.tsx Integrated var group selections into create flow
public/applications/.../has_invalid_but_required_var.ts Enhanced validation to support var group required logic
public/applications/.../step_define_package_policy.tsx Added var group selector UI and filtered variables by selection
public/applications/.../step_configure_package.tsx Added input compatibility filtering based on var group selections
public/applications/.../var_group_selector.tsx New component implementing var group selection UI and logic
public/applications/.../package_policy_input_var_field.tsx Added support for var group required indicator
public/applications/.../package_policy_input_stream.tsx Implemented stream-level var group selections and filtering
public/applications/.../package_policy_input_panel.tsx Passed var group selections to input streams
public/applications/.../hooks.tsx Added useVarGroupSelections hook for state management
common/types/models/package_spec.ts Defined var group type interfaces
common/types/models/package_policy_schema.ts Added schema for var group selections
common/types/models/package_policy.ts Added var group selections to package policy types
common/types/models/epm.ts Added var group support to registry types
common/services/validate_package_policy.ts Enhanced validation to handle var group visibility and requirements
common/services/simplified_package_policy_helper.ts Preserved var group selections in simplified format
oas_docs/bundle.serverless.json Updated OpenAPI schema with var group selections
oas_docs/bundle.json Updated OpenAPI schema with var group selections

@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod Bot requested a review from a team as a code owner January 20, 2026 01:09
Copy link
Copy Markdown
Member

@florent-leborgne florent-leborgne left a comment

Choose a reason for hiding this comment

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

LGTM for docs

Comment thread oas_docs/bundle.json Outdated
Copy link
Copy Markdown
Contributor

@juliaElastic juliaElastic Jan 23, 2026

Choose a reason for hiding this comment

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

@juliaElastic
Copy link
Copy Markdown
Contributor

Code changes look good, could you share some screenshots or steps to verify how var groups look like on the UI?

Copy link
Copy Markdown
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

LGTM

@seanrathier seanrathier enabled auto-merge (squash) January 27, 2026 17:51
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Jan 27, 2026

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 1389 1391 +2

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
fleet 1590 1611 +21

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 2.2MB 2.2MB +4.8KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 181.8KB 182.6KB +747.0B
Unknown metric groups

API count

id before after diff
fleet 1725 1746 +21

History

cc @seanrathier

@seanrathier seanrathier merged commit 13399b1 into elastic:main Jan 28, 2026
16 checks passed
@seanrathier seanrathier deleted the var_groups branch March 6, 2026 21:54
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 ci:cloud-deploy Create or update a Cloud deployment release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related Team:Fleet Team label for Observability Data Collection Fleet team v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants