Class: LittleGhost::TrustedPath
- Inherits:
-
Data
- Object
- Data
- LittleGhost::TrustedPath
- Defined in:
- lib/little_ghost/prompt_resolver.rb,
lib/little_ghost/prompt_resolver.rb
Overview
Marks a caller-supplied prompt directory as trusted application code. Construction resolves symbolic links immediately and rejects paths that are missing or are not directories.
Security and trust
Construction is a trust assertion, not a sanitizer. It does not inspect ownership, permissions, or who can modify the directory. ERB templates run as Ruby inside the current process, so create TrustedPath values only from allowlisted, application-controlled, non-user-writable roots. Never wrap a path taken from unchecked request or model input.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path:) ⇒ TrustedPath
constructor
A new instance of TrustedPath.
Constructor Details
#initialize(path:) ⇒ TrustedPath
Returns a new instance of TrustedPath.
12 13 14 15 16 17 18 |
# File 'lib/little_ghost/prompt_resolver.rb', line 12 def initialize(path:) = File.realpath(path) raise ArgumentError, "trusted template path must be a directory" unless File.directory?() super(path: .freeze) rescue Errno::ENOENT raise ArgumentError, "trusted template path must exist" end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path
11 12 13 |
# File 'lib/little_ghost/prompt_resolver.rb', line 11 def path @path end |