Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: escape % in secrets

Andras Bacsaieebec3b92f59
diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts
index 2e1eefff08..6c3bac1175 100644
--- a/apps/api/src/lib/common.ts
+++ b/apps/api/src/lib/common.ts
@@ -28,9 +28,6 @@ const customConfig: Config = {
length: 3
};
-export const defaultProxyImage = `coolify-haproxy-alpine:latest`;
-export const defaultProxyImageTcp = `coolify-haproxy-tcp-alpine:latest`;
-export const defaultProxyImageHttp = `coolify-haproxy-http-alpine:latest`;
export const defaultTraefikImage = `traefik:v2.8`;
export function getAPIUrl() {
if (process.env.GITPOD_WORKSPACE_URL) {
diff --git a/apps/api/src/lib/services/common.ts b/apps/api/src/lib/services/common.ts
index 528e4ef12e..0d7cec42e0 100644
--- a/apps/api/src/lib/services/common.ts
+++ b/apps/api/src/lib/services/common.ts
@@ -1,5 +1,5 @@
-import { prisma } from '../common';
+import { decrypt, prisma } from '../common';
export async function removeService({ id }: { id: string }): Promise<void> {
await prisma.serviceSecret.deleteMany({ where: { serviceId: id } });
@@ -22,4 +22,18 @@ export async function removeService({ id }: { id: string }): Promise<void> {
await prisma.taiga.deleteMany({ where: { serviceId: id } });
await prisma.service.delete({ where: { id } });
+}
+export async function verifyAndDecryptServiceSecrets(id: string) {
+ const secrets = await prisma.serviceSecret.findMany({ where: { serviceId: id } })
+ let decryptedSecrets = secrets.map(secret => {
+ const { name, value } = secret
+ if (value) {
+ let rawValue = decrypt(value)
+ rawValue = rawValue.replaceAll(/\$/gi, '$$$')
+ return { name, value: rawValue }
+ }
+ return { name, value }
+
+ })
+ return decryptedSecrets
}
\ No newline at end of file
diff --git a/apps/api/src/lib/services/handlers.ts b/apps/api/src/lib/services/handlers.ts
index 270cce2cf0..ec015ea4f7 100644
--- a/apps/api/src/lib/services/handlers.ts
+++ b/apps/api/src/lib/services/handlers.ts
@@ -7,6 +7,7 @@ import { parseAndFindServiceTemplates } from '../../routes/api/v1/services/handl
import { ServiceStartStop } from '../../routes/api/v1/services/types';
import { OnlyId } from '../../types';
+import { verifyAndDecryptServiceSecrets } from './common';
export async function stopService(request: FastifyRequest<ServiceStartStop>) {
try {
@@ -65,15 +66,17 @@ export async function startService(request: FastifyRequest<ServiceStartStop>, fa
}
}
}
-
- const secrets = await prisma.serviceSecret.findMany({ where: { serviceId: id } })
+ const secrets = await verifyAndDecryptServiceSecrets(id)
for (const secret of secrets) {
const { name, value } = secret
if (value) {
const foundEnv = !!template.services[s].environment?.find(env => env.startsWith(`${name}=`))
const foundNewEnv = !!newEnvironments?.find(env => env.startsWith(`${name}=`))
if (foundEnv && !foundNewEnv) {
- newEnvironments.push(`${name}=${decrypt(value)}`)
+ newEnvironments.push(`${name}=${value}`)
+ }
+ if (!foundEnv && !foundNewEnv && s === id) {
+ newEnvironments.push(`${name}=${value}`)
}
}
}