Skip to content

[9.2](backport #5997) Replace secrets in fleet section of policies#6492

Merged
michel-laterman merged 2 commits into9.2from
mergify/bp/9.2/pr-5997
Mar 5, 2026
Merged

[9.2](backport #5997) Replace secrets in fleet section of policies#6492
michel-laterman merged 2 commits into9.2from
mergify/bp/9.2/pr-5997

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Mar 4, 2026

What is the problem this PR solves?

The fleet section of a policy is now allowed to contain secrets. This PR ensures that Fleet Server correctly replaces such secrets with their values before the policy is sent to the Agent.

How does this PR solve the problem?

This PR builds upon the work done in #5852, evaluating the fleet section of the policy received from Elasticsearch and replacing any secrets within it.

Design Checklist

  • I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.
  • I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.
  • I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool

Related issues

Closes #4470


This is an automatic backport of pull request #5997 done by Mergify.

* Turn fleet property into map[string]interface{}

* Add smap.Get and smap.Set methods

* Use smap.Get and smap.Set methods in inline replacement

* Replace secrets in `fleet` section

* Update unit test

* Adding CHANGELOG fragment

* Update integration test

* Error handling

* Run mage check:headers

* Fix potential integer overflow

* Removing vestigial checks

* Update assertion

* Fix secret ID

* Use strconv.ParseInt

(cherry picked from commit 8ea3537)

# Conflicts:
#	internal/pkg/policy/parsed_policy.go
#	internal/pkg/policy/parsed_policy_test.go
#	internal/pkg/secret/secret.go
#	internal/pkg/server/fleet_secrets_integration_test.go
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Mar 4, 2026
@mergify mergify bot requested a review from a team as a code owner March 4, 2026 00:02
@mergify mergify bot requested a review from ycombinator March 4, 2026 00:02
@mergify mergify bot added the backport label Mar 4, 2026
@mergify mergify bot requested a review from swiatekm March 4, 2026 00:02
@mergify mergify bot added the conflicts There is a conflict in the backported pull request label Mar 4, 2026
@mergify
Copy link
Contributor Author

mergify bot commented Mar 4, 2026

Cherry-pick of 8ea3537 has failed:

On branch mergify/bp/9.2/pr-5997
Your branch is up to date with 'origin/9.2'.

You are currently cherry-picking commit 8ea3537.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   changelog/fragments/1764638389-secrets-fleet-ssl.yaml
	modified:   internal/pkg/api/handleCheckin.go
	modified:   internal/pkg/model/schema.go
	modified:   internal/pkg/policy/testdata/policy_with_secrets_mixed.json
	modified:   internal/pkg/secret/secret_test.go
	modified:   internal/pkg/smap/smap.go
	new file:   internal/pkg/smap/smap_test.go
	modified:   model/schema.json

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   internal/pkg/policy/parsed_policy.go
	both modified:   internal/pkg/policy/parsed_policy_test.go
	both modified:   internal/pkg/secret/secret.go
	both modified:   internal/pkg/server/fleet_secrets_integration_test.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@github-actions github-actions bot added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Mar 4, 2026
@mergify
Copy link
Contributor Author

mergify bot commented Mar 4, 2026

This pull request is now in conflicts. Could you fix it @mergify[bot]? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b mergify/bp/9.2/pr-5997 upstream/mergify/bp/9.2/pr-5997
git merge upstream/9.2
git push upstream mergify/bp/9.2/pr-5997

@michel-laterman
Copy link
Contributor

@copilot please rebase the commit

Copy link
Contributor

Copilot AI commented Mar 4, 2026

@michel-laterman I've opened a new pull request, #6511, to work on those changes. Once the pull request is ready, I'll request review from you.

@michel-laterman
Copy link
Contributor

@Mergifyio rebase

@mergify
Copy link
Contributor Author

mergify bot commented Mar 4, 2026

rebase

☑️ Nothing to do, the required conditions are not met

Details
  • -conflict [📌 rebase requirement]
  • -closed [📌 rebase requirement]
  • queue-position = -1 [📌 rebase requirement]
  • any of:
    • #commits-behind > 0 [📌 rebase requirement]
    • -linear-history [📌 rebase requirement]

@michel-laterman michel-laterman merged commit ecfb531 into 9.2 Mar 5, 2026
10 checks passed
@michel-laterman michel-laterman deleted the mergify/bp/9.2/pr-5997 branch March 5, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport conflicts There is a conflict in the backported pull request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants