Skip to content

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

Merge remote-tracking branch 'origin/main' into PAM-455

Andrey5083a2a12832
diff --cc backend/src/lib/aws/s3.ts
index 8abdcf9fd8,f337d85875..4cc3f62033
--- a/backend/src/lib/aws/s3.ts
+++ b/backend/src/lib/aws/s3.ts
@@@ -1,6 -1,10 +1,12 @@@
+import type { Agent } from "node:https";
+
- import { GetObjectCommand, HeadBucketCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
+ import {
+ GetObjectCommand,
+ HeadBucketCommand,
+ ListObjectsV2Command,
+ PutObjectCommand,
+ S3Client
+ } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
import { crypto } from "@app/lib/crypto/cryptography";
@@@ -13,33 -23,6 +25,33 @@@ export type TS3AccessCheck = { ok: tru
export type TS3Bucket = ReturnType<typeof createS3Bucket>;
+export const createS3Client = ({
+ region,
+ credentials,
+ endpoint,
+ httpsAgent
+}: {
+ region: string;
+ credentials: TS3Credentials;
+ endpoint?: string;
+ httpsAgent?: Agent;
+}) =>
+ new S3Client({
+ region,
+ sha256: CustomAWSHasher,
+ credentials,
- ...(httpsAgent && { requestHandler: { httpsAgent } }),
++ requestHandler: { ...AWS_REQUEST_TIMEOUTS, ...(httpsAgent && { httpsAgent }) },
+ ...(endpoint
+ ? {
+ endpoint,
+ forcePathStyle: true,
+ // not every S3-compatible provider accepts the SDK's default flexible checksums
+ requestChecksumCalculation: "WHEN_REQUIRED",
+ responseChecksumValidation: "WHEN_REQUIRED"
+ }
+ : { useFipsEndpoint: crypto.isFipsModeEnabled() })
+ });
+
export const createS3Bucket = ({
region,
bucket,
@@@ -49,7 -32,15 +61,9 @@@
bucket: string;
credentials: TS3Credentials;
}) => {
- const client = new S3Client({
- region,
- useFipsEndpoint: crypto.isFipsModeEnabled(),
- sha256: CustomAWSHasher,
- credentials,
- requestHandler: AWS_REQUEST_TIMEOUTS
- });
+ const client = createS3Client({ region, credentials });
+ // The request timeout stops once the headers arrive, so a reply that stalls after them needs an overall limit.
+ const sendOptions = () => ({ abortSignal: AbortSignal.timeout(S3_CALL_TIMEOUT_MS) });
// These headers are signed so S3 enforces them: the body must be the declared size and hash to the declared
// digest, and If-None-Match stops a re-minted link from overwriting an object already stored.