Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

redact url for log

Thiago Araujo da Silva86e884a4f144
diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts
index 48b4e6c5bc..01c1552259 100644
--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts
+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts
@@ -355,7 +355,7 @@ describe("identityAuthTemplateServiceFactory oidc templates", () => {
expect(error).toBeInstanceOf(BadRequestError);
expect((error as BadRequestError).message).toContain(
- "Could not resolve the host of the OIDC discovery URL 'https://idp.invalid'"
+ "Could not resolve the host of the OIDC discovery URL 'https://idp.invalid/'"
);
expect(identityOidcAuthDAL.updateByTemplateId).not.toHaveBeenCalled();
});
@@ -604,6 +604,19 @@ describe("identityAuthTemplateServiceFactory ldap url validation", () => {
await expect(patchTemplate(service, { url: "not a url", bindPass: "pw" })).rejects.toBeInstanceOf(BadRequestError);
});
+ it("keeps credentials in an unresolvable LDAP URL out of the error message", async () => {
+ const { service } = createLdapService();
+
+ const error = await patchTemplate(service, {
+ url: "ldap://missing.invalid/?token=secret",
+ bindPass: "pw"
+ }).catch((err: unknown) => err);
+
+ expect(error).toBeInstanceOf(BadRequestError);
+ expect((error as BadRequestError).message).toContain("ldap://missing.invalid/?token=[REDACTED]");
+ expect((error as BadRequestError).message).not.toContain("secret");
+ });
+
it("blocks a private LDAP URL on create", async () => {
const { service, identityAuthTemplateDAL } = createLdapService();
diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
index ece4d2769e..7c2fb47b83 100644
--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
@@ -18,6 +18,7 @@ import { TPermissionServiceFactory } from "@app/ee/services/permission/permissio
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { chunkArray } from "@app/lib/fn";
import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";
+import { sanitizeUrlForLog } from "@app/lib/logger";
import { TOrgPermission } from "@app/lib/types";
import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
import { ActorType } from "@app/services/auth/auth-type";
@@ -120,7 +121,7 @@ export const identityAuthTemplateServiceFactory = ({
} catch (error) {
if (error instanceof BadRequestError) throw error;
throw new BadRequestError({
- message: `Could not resolve the host of the ${fieldLabel} '${url}'. Check the URL and that the host resolves from Infisical.`
+ message: `Could not resolve the host of the ${fieldLabel} '${sanitizeUrlForLog(url)}'. Check the URL and that the host resolves from Infisical.`
});
}
};