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

fix(dokploy): exclude password column from application queries #645

Open
wants to merge 10 commits into
base: canary
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const SaveDockerProvider = ({ applicationId }: Props) => {
if (data) {
form.reset({
dockerImage: data.dockerImage || "",
password: data.password || "",
password: "*".repeat(data.passwordLength || 0) || "",
username: data.username || "",
});
}
Expand Down
9 changes: 9 additions & 0 deletions apps/dokploy/server/api/routers/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export const projectRouter = createTRPCRouter({
applications.applicationId,
accesedServices,
),
columns: {
password: false,
},
},
mariadb: {
where: buildServiceFilter(mariadb.mariadbId, accesedServices),
Expand Down Expand Up @@ -143,6 +146,9 @@ export const projectRouter = createTRPCRouter({
),
with: {
applications: {
columns: {
password: false,
},
where: buildServiceFilter(
applications.applicationId,
accesedServices,
Expand Down Expand Up @@ -178,6 +184,9 @@ export const projectRouter = createTRPCRouter({
return await db.query.projects.findMany({
with: {
applications: {
columns: {
password: false,
},
with: {
domains: true,
},
Expand Down
7 changes: 6 additions & 1 deletion packages/server/src/services/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ export const findApplicationById = async (applicationId: string) => {
message: "Application not found",
});
}
return application;
const applicationWithoutPassword: Application & { passwordLength?: number } =
application;
applicationWithoutPassword.passwordLength = application.password?.length || 0; // Calculate length
applicationWithoutPassword.password = ""; // Remove password

return applicationWithoutPassword;
};

export const findApplicationByName = async (appName: string) => {
Expand Down
6 changes: 5 additions & 1 deletion packages/server/src/services/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export const findProjectById = async (projectId: string) => {
const project = await db.query.projects.findFirst({
where: eq(projects.projectId, projectId),
with: {
applications: true,
applications: {
columns: {
password: false,
},
},
mariadb: true,
mongo: true,
mysql: true,
Expand Down