allthingssecurity commented on code in PR #27525:
URL: https://github.com/apache/camel/pull/27525#discussion_r4220263686
##########
components/camel-python3/src/main/java/org/apache/camel/language/python3/Python3Language.java:
##########
@@ -166,15 +171,29 @@ public <T> T evaluate(String script, Map<String, Object>
bindings, Class<T> resu
Object evaluateExpression(String script, Exchange exchange) {
try (Context cx = Python3Helper.newContext(engine(), hostAccess)) {
Value b = cx.getBindings("python");
- // Default: data only. Do not bind exchange/message/context — they
are undefined (NameError)
- // unless createWithHostAccess() opted into trusted host-object
bindings.
+ Message message = exchange.getMessage();
+ Map<String, Object> headers = message.getHeaders();
+ Map<String, Object> properties = exchange.getAllProperties();
+ Map<String, Object> variables = exchange.getVariables();
+ // Default: data only, with the data names
ExchangeHelper.populateVariableMap gives Groovy. The host objects
+ // are undefined (NameError) unless createWithHostAccess() opted
into trusted host-object bindings.
b.putMember("exchangeId", exchange.getExchangeId());
- b.putMember("headers", exchange.getMessage().getHeaders());
- b.putMember("properties", exchange.getAllProperties());
- b.putMember("body", exchange.getMessage().getBody());
+ b.putMember("body", message.getBody());
+ b.putMember("header", headers);
+ b.putMember("headers", headers);
+ b.putMember("exchangeProperty", properties);
+ b.putMember("exchangeProperties", properties);
+ b.putMember("variable", variables);
+ b.putMember("variables", variables);
+ // deprecated name of exchangeProperties
+ b.putMember("properties", properties);
Review Comment:
Done in 4b9d71410d27: camel-python3 no longer binds `properties` or
`context` in either mode, and they are gone from the Javadoc, the deprecated
rows of python3-language.adoc (and its catalog copy), and the upgrade-guide
note, which now says python3 binds only the Groovy names.
`Python3BindingNamesTest` now checks that both raise `NameError` in default and
trusted mode, and the full camel-python3 suite passes (55 tests); the js and
python aliases are unchanged.
_Claude Code on behalf of allthingssecurity_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]