Skip to content

Commit 734b419

Browse files
authored
Merge pull request #1144 from rocket-admin/backend_connection_agent_update_fix
connection: clear non-required properties for connection agents during update process
2 parents b180132 + ce8e220 commit 734b419

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

backend/src/entities/connection/use-cases/update-connection.use.case.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export class UpdateConnectionUseCase
9393
let connectionToken = null;
9494
if (isConnectionTypeAgent(updatedConnection.type)) {
9595
connectionToken = await this.renewOrCreateConnectionToken(updatedConnection.id);
96+
updatedConnection = this.clearNonRequiredConnectionAgentProperties(updatedConnection);
9697
}
9798
if (updatedConnection.masterEncryption && masterPwd) {
9899
updatedConnection = Encryptor.encryptConnectionCredentials(updatedConnection, masterPwd);
@@ -137,4 +138,24 @@ export class UpdateConnectionUseCase
137138
private async renewOrCreateConnectionToken(connectionId: string): Promise<string> {
138139
return await this._dbContext.agentRepository.renewOrCreateConnectionToken(connectionId);
139140
}
141+
142+
private clearNonRequiredConnectionAgentProperties(connection: ConnectionEntity): ConnectionEntity {
143+
delete connection.masterEncryption;
144+
delete connection.authSource;
145+
delete connection.schema;
146+
delete connection.sid;
147+
delete connection.ssh;
148+
delete connection.privateSSHKey;
149+
delete connection.sshHost;
150+
delete connection.sshPort;
151+
delete connection.sshUsername;
152+
delete connection.cert;
153+
delete connection.azure_encryption;
154+
delete connection.host;
155+
delete connection.port;
156+
delete connection.username;
157+
delete connection.password;
158+
delete connection.database;
159+
return connection;
160+
}
140161
}

0 commit comments

Comments
 (0)