Skip to content

[Heartbeat] Add base64 encoding option to inline monitors#45100

Merged
emilioalvap merged 6 commits intomainfrom
heartbeat-base64-inline
Jul 9, 2025
Merged

[Heartbeat] Add base64 encoding option to inline monitors#45100
emilioalvap merged 6 commits intomainfrom
heartbeat-base64-inline

Conversation

@emilioalvap
Copy link
Contributor

@emilioalvap emilioalvap commented Jun 27, 2025

Proposed commit message

Add encoding: base64 option to inline monitors. This change allows inline monitors to support characters that would otherwise break yaml format.

Checklist

  • My code follows the style guidelines of this project
  • 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.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

  1. Build heartbeat locally
  2. Specify a base64-encoded inline script monitor.
  3. Execute heartbeat and check monitor is decoded at setup.

Related issues

@emilioalvap emilioalvap requested a review from a team as a code owner June 27, 2025 22:09
@emilioalvap emilioalvap added bug Team:obs-ds-hosted-services Label for the Observability Hosted Services team backport-active-all Automated backport with mergify to all the active branches labels Jun 27, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jun 27, 2025
@github-actions
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@emilioalvap emilioalvap enabled auto-merge (squash) July 9, 2025 12:38
@emilioalvap emilioalvap merged commit 2266395 into main Jul 9, 2025
30 checks passed
@emilioalvap emilioalvap deleted the heartbeat-base64-inline branch July 9, 2025 15:03
@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2025

@Mergifyio backport 8.17 8.18 8.19 9.0 9.1

@mergify
Copy link
Contributor

mergify bot commented Jul 9, 2025

mergify bot pushed a commit that referenced this pull request Jul 9, 2025
* Add base64 encoding option to inline monitors

* Fix linter

* Fix linter

* Remove unused Decode() method

* Fix linter

* Add changelog

(cherry picked from commit 2266395)
mergify bot pushed a commit that referenced this pull request Jul 9, 2025
* Add base64 encoding option to inline monitors

* Fix linter

* Fix linter

* Remove unused Decode() method

* Fix linter

* Add changelog

(cherry picked from commit 2266395)
mergify bot pushed a commit that referenced this pull request Jul 9, 2025
* Add base64 encoding option to inline monitors

* Fix linter

* Fix linter

* Remove unused Decode() method

* Fix linter

* Add changelog

(cherry picked from commit 2266395)
mergify bot pushed a commit that referenced this pull request Jul 9, 2025
* Add base64 encoding option to inline monitors

* Fix linter

* Fix linter

* Remove unused Decode() method

* Fix linter

* Add changelog

(cherry picked from commit 2266395)
mergify bot pushed a commit that referenced this pull request Jul 9, 2025
* Add base64 encoding option to inline monitors

* Fix linter

* Fix linter

* Remove unused Decode() method

* Fix linter

* Add changelog

(cherry picked from commit 2266395)
emilioalvap added a commit that referenced this pull request Jul 10, 2025
…45259)

* Add base64 encoding option to inline monitors

* Fix linter

* Fix linter

* Remove unused Decode() method

* Fix linter

* Add changelog

(cherry picked from commit 2266395)

Co-authored-by: Emilio Alvarez Piñeiro <95703246+emilioalvap@users.noreply.github.com>
emilioalvap added a commit that referenced this pull request Jul 10, 2025
…ne monitors (#45260)

* [Heartbeat] Add base64 encoding option to inline monitors (#45100)

* Add base64 encoding option to inline monitors

* Fix linter

* Fix linter

* Remove unused Decode() method

* Fix linter

* Add changelog

(cherry picked from commit 2266395)

* Update CHANGELOG.next.asciidoc

Co-authored-by: Marc Capell <marc.capell@gmail.com>

---------

Co-authored-by: Emilio Alvarez Piñeiro <95703246+emilioalvap@users.noreply.github.com>
Co-authored-by: Marc Capell <marc.capell@gmail.com>
emilioalvap added a commit that referenced this pull request Jul 10, 2025
…ine monitors (#45258)

* [Heartbeat] Add base64 encoding option to inline monitors (#45100)

* Add base64 encoding option to inline monitors

* Fix linter

* Fix linter

* Remove unused Decode() method

* Fix linter

* Add changelog

(cherry picked from commit 2266395)

* Update CHANGELOG.next.asciidoc

Co-authored-by: Marc Capell <marc.capell@gmail.com>

---------

Co-authored-by: Emilio Alvarez Piñeiro <95703246+emilioalvap@users.noreply.github.com>
Co-authored-by: Marc Capell <marc.capell@gmail.com>
emilioalvap added a commit that referenced this pull request Jul 10, 2025
…ine monitors (#45256)

* [Heartbeat] Add base64 encoding option to inline monitors (#45100)

* Add base64 encoding option to inline monitors

* Fix linter

* Fix linter

* Remove unused Decode() method

* Fix linter

* Add changelog

(cherry picked from commit 2266395)

* Update CHANGELOG.next.asciidoc

Co-authored-by: Marc Capell <marc.capell@gmail.com>

---------

Co-authored-by: Emilio Alvarez Piñeiro <95703246+emilioalvap@users.noreply.github.com>
Co-authored-by: Marc Capell <marc.capell@gmail.com>
emilioalvap added a commit that referenced this pull request Jul 10, 2025
…ine monitors (#45257)

* [Heartbeat] Add base64 encoding option to inline monitors (#45100)

* Add base64 encoding option to inline monitors

* Fix linter

* Fix linter

* Remove unused Decode() method

* Fix linter

* Add changelog

(cherry picked from commit 2266395)

* Update CHANGELOG.next.asciidoc

Co-authored-by: Marc Capell <marc.capell@gmail.com>

---------

Co-authored-by: Emilio Alvarez Piñeiro <95703246+emilioalvap@users.noreply.github.com>
Co-authored-by: Marc Capell <marc.capell@gmail.com>
fkanout added a commit to elastic/kibana that referenced this pull request Feb 20, 2026
…r monitors (#251499)

It fixes #251477
Related to elastic/integrations#17208

### Summary
Encodes inline browser monitor scripts as base64 before sending to
Fleet. This prevents Elastic Agent from interpreting JavaScript template
literals (`${variable}`) as policy variables and mangling the scripts.

Leverages the base64 encoding support added in Heartbeat via
elastic/beats#45100

### Changes

- Add `base64InlineScriptFormatter` for private location browser
monitors
- Set `source.inline.encoding: 'base64'` in package policies
- Remove unused `inlineSourceFormatter` reference from private
formatters
- Add `SOURCE_INLINE_ENCODING` config key

### Testing

Verified with scripts containing:
- JS template literals (`${variable}`)
- Object literals (`{ key: value }`)
- Multi-line scripts

### Scope

- Private locations only (Fleet/Agent path)
- Browser monitors with inline scripts only
- Public locations and project monitors unaffected

---------

Co-authored-by: Shahzad <shahzad31comp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches bug Team:obs-ds-hosted-services Label for the Observability Hosted Services team

3 participants