Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter camel properties to camelMain #1640

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -47,6 +47,8 @@ public class CamelKafkaConnectMain extends SimpleMain {
public static final String KAMELET_IDEMPOTENT_TEMPLATE_PARAMETERS_PREFIX = "camel.kamelet.ckcIdempotent.";
public static final String KAMELET_REMOVEHEADER_TEMPLATE_PARAMETERS_PREFIX = "camel.kamelet.ckcRemoveHeader.";

private static final String CAMEL_PROPERTY_PREFIX = "camel.";

private static final Logger LOG = LoggerFactory.getLogger(CamelKafkaConnectMain.class);

protected volatile ConsumerTemplate consumerTemplate;
Expand Down Expand Up @@ -227,7 +229,10 @@ public CamelKafkaConnectMain build(CamelContext camelContext) {
camelMain.configure().setDumpRoutes(Boolean.TRUE.toString());

Properties camelProperties = new Properties();
camelProperties.putAll(props);
Map<String, String> camelProps = props.entrySet().stream()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is that, theoretically (since it is not explicitly tested in tests, would be possible to add properties not starting with camel. as a way to configure some other useful stuff like factories for some camel components i.e. as in https://github.com/apache/camel-kafka-connector/blob/main/connectors/camel-kafka-connector-fix-dependencies.properties#L25 what about having a specific property say camel.kafkaconnector.filtered.props as a comma separated list of sensitive properties that one may want to explicitly filter?

.filter(entry -> entry.getKey().startsWith(CAMEL_PROPERTY_PREFIX))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
camelProperties.putAll(camelProps);

//error handler
camelMain.getCamelContext().getRegistry().bind("ckcErrorHandler", new DefaultErrorHandlerBuilder());
Expand Down
Loading