Skip to content

fix: enforce simulator object lock updates#122

Merged
goanpeca merged 7 commits into
mainfrom
fix/issue-16-simulator-object-lock
Jul 13, 2026
Merged

fix: enforce simulator object lock updates#122
goanpeca merged 7 commits into
mainfrom
fix/issue-16-simulator-object-lock

Conversation

@goanpeca

@goanpeca goanpeca commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Enforce simulator object-lock updates against bucket fileLockEnabled, compliance weakening, governance bypass requirements, strict-auth bypassGovernance capability, and legal-hold value validation.
  • Validate raw b2_update_file_retention payloads before assignment so invalid modes, omitted/non-finite/past timestamps, and malformed null-mode payloads cannot remove or invalidate retention.
  • Use wall-clock time for retention timestamp validation so Object Lock policy is not coupled to the simulator auth-token virtual clock.
  • Require governance bypass for governance-to-compliance transitions and for governance delete bypass in strict-auth mode before simulator state is mutated.
  • Add regression tests with stable B2 error status/code assertions for lock-disabled buckets, compliance/governance weakening, malformed retention payloads, governance conversion, strict-auth bypass capability, invalid legal holds, protected deletes, and expired governance retention deletes without bypass.
  • Keep the expired-governance delete regression compatible with both Vitest and Bun by stubbing Date.now() directly.
  • Align integration Vitest hookTimeout with the 120s test timeout so real B2 setup on Node 24 is not killed at 10s.

Linked issue

Closes #16

Tests run

  • pnpm exec vitest run src/object-lock.test.ts
  • pnpm exec vitest run src/object-lock.test.ts src/client.test.ts
  • bun test --timeout 180000 src/object-lock.test.ts
  • bun test --timeout 180000 src/
  • B2_APPLICATION_KEY_ID= B2_APPLICATION_KEY= pnpm test:integration
  • pnpm run typecheck
  • pnpm run lint
  • pnpm test

Follow-up notes

None.

Copilot AI review requested due to automatic review settings July 7, 2026 13:21
@goanpeca goanpeca added this to the v0.3.0 milestone Jul 7, 2026
@goanpeca goanpeca added bug Something isn't working area: simulator Area: simulator priority: medium Medium severity labels Jul 7, 2026
@goanpeca goanpeca self-assigned this Jul 7, 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 pull request tightens B2Simulator’s behavior around Object Lock updates so SDK tests exercise the same invalid transitions that real B2 rejects (retention updates on lock-disabled buckets, retention weakening rules, and strict-auth bypass capability enforcement), closing issue #16.

Changes:

  • Enforce fileLockEnabled on b2_update_file_retention and b2_update_file_legal_hold in the simulator and validate legal-hold values.
  • Block compliance retention weakening/removal; require bypassGovernance (and bypassGovernance capability in strict-auth) for governance weakening.
  • Add/adjust tests to cover the above behavior and ensure test buckets opt into file lock.

Reviewed changes

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

File Description
src/simulator/index.ts Adds Object Lock enforcement and validation for retention/legal-hold update handlers, including strict-auth bypass capability checks.
src/object-lock.test.ts Adds regression tests for lock-disabled buckets, compliance/governance weakening rules, strict-auth bypass capability, and legalHold validation.
src/client.test.ts Updates retention/legal-hold tests to create lock-enabled buckets to match new simulator enforcement.

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

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 review requested due to automatic review settings July 7, 2026 13: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 4 out of 4 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 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 7, 2026 14:06
@goanpeca goanpeca force-pushed the fix/issue-16-simulator-object-lock branch from 1fed02e to 5207b5e Compare July 8, 2026 16:08
Copilot AI review requested due to automatic review settings July 8, 2026 16:08

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/object-lock.test.ts
Copilot AI review requested due to automatic review settings July 8, 2026 19:42
@goanpeca goanpeca force-pushed the fix/issue-16-simulator-object-lock branch from 5207b5e to ff5ebc8 Compare July 8, 2026 19:42

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 2 comments.

Comment thread src/object-lock.test.ts
Comment thread src/simulator/index.ts Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 14:24
@goanpeca goanpeca force-pushed the fix/issue-16-simulator-object-lock branch from ff5ebc8 to adc8452 Compare July 13, 2026 14:24

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.

Copilot AI review requested due to automatic review settings July 13, 2026 14:31

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.

Copilot AI review requested due to automatic review settings July 13, 2026 14:36

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 merged commit 4d46655 into main Jul 13, 2026
29 checks passed
@goanpeca goanpeca deleted the fix/issue-16-simulator-object-lock branch July 13, 2026 14:56
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: file retention / legal hold updates stored without validation or enforcement

2 participants