mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-02-14 07:55:03 -05:00
Add initial set of utility plugins for the template system: - datetime: Date/time formatting and manipulation - fetch: HTTP content retrieval and processing - file: File system operations and content handling - sys: System information and environment access - text: String manipulation and formatting operations Each plugin includes: - Implementation with comprehensive test coverage - Markdown documentation of capabilities - Integration with template package This builds on the template system to provide practical utility functions while maintaining a focused scope for the initial plugin release.
51 lines
1.0 KiB
Markdown
51 lines
1.0 KiB
Markdown
# File Plugin Tests
|
|
|
|
Simple test file for validating file plugin functionality.
|
|
|
|
## Basic File Operations
|
|
|
|
```
|
|
Read File:
|
|
{{plugin:file:read:/path/to/file.txt}}
|
|
|
|
Last 5 Lines:
|
|
{{plugin:file:tail:/path/to/log.txt|5}}
|
|
|
|
Check Existence:
|
|
{{plugin:file:exists:/path/to/file.txt}}
|
|
|
|
Get Size:
|
|
{{plugin:file:size:/path/to/file.txt}}
|
|
|
|
Last Modified:
|
|
{{plugin:file:modified:/path/to/file.txt}}
|
|
```
|
|
|
|
## Error Cases
|
|
These should produce appropriate error messages:
|
|
|
|
```
|
|
Invalid Operation:
|
|
{{plugin:file:invalid:/path/to/file.txt}}
|
|
|
|
Non-existent File:
|
|
{{plugin:file:read:/path/to/nonexistent.txt}}
|
|
|
|
Path Traversal Attempt:
|
|
{{plugin:file:read:../../../etc/passwd}}
|
|
|
|
Invalid Tail Format:
|
|
{{plugin:file:tail:/path/to/file.txt}}
|
|
|
|
Large File:
|
|
{{plugin:file:read:/path/to/huge.iso}}
|
|
```
|
|
|
|
## Security Considerations
|
|
|
|
- Carefully control which paths are accessible
|
|
- Consider using path allow lists in production
|
|
- Be aware of file size limits (1MB max)
|
|
- No directory traversal is allowed
|
|
- Home directory (~/) expansion is supported
|
|
- All paths are cleaned and normalized |