test: add comprehensive tests for mount-security module#721
Closed
cmraible-bot wants to merge 1 commit intoqwibitai:mainfrom
Closed
test: add comprehensive tests for mount-security module#721cmraible-bot wants to merge 1 commit intoqwibitai:mainfrom
cmraible-bot wants to merge 1 commit intoqwibitai:mainfrom
Conversation
The mount-security module handles security-critical mount validation (path traversal prevention, blocked pattern matching, symlink resolution, read-only enforcement) but had zero test coverage. Adds 35 tests covering: - Allowlist loading: missing file, invalid JSON, malformed structure, default pattern merging, caching behavior - Mount validation: blocked patterns, allowed roots, container path traversal prevention, non-existent paths - Read-only enforcement: nonMainReadOnly policy, per-root allowReadWrite - Symlink security: resolving symlinks before validation, blocking symlinks that escape allowed roots or target blocked paths - validateAdditionalMounts: filtering, container path prefixing - generateAllowlistTemplate: valid JSON structure Also adds _resetMountCacheForTests() to clear the module-level cache between tests (same pattern as task-scheduler.ts). Co-Authored-By: Claude Opus 4.6 <[email protected]>
Collaborator
|
More tests for mount-security is always welcome. Will review alongside the other test PRs. |
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
The
mount-security.tsmodule is security-critical — it handles mount validation, path traversal prevention, blocked pattern matching, symlink resolution, and read-only enforcement for container mounts. Despite this, it had zero test coverage.This PR adds 35 tests covering all public functions and security-relevant edge cases:
Also adds
_resetMountCacheForTests()to clear the module-level cache between tests (same pattern used by task-scheduler.ts).Changes
src/mount-security.ts: Add_resetMountCacheForTests()export (5 lines)src/mount-security.test.ts: New file with 35 testsTest plan
Co-Authored-By: Claude Opus 4.6 [email protected]