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.
Choosing prompt directories
ERB templates run as Ruby inside the current process. TrustedPath checks that a directory exists and resolves symbolic links; it cannot tell who may edit that directory. Create these values only from application-configured, non-user-writable roots, never from a request or model-selected path.
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 |