Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/user-manual/modules/ROOT/pages/body-types.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,10 @@ option, but it can be set elsewhere: not known.
the model the step uses (the language of its expression, its data format, its endpoint, or the data type transformer
of its `toType`), with the options of that model. `steps` is the body the steps of the EIP end with.
. *An option the side names whose value is not known before the route runs* (a `+{{placeholder}}+` or a `+${expression}+`),
or an option the step does not set but that can be set elsewhere, such as on the component: not known.
or an option the step does not set but that can be set elsewhere, such as on the component: not known. An insecure
opt-in (its `security` is `insecure:ssl`, `insecure:serialization` or `insecure:dev`, such as `allowJavaSerializedObject`)
is not such an option: it keeps its default when the step does not set it, as one turned on for the whole component is
reported by the xref:security-policy.adoc[security policy] at startup.
. *An option of `dependsOn` the step sets:* the `byOption` entry for that value says the body. When it has a
`javaTypeOption` the step sets, the body is an object of that class. Without such an entry: not known.
. *The `javaTypeOption` of the side, when the step sets it:* an object of the class it names, or null. It wins over the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ private Answer componentSide(String uri, JsonNode node, String side) {
}
Set<String> configurable = new HashSet<>();
for (BaseOptionModel option : model.getComponentOptions()) {
configurable.add(option.getName());
// an insecure option (allowJavaSerializedObject, transferExchange) is an opt-in: it keeps its default when
// the step does not set it, as one turned on for the whole component is reported by the security policy
if (!isInsecure(option)) {
configurable.add(option.getName());
}
}
Map<String, String> set = values(node != null && node.isObject() ? node.get("parameters") : null);
String text = node != null && node.isString() ? node.asString()
Expand Down Expand Up @@ -299,6 +303,13 @@ private static Optional<Map<String, String>> endpointProperties(CamelCatalog cat
}
}

/**
* Whether the option is one of the insecure opt-ins: security insecure:ssl, insecure:serialization or insecure:dev.
*/
private static boolean isInsecure(BaseOptionModel option) {
return option.getSecurity() != null && option.getSecurity().startsWith("insecure:");
}

/**
* What a side says for the options a step sets, by the rule the tools share (BodyTypeResolver of the tooling
* model); null when it is not known for the step.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1430,10 +1430,10 @@ public void testTheBodyOfCloudMessaging() {

@Test
public void testTheBodyOfMessaging() {
// the paho consumer gives bytes, so a field read needs an unmarshal; smtp sends what converts to text, so
// parsed data must be marshalled first, and so must the reply of a nats consumer that answers (InOut); the
// converter of spring-rabbitmq and the allowJavaSerializedObject option of pulsar may be set on the component,
// and an imap mail may be text, a stream or a multipart, which say nothing
// the paho consumer gives bytes, so a field read needs an unmarshal; pulsar and smtp send what converts to
// bytes or text, so parsed data must be marshalled first, and so must the reply of a nats consumer that answers
// (InOut); the converter of spring-rabbitmq may be set on the component, and an imap mail may be text, a stream
// or a multipart, which say nothing
String yaml = """
- route:
id: mqtt
Expand Down Expand Up @@ -1502,17 +1502,48 @@ public void testTheBodyOfMessaging() {
name: id
simple: ${body[id]}
""";
assertThat(lines(yaml)).hasSize(3).anySatisfy(m -> assertThat(m)
assertThat(lines(yaml)).hasSize(4).anySatisfy(m -> assertThat(m)
.contains("route mqtt: simple reads a field of the body (${body[id]})")
.contains("the paho consumer gives it as bytes"))
.noneSatisfy(m -> assertThat(m).contains("route publish:"))
.anySatisfy(m -> assertThat(m).contains("to: pulsar needs the body as text, bytes, a stream or a file"))
.anySatisfy(m -> assertThat(m)
.contains("route service:")
.contains("the body at the end of the route is the reply to the nats request"))
.anySatisfy(m -> assertThat(m)
.contains("route mail: to: smtp needs the body as text, bytes, a stream or a file"));
}

@Test
public void testTheBodyOfAnInsecureOptIn() {
// allowJavaSerializedObject of pulsar can be set on the component, but it is an insecure opt-in: it keeps its
// default (off) when the route does not set it, so parsed data must be marshalled first; a route that turns it
// on sends any body, which says nothing
String yaml = """
- route:
id: publish
from:
uri: timer:tick
steps:
- setBody:
constant: '{"id": 1}'
- unmarshal:
json: {}
- to: pulsar:persistent://public/default/orders
- route:
id: legacy
from:
uri: timer:tick
steps:
- setBody:
constant: '{"id": 1}'
- unmarshal:
json: {}
- to: pulsar:persistent://public/default/orders?allowJavaSerializedObject=true
""";
assertThat(lines(yaml)).hasSize(1).first().asString()
.contains("route publish: to: pulsar needs the body as text, bytes, a stream or a file");
}

@Test
public void testTheBodyOfMoreComponents() {
// ssh runs the body as a command and gives its output as a stream, and so does its consumer; spring-redis keeps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public record Resolved(List<String> carriers, String javaType, String format) {
* @param options the options the step sets, by name: the endpoint uri, the parameters or the options of a data
* format
* @param hidden the options that can be set elsewhere when the step does not set them, such as the options of the
* component
* component; not the insecure opt-ins (allowJavaSerializedObject), which keep their default unless
* the step sets them
* @return the body, or null when it is not known for the step
*/
public static Resolved resolve(BodyTypeModel side, Map<String, String> options, Set<String> hidden) {
Expand Down
Loading