Skip to content

Commit

Permalink
KAFKA-15377: Don't expose externalized secret values in tasks-config …
Browse files Browse the repository at this point in the history
…API endpoint (apache#14244)

Reviewers: Greg Harris <greg.harris@aiven.io>
  • Loading branch information
yashmayya authored and mjsax committed Nov 22, 2023
1 parent 6776bf1 commit 8c54d6d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Expand Up @@ -311,7 +311,7 @@ protected Map<ConnectorTaskId, Map<String, String>> buildTasksConfig(String conn

Map<ConnectorTaskId, Map<String, String>> configs = new HashMap<>();
for (ConnectorTaskId cti : configState.tasks(connector)) {
configs.put(cti, configState.taskConfig(cti));
configs.put(cti, configState.rawTaskConfig(cti));
}

return configs;
Expand Down
Expand Up @@ -579,7 +579,7 @@ public int hashCode() {
public void tasksConfig(String connName, Callback<Map<ConnectorTaskId, Map<String, String>>> callback) {
Map<ConnectorTaskId, Map<String, String>> tasksConfig = buildTasksConfig(connName);
if (tasksConfig.isEmpty()) {
callback.onCompletion(new NotFoundException("Connector " + connName + " not found"), tasksConfig);
callback.onCompletion(new NotFoundException("Connector " + connName + " not found"), null);
return;
}
callback.onCompletion(null, tasksConfig);
Expand Down
Expand Up @@ -2091,6 +2091,8 @@ public void testAccessors() throws Exception {
herder.connectorConfig(CONN1, connectorConfigCb);
FutureCallback<List<TaskInfo>> taskConfigsCb = new FutureCallback<>();
herder.taskConfigs(CONN1, taskConfigsCb);
FutureCallback<Map<ConnectorTaskId, Map<String, String>>> tasksConfigCb = new FutureCallback<>();
herder.tasksConfig(CONN1, tasksConfigCb);

herder.tick();
assertTrue(listConnectorsCb.isDone());
Expand All @@ -2107,6 +2109,11 @@ public void testAccessors() throws Exception {
new TaskInfo(TASK1, TASK_CONFIG),
new TaskInfo(TASK2, TASK_CONFIG)),
taskConfigsCb.get());
Map<ConnectorTaskId, Map<String, String>> tasksConfig = new HashMap<>();
tasksConfig.put(TASK0, TASK_CONFIG);
tasksConfig.put(TASK1, TASK_CONFIG);
tasksConfig.put(TASK2, TASK_CONFIG);
assertEquals(tasksConfig, tasksConfigCb.get());

// Config transformation should not occur when requesting connector or task info
verify(configTransformer, never()).transform(eq(CONN1), any());
Expand Down
Expand Up @@ -765,6 +765,7 @@ public void testAccessors() throws Exception {
Callback<ConnectorInfo> connectorInfoCb = PowerMock.createMock(Callback.class);
Callback<Map<String, String>> connectorConfigCb = PowerMock.createMock(Callback.class);
Callback<List<TaskInfo>> taskConfigsCb = PowerMock.createMock(Callback.class);
Callback<Map<ConnectorTaskId, Map<String, String>>> tasksConfigCb = PowerMock.createMock(Callback.class);

// Check accessors with empty worker
listConnectorsCb.onCompletion(null, Collections.EMPTY_SET);
Expand All @@ -775,6 +776,8 @@ public void testAccessors() throws Exception {
EasyMock.expectLastCall();
taskConfigsCb.onCompletion(EasyMock.<NotFoundException>anyObject(), EasyMock.isNull());
EasyMock.expectLastCall();
tasksConfigCb.onCompletion(EasyMock.<NotFoundException>anyObject(), EasyMock.isNull());
EasyMock.expectLastCall();

// Create connector
connector = PowerMock.createMock(BogusSourceConnector.class);
Expand All @@ -795,6 +798,10 @@ public void testAccessors() throws Exception {
taskConfigsCb.onCompletion(null, Arrays.asList(taskInfo));
EasyMock.expectLastCall();

Map<ConnectorTaskId, Map<String, String>> tasksConfig = Collections.singletonMap(new ConnectorTaskId(CONNECTOR_NAME, 0),
taskConfig(SourceSink.SOURCE));
tasksConfigCb.onCompletion(null, tasksConfig);
EasyMock.expectLastCall();

PowerMock.replayAll();

Expand All @@ -803,6 +810,7 @@ public void testAccessors() throws Exception {
herder.connectorInfo(CONNECTOR_NAME, connectorInfoCb);
herder.connectorConfig(CONNECTOR_NAME, connectorConfigCb);
herder.taskConfigs(CONNECTOR_NAME, taskConfigsCb);
herder.tasksConfig(CONNECTOR_NAME, tasksConfigCb);

herder.putConnectorConfig(CONNECTOR_NAME, connConfig, false, createCallback);
Herder.Created<ConnectorInfo> connectorInfo = createCallback.get(1000L, TimeUnit.SECONDS);
Expand All @@ -818,6 +826,7 @@ public void testAccessors() throws Exception {
herder.connectorInfo(CONNECTOR_NAME, connectorInfoCb);
herder.connectorConfig(CONNECTOR_NAME, connectorConfigCb);
herder.taskConfigs(CONNECTOR_NAME, taskConfigsCb);
herder.tasksConfig(CONNECTOR_NAME, tasksConfigCb);

PowerMock.verifyAll();
}
Expand Down

0 comments on commit 8c54d6d

Please sign in to comment.