Repository navigation
fix(expressions): only eval template-authored expressions - #7221
dwisiswant0 merged 2 commits into
Conversation
`expressions.Evaluate()` currently replaces placeholders first and then scans the substituted output for expressions which allows response-derived values, including extractor output, to be reinterpreted as DSL/helper syntax on a second pass, which then becomes more serious when env-backed variables are enabled. So making this by collecting expressions from the original template text before placeholder substitution and then evaluating only those original expressions after normal replacement to keep trusted template-authored helpers working, including placeholders nested inside helper arguments while treating substituted response data as literal text. Fixes #7210 Signed-off-by: Dwi Siswanto <[email protected]>
Neo - PR Security ReviewNo security issues found Highlights
Hardening Notes
Comment |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
WalkthroughMoved expression discovery in Evaluate to run before replacement so expressions are collected from pre-replacement data, preventing recursive evaluation of DSL syntax in resolved values. Added unit and integration tests validating literal reuse and isolation of resolved values. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip You can disable the changed files summary in the walkthrough.Disable the |
Signed-off-by: Dwi Siswanto <[email protected]>
Evaluate substituted every placeholder into the whole text first, then
wrote each expression result over the first matching marker it found.
When a substituted value repeated an expression's text, such as a
response body of {{to_upper(seed)}}, the result went into that value
and the template's own expression was left unevaluated.
Replace had the same flaw in another form: its § pass ran over the
output of its {{}} pass, so a substituted value of §name§ resolved to
the value of name, and a value could pull in any other variable.
Both now make one left-to-right pass over the template text. Evaluate
locates each expression before anything is substituted and writes the
result at that position, and Replace never scans a value it inserted.
Replace also stops converting every value up front, so rendering is
faster and allocates less.
Fixes: #8053
Fixes: #8055
Refs: #7221
Signed-off-by: Dwi Siswanto <[email protected]>
Proposed changes
expressions.Evaluate()currently replacesplaceholders first and then scans the substituted
output for expressions which allows
response-derived values, including extractor
output, to be reinterpreted as DSL/helper syntax
on a second pass, which then becomes more serious
when env-backed variables are enabled.
So making this by collecting expressions from the
original template text before placeholder
substitution and then evaluating only those
original expressions after normal replacement to
keep trusted template-authored helpers working,
including placeholders nested inside helper
arguments while treating substituted response data
as literal text.
Fixes #7210
Proof
Checklist
Summary by CodeRabbit
Bug Fixes
Tests