Documentation
¶
Overview ¶
Package loader provides secure filesystem access control for template engines.
Security considerations: - Always validate custom fs.FS implementations before use - Ensure path traversal attacks are prevented at the fs.FS level - Consider implementing audit logging for all filesystem access - Use io/fs.Sub to create restricted filesystem views
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFilesystemAccessDisabled = errors.New("template loading from filesystem disabled for security reasons")
ErrFilesystemAccessDisabled is the error returned when filesystem access is disabled for security.
Functions ¶
This section is empty.
Types ¶
type FSLoader ¶
type FSLoader struct {
// contains filtered or unexported fields
}
FSLoader wraps an fs.FS to provide controlled filesystem access. This is used internally when explicit filesystem access is needed.
Security note: The provided fs.FS should be pre-validated to ensure: - It doesn't allow access outside intended boundaries - Path traversal attempts are blocked - Symbolic links don't escape the filesystem root - Consider using fs.Sub() to create restricted views
func NewFSLoader ¶
NewFSLoader creates a new FSLoader with the provided filesystem.
type NilFSLoader ¶
type NilFSLoader struct{}
NilFSLoader is a template loader that provides no filesystem access. This prevents template injection attacks like {% include "/etc/passwd" %}.