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 (#14244)

Reviewers: Greg Harris <greg.harris@aiven.io>
  • Loading branch information
yashmayya authored and gharris1727 committed Aug 24, 2023
1 parent 7e3f1c1 commit 3b9c3da
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 @@ -551,7 +551,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 @@ -2839,6 +2839,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 @@ -2855,6 +2857,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());

PowerMock.verifyAll();
}
Expand Down
Expand Up @@ -762,6 +762,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 @@ -772,6 +773,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 @@ -792,6 +795,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 @@ -800,6 +807,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 @@ -815,6 +823,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 3b9c3da

Please sign in to comment.