Skip to content

Commit 96ff310

Browse files
authored
feat(aurora-portal): bucket policy bff (#910)
* feat: bucket policy BFF * fix(aurora-portal): vulnerabilities issues * fix(aurora-portal): tests and validation issues * fix(aurora-portal): rate limiter map grows unbounded
1 parent 6bf0533 commit 96ff310

7 files changed

Lines changed: 841 additions & 4 deletions

File tree

packages/aurora/src/server/Storage/helpers/s3ErrorMapper.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ describe("mapS3ErrorToTRPCError", () => {
310310
// Expected to throw
311311
}
312312

313-
expect(consoleWarnSpy).toHaveBeenCalledWith("[s3] Unmapped S3 error code: UnmappedErrorCode")
313+
expect(consoleWarnSpy).toHaveBeenCalled()
314+
const warnCall = consoleWarnSpy.mock.calls[0][0] as string
315+
expect(warnCall).toContain("Unmapped S3 error code")
314316
})
315317

316318
it("does not log when error code is mapped", () => {

packages/aurora/src/server/Storage/helpers/s3ErrorMapper.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { TRPCError } from "@trpc/server"
2+
import { logger } from "@cobaltcore-dev/signal-openstack"
23

34
interface S3ErrorShape {
45
name?: string
@@ -11,6 +12,7 @@ const S3_ERROR_MAP: Record<string, TRPCError["code"]> = {
1112
NoSuchKey: "NOT_FOUND",
1213
NoSuchUpload: "NOT_FOUND",
1314
NoSuchVersion: "NOT_FOUND",
15+
NoSuchBucketPolicy: "NOT_FOUND",
1416
BucketAlreadyExists: "CONFLICT",
1517
BucketAlreadyOwnedByYou: "CONFLICT",
1618
BucketNotEmpty: "PRECONDITION_FAILED",
@@ -24,6 +26,7 @@ const S3_ERROR_MAP: Record<string, TRPCError["code"]> = {
2426
RequestTimeTooSkewed: "UNAUTHORIZED",
2527
InvalidBucketName: "BAD_REQUEST",
2628
KeyTooLongError: "BAD_REQUEST",
29+
MalformedPolicy: "BAD_REQUEST",
2730
EntityTooLarge: "PAYLOAD_TOO_LARGE",
2831
EntityTooSmall: "BAD_REQUEST",
2932
}
@@ -49,7 +52,7 @@ export function mapS3ErrorToTRPCError(
4952

5053
// Log unmapped errors for future improvements
5154
if (!S3_ERROR_MAP[errorCode] && errorCode) {
52-
console.warn(`[s3] Unmapped S3 error code: ${errorCode}`)
55+
logger.warn("Unmapped S3 error code", { errorCode, operation: context.operation })
5356
}
5457

5558
// Build contextual error message

0 commit comments

Comments
 (0)