mirror of
https://github.com/vran-dev/databasir.git
synced 2025-09-18 01:37:12 +08:00
Fix spel expression injection vulnerability (#270)
This commit is contained in:
@@ -3,7 +3,7 @@ package com.databasir.core.domain.mock.script;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.expression.spel.support.SimpleEvaluationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@@ -15,7 +15,7 @@ public class SpelScriptEvaluator implements MockScriptEvaluator {
|
||||
@Override
|
||||
public String evaluate(String script, ScriptContext context) {
|
||||
Expression expression = spelExpressionParser.parseExpression(script);
|
||||
StandardEvaluationContext spelContext = new StandardEvaluationContext(context);
|
||||
SimpleEvaluationContext spelContext = SimpleEvaluationContext.forReadOnlyDataBinding().build();
|
||||
return expression.getValue(spelContext, String.class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user