Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Address bot reviews
Andrey03eeb10664fa
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex f20e098855..82dc63605e 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -52,6 +52,7 @@ import {} from "../pam/pam-permission";import { resolveAccessControls } from "../pam/pam-policies";import {+ getInheritedRecordingS3Config,mintCorsProbeUrl,resolveOverridesS3Config,validateGatewayAttachment,@@ -743,7 +744,8 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>deps,settingsOverrides,recordingConnectionId ?? template.recordingConnectionId,- ctx+ ctx,+ recordingConnectionId ? getInheritedRecordingS3Config(settingsOverrides, template.settings) : undefined);const forced = applyForcedFields(accountType, {@@ -938,7 +940,13 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>settingsOverrides,(recordingConnectionId !== undefined ? recordingConnectionId : existing.recordingConnectionId) ??existing.templateRecordingConnectionId,- ctx+ ctx,+ recordingConnectionId+ ? getInheritedRecordingS3Config(+ settingsOverrides === undefined ? existing.settingsOverrides : settingsOverrides,+ template ? template.settings : existing.templateSettings+ )+ : undefined);const updateData: Record<string, unknown> = {};diff --git a/backend/src/ee/services/pam/pam-validators.ts b/backend/src/ee/services/pam/pam-validators.tsindex 3caa484d18..bc3abc44a3 100644--- a/backend/src/ee/services/pam/pam-validators.ts+++ b/backend/src/ee/services/pam/pam-validators.ts@@ -17,7 +17,11 @@ import { decryptAppConnection } from "@app/services/app-connection/app-connectioimport { TKmsServiceFactory } from "@app/services/kms/kms-service";import { TOrgDALFactory } from "@app/services/org/org-dal";-import { TPamAccountSettingsOverrides } from "../pam-account-template/pam-account-template-schemas";+import {+ PamAccountSettingsOverridesSchema,+ PamTemplateSettingsSchema,+ TPamAccountSettingsOverrides+} from "../pam-account-template/pam-account-template-schemas";import {PAM_RECORDING_CONNECTION_APPS,resolveS3RecordingAccess@@ -160,13 +164,20 @@ export const validateRecordingS3Config = async (return resolvedConfig;};+export const getInheritedRecordingS3Config = (settingsOverrides: unknown, templateSettings: unknown) =>+ PamAccountSettingsOverridesSchema.safeParse(settingsOverrides).data?.recordingS3Config ??+ PamTemplateSettingsSchema.safeParse(templateSettings).data?.recordingS3Config;+export const resolveOverridesS3Config = async (deps: Pick<TPamValidatorDeps, "permissionService" | "appConnectionDAL" | "kmsService">,settingsOverrides: TPamAccountSettingsOverrides | null | undefined,effectiveConnectionId: string | null | undefined,- ctx: TActorContext+ ctx: TActorContext,+ // an account that overrides only the connection still records to the bucket it inherits+ inheritedS3Config?: TPamAccountSettingsOverrides["recordingS3Config"]): Promise<TPamRecordingResolvedConfig | null> => {- if (!settingsOverrides?.recordingS3Config) return null;+ const s3Config = settingsOverrides?.recordingS3Config ?? inheritedS3Config;+ if (!s3Config) return null;if (!effectiveConnectionId) {throw new BadRequestError({@@ -174,7 +185,7 @@ export const resolveOverridesS3Config = async (});}- return validateRecordingS3Config(deps, effectiveConnectionId, settingsOverrides.recordingS3Config, ctx);+ return validateRecordingS3Config(deps, effectiveConnectionId, s3Config, ctx);};export const mintCorsProbeUrl = async (resolvedConfig: TPamRecordingResolvedConfig): Promise<string | null> => {diff --git a/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-fns.ts b/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-fns.tsindex 59a6170232..84afb7e209 100644--- a/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-fns.ts+++ b/backend/src/services/app-connection/s3-compatible/s3-compatible-connection-fns.ts@@ -9,15 +9,6 @@ import { S3CompatibleConnectionMethod, S3CompatibleProvider } from "./s3-compatiimport { parseS3CompatibleEndpoint, S3_COMPATIBLE_PROVIDER_MAP } from "./s3-compatible-connection-schemas";import { TS3CompatibleConnectionConfig } from "./s3-compatible-connection-types";-const REJECTED_KEY_ERROR_CODES = new Set([- "invalidaccesskeyid",- "invalidargument",- "signaturedoesnotmatch",- "authorizationheadermalformed",- "invalidsecurity",- "unauthorized"-]);-export const getS3CompatibleConnectionListItem = () => {return {name: "S3-Compatible Storage" as const,@@ -53,14 +44,8 @@ export const validateS3CompatibleConnectionCredentials = async (config: TS3Compatry {await createS3Client(clientConfig).send(new ListBucketsCommand({}));} catch (error) {- // keys scoped to a bucket can't list buckets, so only a rejected key fails here- if (- error instanceof S3ServiceException &&- !REJECTED_KEY_ERROR_CODES.has(error.name.toLowerCase()) &&- error.$metadata?.httpStatusCode !== 401- ) {- return config.credentials;- }+ // keys scoped to a bucket can't list buckets, but an AccessDenied still means the key authenticated+ if (error instanceof S3ServiceException && error.name === "AccessDenied") return config.credentials;logger.warn({ err: error },@@ -69,7 +54,7 @@ export const validateS3CompatibleConnectionCredentials = async (config: TS3Compaif (error instanceof S3ServiceException) {throw new BadRequestError({- message: `${providerName} rejected the access key: ${error.message || error.name}`+ message: `${providerName} couldn't verify the access key: ${error.message || error.name}`});}