Skip to content

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

cleanup

Danield65d66694b5d
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts
index ab67332094..f93e6ac799 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-types.ts
@@ -5,6 +5,7 @@ import { OrderByDirection } from "@app/lib/types";
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { SecretsOrderBy } from "@app/services/secret/secret-types";
+import { TConstraint } from "@app/services/secret-validation-rule/secret-validation-rule-types";
import { TGatewayPoolServiceFactory } from "../gateway-pool/gateway-pool-service";
import { TGatewayV2ServiceFactory } from "../gateway-v2/gateway-v2-service";
@@ -415,7 +416,7 @@ export type TRotationFactoryCheckActiveCredentials<T extends TSecretRotationV2Ge
// When present, factories that generate passwords must satisfy these
// constraints and ignore any user-provided passwordRequirements.
export type TRotationPasswordValidationContext = {
- constraints: import("@app/services/secret-validation-rule/secret-validation-rule-types").TConstraint[];
+ constraints: TConstraint[];
ruleNames: string[];
};
diff --git a/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts b/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts
index 8b5a5bb58a..3c489ffaf1 100644
--- a/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts
+++ b/backend/src/services/app-connection/hc-vault/hc-vault-connection-fns.ts
@@ -993,9 +993,7 @@ export const getHCVaultSecretsForPaths = async (
return [];
}
- let skipNamespaceHeader = false;
-
- const parameters = {
+ const fetchParams = {
namespace,
mounts,
instanceUrl,
@@ -1003,36 +1001,43 @@ export const getHCVaultSecretsForPaths = async (
connection,
gatewayService,
gatewayV2Service
- } as const;
+ };
- const [firstSecretPath, ...restSecretPaths] = secretPaths;
+ const fetchOne = async (vaultSecretPath: string, skipNamespaceHeader: boolean) => ({
+ vaultSecretPath,
+ secrets: await fetchVaultSecretAtPath({
+ ...fetchParams,
+ secretPath: vaultSecretPath,
+ skipNamespaceHeader
+ })
+ });
+
+ const [firstPath, ...restPaths] = secretPaths;
// Probe with the first path: Vault 1.0.0 returns 301 for root/"/" when the namespace header is sent.
// so we need to remove the namespace header and retry the request.
- await fetchVaultSecretAtPath({
- ...parameters,
- secretPath: firstSecretPath,
- skipNamespaceHeader
- }).catch((err) => {
- if (err instanceof NamespaceHeaderNotSupportedError) {
+ let skipNamespaceHeader = false;
+ let firstResult: { vaultSecretPath: string; secrets: Record<string, JsonValue> };
+ try {
+ firstResult = await fetchOne(firstPath, false);
+ } catch (error) {
+ if (error instanceof NamespaceHeaderNotSupportedError) {
skipNamespaceHeader = true;
+ firstResult = await fetchOne(firstPath, true);
} else {
- throw err;
+ throw error;
}
- });
+ }
- return Promise.all(
- secretPaths.map((vaultSecretPath) =>
- limiter(async () => {
- const secrets = await fetchVaultSecretAtPath({
- ...parameters,
- secretPath: vaultSecretPath,
- skipNamespaceHeader
- });
- return { vaultSecretPath, secrets };
- })
- )
+ if (restPaths.length === 0) {
+ return [firstResult];
+ }
+
+ const restResults = await Promise.all(
+ restPaths.map((vaultSecretPath) => limiter(() => fetchOne(vaultSecretPath, skipNamespaceHeader)))
);
+
+ return [firstResult, ...restResults];
};
export const getHCVaultAuthMounts = async (