Commit graph

18 commits

Author SHA1 Message Date
Fade78
1c40d972d2 Multi-axis audit fixes: security, code quality, API consistency
Security fixes:
- Add explicit symlink detection in _resolve_chroot_path
- Fix TOCTOU race conditions in _patch_text_impl and _patch_bytes_impl
- Sanitize SQLite error messages to prevent information leakage
- Add finally:conn.close() to prevent SQLite connection leaks
- Add readonly check for output_csv in shed_sqlite

Code quality:
- Replace bare except with specific exceptions (OSError, UnicodeDecodeError, etc.)
- Translate French comments to English in shed_import
- Refactor shed_sqlite to use centralized _resolve_zone()

API improvements:
- Change safe=False to safe=True by default in patch_text/patch_bytes
- Change message='' to message=None in zone movement functions

Documentation:
- Add comprehensive error codes reference table to SPEC.md

https://claude.ai/code/session_01THb4YA4SqYG52LVwjwb5Uo
2026-01-30 10:57:24 +01:00
Fade78
d75e174d44 Add zone prefix validation to all remaining functions for consistency
Updated functions with allow_zone_in_path parameter and zone_name validation:
- shed_tree (path)
- shed_zipinfo (path)
- shed_file_type (path)
- shed_hexdump (path)
- shed_force_unlock (path - both group and personal zones)
- shed_group_set_mode (path)
- shed_group_chown (path)

Also fixed zone_name consistency:
- Changed "group:{id}" to "Group:{id}" in _patch_text_impl and _patch_bytes_impl
- Changed "group:{group}" to "Group:{group}" in shed_copy_to_group

All zone names now consistently use capital letters (Storage, Documents,
Uploads, Group:) for internal discipline while accepting case-insensitive
input from users.

https://claude.ai/code/session_01THb4YA4SqYG52LVwjwb5Uo
2026-01-30 10:57:24 +01:00
Fade78
551a72a2d2 Add zone prefix validation to builtin functions (zip, unzip, sqlite, etc.)
Added allow_zone_in_path parameter and zone_name validation to:
- shed_unzip (src + dest paths)
- shed_zip (src + dest paths)
- shed_sqlite (path, import_csv, output_csv paths)
- shed_convert_eol (path)
- shed_import (dest_subdir)

This prevents LLMs from accidentally duplicating zone names in paths
(e.g., zone="storage", path="Storage/folder").

https://claude.ai/code/session_01THb4YA4SqYG52LVwjwb5Uo
2026-01-30 10:57:24 +01:00
Fade78
563e477ecd Add zone prefix validation to bridge functions (move/copy between zones)
Extended zone_name validation to:
- shed_move_uploads_to_storage
- shed_move_uploads_to_documents
- shed_copy_storage_to_documents
- shed_move_documents_to_storage

These functions previously had NO path validation and could create
duplicate zone folders (e.g., Storage/Storage/file.txt).

Also updated shed_help documentation to list all functions supporting
allow_zone_in_path parameter.

https://claude.ai/code/session_01THb4YA4SqYG52LVwjwb5Uo
2026-01-30 10:57:24 +01:00
Fade78
6f5044a684 Add zone prefix validation to lockedit_* and shed_copy_to_group
Extended zone_name validation to:
- All 5 lockedit_* functions (open, exec, overwrite, save, cancel)
- shed_copy_to_group (validates both src_path and dest_path)

Also updated shed_help paths documentation to include lockedit_* in
the list of functions supporting allow_zone_in_path.

https://claude.ai/code/session_01THb4YA4SqYG52LVwjwb5Uo
2026-01-30 10:57:24 +01:00
Fade78
1e2dc56042 Add zone prefix validation to prevent path duplication errors
Refactored path validation to detect when paths start with the zone name
(e.g., "Documents/folder" in zone="documents"), which causes unwanted
directory duplication. The validation rejects such paths by default with
a helpful error message.

Changes:
- Added zone_name and allow_zone_in_path params to _validate_relative_path
- Refactored _validate_path_args to call _validate_relative_path
- Extracted _is_expression_not_path helper for cleaner code
- Updated shed_exec, shed_patch_text, shed_patch_bytes, shed_delete,
  shed_rename to pass zone context and allow_zone_in_path parameter
- Updated _patch_text_impl and _patch_bytes_impl accordingly

LLMs can now set allow_zone_in_path=True if they intentionally want a
subfolder named after the zone.

https://claude.ai/code/session_01THb4YA4SqYG52LVwjwb5Uo
2026-01-30 10:57:24 +01:00
Fade78
f464a0598b Use generic example name in paths documentation
https://claude.ai/code/session_01THb4YA4SqYG52LVwjwb5Uo
2026-01-30 10:57:24 +01:00
Fade78
9085c141d5 Improve shed_help paths guide with explicit duplication warning
LLMs often mistakenly include the zone name in paths (e.g., zone="Documents"
with args=["Documents/folder"]) creating unwanted duplicate folders. Added
detailed explanation with concrete examples showing the mistake and its
consequence.

https://claude.ai/code/session_01THb4YA4SqYG52LVwjwb5Uo
2026-01-30 10:57:24 +01:00
Claude
547a47ac5a
Simplify shed_import message (remove warning field)
Keep context minimal: just remind about shed_delete in message.

https://claude.ai/code/session_01DLaRR2nnTryPWd2p7MyUtf
2026-01-29 00:25:12 +00:00
Claude
7862445a29
Add warning in shed_import about Uploads persistence
Warn users that files imported to Uploads are permanent and NOT deleted
when the conversation is deleted. They must be removed manually with
shed_delete(zone='uploads', path='...').

https://claude.ai/code/session_01DLaRR2nnTryPWd2p7MyUtf
2026-01-29 00:21:46 +00:00
Claude
1b760e6652
Remove warning from shed_unzip (moved to shed_import)
The Uploads persistence warning will be handled by shed_import instead.

https://claude.ai/code/session_01DLaRR2nnTryPWd2p7MyUtf
2026-01-29 00:20:19 +00:00
Claude
345d8299b3
Add warning when extracting ZIP from Uploads zone
Remind users that the source ZIP file remains in Uploads after extraction,
that Uploads files are NOT deleted when the conversation is deleted,
and suggest using shed_delete to remove it manually.

https://claude.ai/code/session_01DLaRR2nnTryPWd2p7MyUtf
2026-01-29 00:05:10 +00:00
Claude
7dc71daa88
Fix shed_help to return normal help when howto is empty string
When LLM passes howto="" instead of omitting the parameter,
treat it as a request for normal help instead of an unknown howto error.

https://claude.ai/code/session_01DLaRR2nnTryPWd2p7MyUtf
2026-01-28 23:56:06 +00:00
Claude
2f57d7f81f
Fix zone names capitalization in shed_unzip
Use canonical zone names with capital letters (Uploads, Storage, Documents)
in documentation, hints, and response data for consistency with the rest
of the codebase.

https://claude.ai/code/session_01DLaRR2nnTryPWd2p7MyUtf
2026-01-28 23:49:23 +00:00
Claude
7384e2d92a
Add src_zone parameter to shed_unzip for cross-zone extraction
Allow extracting ZIP files from Uploads zone without moving them first.
The new src_zone parameter accepts "uploads", "storage", or "documents"
while zone parameter remains the destination (storage/documents only).

Bump version to 1.0.2.

https://claude.ai/code/session_01DLaRR2nnTryPWd2p7MyUtf
2026-01-28 23:43:28 +00:00
Claude
8c47ec27bb
Bump version to 1.0.1
https://claude.ai/code/session_014zLd33kdJPBqDvjpWtHfuX
2026-01-28 18:07:34 +00:00
Claude
20a70f1e83
Security patch: Address audit vulnerabilities
This patch addresses security vulnerabilities identified in the Fileshed audit:

Critical fixes:
- ZIP Slip: Validate resolved paths stay within destination directory
- Git hooks: Neutralize hooks after clone/init to prevent code execution

High priority fixes:
- awk variants: Extend system()/getline validation to gawk/mawk/nawk
- Hard links: Block ln command entirely (both symlinks and hardlinks)
- Resource limits: Add exec_memory_limit_mb and exec_cpu_limit_seconds valves

Medium priority fixes:
- SQLite: Add sqlite_readonly valve for SELECT-only mode
- ffmpeg: Block dangerous options (-metadata, -filter_complex, etc.) in safe mode

New Valves added:
- exec_memory_limit_mb (default: 512MB)
- exec_cpu_limit_seconds (default: 60s)
- sqlite_readonly (default: false)

https://claude.ai/code/session_014zLd33kdJPBqDvjpWtHfuX
2026-01-28 17:59:11 +00:00
Fade
a0dbe391fc
Add files via upload 2026-01-28 01:59:36 +01:00