Skip to content

fix: model simulator SSE-C downloads#118

Open
goanpeca wants to merge 14 commits into
mainfrom
fix/issue-14-simulator-sse
Open

fix: model simulator SSE-C downloads#118
goanpeca wants to merge 14 commits into
mainfrom
fix/issue-14-simulator-sse

Conversation

@goanpeca

@goanpeca goanpeca commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary:

  • Store simulator server-side encryption metadata separately from public file versions so SSE-B2/SSE-C modes echo without exposing customer keys.
  • Reject incomplete, empty, malformed, oversized, unsupported, and mismatched SSE-C customer-key inputs before accepting uploads, start-large-file requests, upload parts, copy destinations, and downloads.
  • Require matching SSE-C headers for downloads, large-file part uploads, copyFile/copyPart sources, and encrypted copy destinations, with complete wrong download keys returning access_denied.
  • Preserve or apply destination encryption metadata for copyFile/copyPart, and reject unsupported encryption modes or stray customer-key fields on non-SSE-C settings.
  • Compare SSE-C keys by decoded 32-byte key material instead of literal base64 text, and keep MD5 validation internal with native Node sync MD5 when available plus a pure-JS fallback.
  • Keep simulator download handling efficient by lazily decoding response bodies and returning JSON errors for every JSON download response.
  • Add and organize regression coverage for encryption validation, download/copy behavior, large-file parts, malformed inputs, MD5 browser/coverage behavior, public metadata echo, and raw-key non-exposure.

Linked issue:

Tests run:

  • pnpm lint
  • pnpm lint:spelling
  • pnpm run typecheck
  • pnpm test
  • pnpm run test:coverage
  • pnpm test:browser
  • VITEST_BROWSER_INSTANCE=chromium pnpm test:browser
  • pnpm exec vitest run src/util/md5.node.test.ts

Follow-up notes:

  • CI is passing on the latest pushed commit.

Copilot AI review requested due to automatic review settings July 3, 2026 13:54
@goanpeca goanpeca added this to the v0.3.0 milestone Jul 3, 2026
@goanpeca goanpeca added bug Something isn't working area: simulator Area: simulator priority: medium Medium severity labels Jul 3, 2026
@goanpeca goanpeca self-assigned this Jul 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the in-memory B2 simulator’s handling of server-side encryption metadata, specifically modeling SSE-B2/SSE-C behavior without persisting customer-provided keys and enforcing SSE-C requirements on download paths to catch SDK regressions.

Changes:

  • Persist simulator encryption metadata separately (hashed for SSE-C) and ensure public responses echo only mode/algorithm.
  • Enforce SSE-C customer headers on downloads by validating against stored digests.
  • Add regression tests covering SSE-C download failures/success, public SSE metadata echo, and non-persistence of raw customer keys.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/simulator/index.ts Stores SSE metadata in simulator state and enforces SSE-C headers on download.
src/simulator/fidelity.test.ts Adds regression coverage for SSE-C download enforcement and non-persistence of raw keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/simulator/index.ts Outdated
Comment thread src/simulator/index.ts
Copilot AI review requested due to automatic review settings July 3, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/simulator/index.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/simulator/index.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/simulator/index.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/simulator/index.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@goanpeca goanpeca marked this pull request as ready for review July 3, 2026 15:57
Copilot AI review requested due to automatic review settings July 8, 2026 16:04
@goanpeca goanpeca force-pushed the fix/issue-14-simulator-sse branch from f0cdec5 to f1dd2fe Compare July 8, 2026 16:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/simulator/index.ts
Copilot AI review requested due to automatic review settings July 8, 2026 16:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread src/simulator/index.ts
Comment thread src/simulator/index.ts
Copilot AI review requested due to automatic review settings July 8, 2026 16:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread src/simulator/index.ts
Copilot AI review requested due to automatic review settings July 8, 2026 16:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread src/simulator/index.ts
Copilot AI review requested due to automatic review settings July 8, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread src/util/md5.ts
Copilot AI review requested due to automatic review settings July 8, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 8, 2026 17:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread src/util/md5.node.test.ts
Comment on lines +6 to +21
const originalGetBuiltinModule = process.getBuiltinModule
const originalBuffer = globalThis.Buffer

function restoreGlobals() {
Object.defineProperty(process, 'getBuiltinModule', {
configurable: true,
enumerable: true,
value: originalGetBuiltinModule,
writable: true,
})
Object.defineProperty(globalThis, 'Buffer', {
configurable: true,
value: originalBuffer,
writable: true,
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: simulator Area: simulator bug Something isn't working priority: medium Medium severity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simulator: SSE-C / SSE-B2 not modeled on upload or download

2 participants