fix: enforce simulator object lock updates#122
Merged
Conversation
There was a problem hiding this comment.
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
fileLockEnabledonb2_update_file_retentionandb2_update_file_legal_holdin the simulator and validate legal-hold values. - Block compliance retention weakening/removal; require
bypassGovernance(andbypassGovernancecapability 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.
1fed02e to
5207b5e
Compare
5207b5e to
ff5ebc8
Compare
ff5ebc8 to
adc8452
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fileLockEnabled, compliance weakening, governance bypass requirements, strict-authbypassGovernancecapability, and legal-hold value validation.b2_update_file_retentionpayloads before assignment so invalid modes, omitted/non-finite/past timestamps, and malformed null-mode payloads cannot remove or invalidate retention.Date.now()directly.hookTimeoutwith 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.tspnpm exec vitest run src/object-lock.test.ts src/client.test.tsbun test --timeout 180000 src/object-lock.test.tsbun test --timeout 180000 src/B2_APPLICATION_KEY_ID= B2_APPLICATION_KEY= pnpm test:integrationpnpm run typecheckpnpm run lintpnpm testFollow-up notes
None.