Skip to content

slp_all: use triple-brace templating in templates - #11317

Merged
efd6 merged 1 commit into
elastic:mainfrom
efd6:7641-slp_all
Oct 8, 2024
Merged

slp_all: use triple-brace templating in templates#11317
efd6 merged 1 commit into
elastic:mainfrom
efd6:7641-slp_all

Conversation

@efd6

@efd6 efd6 commented Oct 3, 2024

Copy link
Copy Markdown
Contributor

Proposed commit message

slp_all: use triple-brace templating in templates

The mustache templating system used by ingest pipelines has two levels of
escaping available, not escaped (triple stache) and HTML escaped
(double stache) — see man mustache[1] under "tag types: variables". This can
lead to data corruption, particularly in cases where an operating system has
chosen to use a character requiring escaping in its path syntax.

[1]http://mustache.github.io/mustache.5.html

[git-generate]
for f in $(
	(
		for p in $(
			yq 'select(.owner.github == "elastic/sec-linux-platform")|.name' packages/**/manifest.yml \
			| grep -v -- '---'
		); do
			rg -l -g '*.yml' "[^{]\{\{[^{][ .a-zA-Z0-9_]*[^}]}}[^}]" packages/$p
		done
	)|grep "elasticsearch/ingest_pipeline"|sort|uniq
); do
	perl -pi -e 's/(?<!\{)(\{\{[^{][ .a-zA-Z0-9_]*[^}]}})(?!\})/{$1}/g' $f
done
for p in $(git diff --name-only HEAD~1|cut -d/ -f1,2|sort|uniq); do
	(
		cd $p
		elastic-package test pipeline -g
		elastic-package changelog add \
			--description "Use triple-brace Mustache templating when referencing variables in ingest pipelines." \
			--type bugfix \
			--next patch \
			--link https://github.com/elastic/integrations/pull/11317
	)>/dev/null 2>&1
done

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Screenshots

This is a second pass at replacing double brace template marks with triple brace
marks. It addresses more complex uses that the sed rewrite did not find by using
PCRE via perl.

[git-generate]
for f in $(
	(
		for p in $(
			yq 'select(.owner.github == "elastic/sec-linux-platform")|.name' packages/**/manifest.yml \
			| grep -v -- '---'
		); do
			rg -l -g '*.yml' "[^{]\{\{[^{][ .a-zA-Z0-9_]*[^}]}}[^}]" packages/$p
		done
	)|grep "elasticsearch/ingest_pipeline"|sort|uniq
); do
	perl -pi -e 's/(?<!\{)(\{\{[^{][ .a-zA-Z0-9_]*[^}]}})(?!\})/{$1}/g' $f
done
for p in $(git diff --name-only HEAD~1|cut -d/ -f1,2|sort|uniq); do
	(
		cd $p
		elastic-package test pipeline -g
		elastic-package changelog add \
			--description "Use triple-brace Mustache templating when referencing variables in ingest pipelines." \
			--type bugfix \
			--next patch \
			--link elastic#11317
	)>/dev/null 2>&1
done
@efd6 efd6 added Integration:All Applies to all integrations [Integration not found in source] bugfix Pull request that fixes a bug issue Team:Security-Linux Platform Linux Platform Security team [elastic/sec-linux-platform] labels Oct 3, 2024
@efd6 efd6 self-assigned this Oct 3, 2024
@andrewkroh andrewkroh added Integration:auditd Auditd Logs Integration:cloud_defend Defend for Containers (BETA) Integration:network_traffic Network Packet Capture Integration:sysmon_linux Sysmon for Linux Integration:system_audit System Audit and removed Integration:All Applies to all integrations [Integration not found in source] labels Oct 3, 2024
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@elastic-sonarqube

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
29.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

cc @efd6

@efd6
efd6 marked this pull request as ready for review October 3, 2024 03:52
@efd6
efd6 requested a review from a team as a code owner October 3, 2024 03:52
@elasticmachine

Copy link
Copy Markdown

Pinging @elastic/sec-linux-platform (Team:Security-Linux Platform)

@efd6
efd6 merged commit 5febbdd into elastic:main Oct 8, 2024
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package auditd - 3.20.2 containing this change is available at https://epr.elastic.co/search?package=auditd

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package cloud_defend - 1.2.6 containing this change is available at https://epr.elastic.co/search?package=cloud_defend

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package network_traffic - 1.31.2 containing this change is available at https://epr.elastic.co/search?package=network_traffic

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package sysmon_linux - 1.7.1 containing this change is available at https://epr.elastic.co/search?package=sysmon_linux

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package system_audit - 1.10.3 containing this change is available at https://epr.elastic.co/search?package=system_audit

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package network_traffic - 1.32.1 containing this change is available at https://epr.elastic.co/search?package=network_traffic

harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
The mustache templating system used by ingest pipelines has two levels of
escaping available, not escaped (triple stache) and HTML escaped
(double stache) — see man mustache[1] under "tag types: variables". This can
lead to data corruption, particularly in cases where an operating system has
chosen to use a character requiring escaping in its path syntax.

[1]http://mustache.github.io/mustache.5.html

[git-generate]
for f in $(
	(
		for p in $(
			yq 'select(.owner.github == "elastic/sec-linux-platform")|.name' packages/**/manifest.yml \
			| grep -v -- '---'
		); do
			rg -l -g '*.yml' "[^{]\{\{[^{][ .a-zA-Z0-9_]*[^}]}}[^}]" packages/$p
		done
	)|grep "elasticsearch/ingest_pipeline"|sort|uniq
); do
	perl -pi -e 's/(?<!\{)(\{\{[^{][ .a-zA-Z0-9_]*[^}]}})(?!\})/{$1}/g' $f
done
for p in $(git diff --name-only HEAD~1|cut -d/ -f1,2|sort|uniq); do
	(
		cd $p
		elastic-package test pipeline -g
		elastic-package changelog add \
			--description "Use triple-brace Mustache templating when referencing variables in ingest pipelines." \
			--type bugfix \
			--next patch \
			--link elastic#11317
	)>/dev/null 2>&1
done
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
The mustache templating system used by ingest pipelines has two levels of
escaping available, not escaped (triple stache) and HTML escaped
(double stache) — see man mustache[1] under "tag types: variables". This can
lead to data corruption, particularly in cases where an operating system has
chosen to use a character requiring escaping in its path syntax.

[1]http://mustache.github.io/mustache.5.html

[git-generate]
for f in $(
	(
		for p in $(
			yq 'select(.owner.github == "elastic/sec-linux-platform")|.name' packages/**/manifest.yml \
			| grep -v -- '---'
		); do
			rg -l -g '*.yml' "[^{]\{\{[^{][ .a-zA-Z0-9_]*[^}]}}[^}]" packages/$p
		done
	)|grep "elasticsearch/ingest_pipeline"|sort|uniq
); do
	perl -pi -e 's/(?<!\{)(\{\{[^{][ .a-zA-Z0-9_]*[^}]}})(?!\})/{$1}/g' $f
done
for p in $(git diff --name-only HEAD~1|cut -d/ -f1,2|sort|uniq); do
	(
		cd $p
		elastic-package test pipeline -g
		elastic-package changelog add \
			--description "Use triple-brace Mustache templating when referencing variables in ingest pipelines." \
			--type bugfix \
			--next patch \
			--link elastic#11317
	)>/dev/null 2>&1
done
@efd6
efd6 deleted the 7641-slp_all branch February 5, 2025 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes a bug issue Integration:auditd Auditd Logs Integration:cloud_defend Defend for Containers (BETA) Integration:network_traffic Network Packet Capture Integration:sysmon_linux Sysmon for Linux Integration:system_audit System Audit Team:Security-Linux Platform Linux Platform Security team [elastic/sec-linux-platform]

3 participants