Tweak lang-mustache factory (#92211)#4
Open
MitchLewis930 wants to merge 1 commit intopr_014_beforefrom
Open
Conversation
This commits makes a few very minor tweaks to our Mustache scripting capabilities.
1. Switches from `DefaultMustacheFactory` to `SafeMustacheFactory`
In the event that the security manager were disabled (or removed, as is threatened in subsequent JDK releases), Mustache's "partial template" (`{{>partial}}`) support is a security risk because it would allow reading from an arbitrary URL or file on disk. Switching to the "Safe" version and passing in an empty set into the parent constructor disallows using partial Mustache templates. This also switches from `Function<String, String>` to the `TemplateFunction` value for the built-in functions.
3. Minor internal optimization
This removes useless grouping for one of the built-in mustache functions, and removes the call to `CollectionUtils.ensureNoSelfReferences` used in `CustomReflectionObjectHandler`. This check during stringification should not be necessary because Mustache templates without "partial" support cannot be self-referencing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR_014
Note
Medium Risk
Touches mustache rendering internals and changes where self-referential payloads are rejected, which can alter error surfaces and behavior in watcher transforms.
Overview
Switches
CustomMustacheFactoryfromDefaultMustacheFactorytoSafeMustacheFactory, updates custom function handling to useTemplateFunction, and makes small parsing/encoding tweaks (join delimiter regex andURLEncoderoverload).Removes the mustache-side self-reference guard (
CustomReflectionObjectHandler.stringify) and instead validates watcher action payloads on construction (Payload.Simple), updating/rest-skipping watcher QA tests to reflect the new failure location and error shape.Written by Cursor Bugbot for commit 34ddaa7. This will update automatically on new commits. Configure here.