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

refactor(api): Replace for loop with array indexing while decrypting secrets during bulk fetch #265 #266

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Changes from 1 commit
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
15 changes: 5 additions & 10 deletions apps/api/src/secret/service/secret.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import {
SecretWithProject,
SecretWithProjectAndVersion,
SecretWithVersionAndEnvironment

Check warning on line 31 in apps/api/src/secret/service/secret.service.ts

View workflow job for this annotation

GitHub Actions / Validate API

'SecretWithVersionAndEnvironment' is defined but never used
} from '../secret.types'
import createEvent from '../../common/create-event'
import getDefaultEnvironmentOfProject from '../../common/get-default-project-environment'
Expand Down Expand Up @@ -505,16 +505,11 @@

for (const secret of secrets) {
// Decrypt the secret value
for (let i = 0; i < secret.versions.length; i++) {
const version = secret.versions[i]
// Optionally decrypt secret value if decryptValue is true
if (decryptValue) {
const decryptedValue = await decrypt(
project.privateKey,
version.value
)
version.value = decryptedValue
}
const version = secret.versions[0]
anudeeps352 marked this conversation as resolved.
Show resolved Hide resolved
// Optionally decrypt secret value if decryptValue is true
if (decryptValue) {
const decryptedValue = await decrypt(project.privateKey, version.value)
version.value = decryptedValue
}

const { id, name } = secret.environment
Expand Down
Loading