Skip to content

Commit

Permalink
redact by default when decrypting credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
despairblue committed Dec 27, 2024
1 parent b6ede91 commit 9f3a0d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 1 addition & 4 deletions packages/cli/src/credentials/credentials.service.ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ export class EnterpriseCredentialsService {
if (credential) {
// Decrypt the data if we found the credential with the `credential:update`
// scope.
decryptedData = this.credentialsService.redact(
this.credentialsService.decrypt(credential),
credential,
);
decryptedData = this.credentialsService.decrypt(credential);
} else {
// Otherwise try to find them with only the `credential:read` scope. In
// that case we return them without the decrypted data.
Expand Down
15 changes: 12 additions & 3 deletions packages/cli/src/credentials/credentials.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,18 @@ export class CredentialsService {
return newCredentialData;
}

decrypt(credential: CredentialsEntity) {
/**
* Decrypts the credentials data and redacts the content by default.
*
* If `includeRawData` is set to true it will not redact the data.
*/
decrypt(credential: CredentialsEntity, includeRawData = false) {
const coreCredential = createCredentialsFromCredentialsEntity(credential);
return coreCredential.getData();
const data = coreCredential.getData();
if (includeRawData) {
return data;
}
return this.redact(data, credential);
}

async update(credentialId: string, newCredentialData: ICredentialsDb) {
Expand Down Expand Up @@ -533,7 +542,7 @@ export class CredentialsService {
if (sharing) {
// Decrypt the data if we found the credential with the `credential:update`
// scope.
decryptedData = this.redact(this.decrypt(sharing.credentials), sharing.credentials);
decryptedData = this.decrypt(sharing.credentials);
} else {
// Otherwise try to find them with only the `credential:read` scope. In
// that case we return them without the decrypted data.
Expand Down

0 comments on commit 9f3a0d6

Please sign in to comment.