Class: Klee::MCP::PathValidator
- Inherits:
-
Object
- Object
- Klee::MCP::PathValidator
- Defined in:
- lib/klee/mcp/path_validator.rb
Instance Method Summary collapse
-
#initialize(allowed_roots: [Dir.pwd]) ⇒ PathValidator
constructor
A new instance of PathValidator.
- #validate!(patterns) ⇒ Object
Constructor Details
#initialize(allowed_roots: [Dir.pwd]) ⇒ PathValidator
Returns a new instance of PathValidator.
6 7 8 |
# File 'lib/klee/mcp/path_validator.rb', line 6 def initialize(allowed_roots: [Dir.pwd]) @allowed_roots = allowed_roots.map { |r| File.(r) } end |
Instance Method Details
#validate!(patterns) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/klee/mcp/path_validator.rb', line 10 def validate!(patterns) patterns.each do |pattern| = (pattern) unless allowed?() raise SecurityError, "Pattern '#{pattern}' resolves to '#{}' which is outside allowed roots: #{@allowed_roots.join(", ")}" end end end |