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
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ protected Class<?> getClassForName(String name) throws ClassNotFoundException {
final class TrustedTagInspector implements TagInspector {
@Override
public boolean isGlobalTagAllowed(Tag tag) {
return true;
// consult the same typeFilters allow-list as getClassForName, so the SnakeYAML 2.x TagInspector
// layer actually enforces the configured filters instead of allowing every global tag (CAMEL-24294)
return allowTypeFilter(tag.getClassName());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.camel.component.snakeyaml.model.RexPojo;
import org.apache.camel.component.snakeyaml.model.TestPojo;
import org.apache.camel.component.snakeyaml.model.UnsafePojo;
import org.yaml.snakeyaml.composer.ComposerException;
import org.yaml.snakeyaml.constructor.ConstructorException;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
Expand Down Expand Up @@ -57,10 +58,11 @@ static void testTypeConstructor(ProducerTemplate template) {
"!!org.apache.camel.component.snakeyaml.model.UnsafePojo {name: Camel}"),
"As SnakeYAML filters class is can unmarshall, UnsafePojo should not be allowed");

// Wrapped by SnakeYAML
assertTrue(ex.getCause() instanceof ConstructorException);
// Thrown by SnakeYAMLDataFormat
assertTrue(ex.getCause().getCause() instanceof IllegalArgumentException);
// Rejected by the SnakeYAML TagInspector allow-list during composing (CAMEL-24294), before
// getClassForName would run - so the failure is a ComposerException, not the previous
// ConstructorException -> IllegalArgumentException chain.
assertTrue(ex.getCause() instanceof ComposerException);
assertTrue(ex.getCause().getMessage().contains("UnsafePojo"));
}

static void testTypeConstructorFromDefinition(ProducerTemplate template) {
Expand Down Expand Up @@ -88,10 +90,9 @@ static void testTypeConstructorFromDefinition(ProducerTemplate template) {
"!!org.apache.camel.component.snakeyaml.model.UnsafePojo {name: Camel}"),
"As SnakeYAML filters class is can unmarshall, UnsafePojo should not be allowed");

// Wrapped by SnakeYAML
assertTrue(ex.getCause() instanceof ConstructorException);
// Thrown by SnakeYAMLDataFormat
assertTrue(ex.getCause().getCause() instanceof IllegalArgumentException);
// Rejected by the SnakeYAML TagInspector allow-list during composing (CAMEL-24294)
assertTrue(ex.getCause() instanceof ComposerException);
assertTrue(ex.getCause().getMessage().contains("UnsafePojo"));
}

static void testAllowAllConstructor(ProducerTemplate template) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,16 @@ data format and the iterator/splitter modes. The full, unmodified entry name rem
so routes that intentionally recreate the archive's directory structure keep working — read it
from `CamelTarFileEntryName` for tar and from `zipFileName` for zip instead of `CamelFileName`.

=== camel-snakeyaml - typeFilters are now also enforced by the SnakeYAML TagInspector

When `typeFilters` (or `unmarshalType`) is configured, the allow-list is now also enforced by the
SnakeYAML 2.x `TagInspector` layer, not only by the `getClassForName` constructor override. A YAML
document that references a disallowed global tag is therefore rejected earlier, during composing, and
surfaces as an `org.yaml.snakeyaml.composer.ComposerException` (`"Global tag is not allowed: ..."`)
instead of the previous `ConstructorException` caused by an `IllegalArgumentException`. The set of
accepted types is unchanged; only the exception raised for a rejected type differs. Routes that do not
configure `typeFilters` are unaffected.

=== camel-jfr

`camel-jfr` can now also emit JFR events during message routing, in addition to the
Expand All @@ -1507,4 +1517,4 @@ read once while the `CamelContext` initializes and cannot be changed afterwards.

`org.apache.camel.spi.StartupStepRecorder` gained the default methods
`isRuntimeEnabled()` and `setRuntimeEnabled(boolean)`. Both have no-op defaults, so
existing implementations continue to compile and behave as before.
existing implementations continue to compile and behave as before.