| Server IP : 77.68.64.21 / Your IP : 216.73.217.105 Web Server : Apache System : Linux hp3-wp-1011378.hostingp3.local 3.10.0-1160.144.1.el7.tuxcare.els9.x86_64 #1 SMP Fri Jul 10 17:06:31 UTC 2026 x86_64 User : csh2668128 ( 2112425) PHP Version : 8.1.34 Disable Function : shell_exec,exec,system,popen,set_time_limit MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/ruby/vendor_ruby/puppet/file_system/ |
Upload File : |
require 'pathname'
module Puppet::FileSystem
class PathPattern
class InvalidPattern < Puppet::Error; end
TRAVERSAL = /^\.\.$/
ABSOLUTE_UNIX = /^\//
ABSOLUTE_WINDOWS = /^[a-z]:/i
#ABSOLUT_VODKA #notappearinginthisclass
CURRENT_DRIVE_RELATIVE_WINDOWS = /^\\/
def self.relative(pattern)
RelativePathPattern.new(pattern)
end
def self.absolute(pattern)
AbsolutePathPattern.new(pattern)
end
class << self
protected :new
end
# @param prefix [AbsolutePathPattern] An absolute path pattern instance
# @return [AbsolutePathPattern] A new AbsolutePathPattern prepended with
# the passed prefix's pattern.
def prefix_with(prefix)
new_pathname = prefix.pathname + pathname
self.class.absolute(new_pathname.to_s)
end
def glob
Dir.glob(pathname.to_s)
end
def to_s
pathname.to_s
end
protected
attr_reader :pathname
private
def validate
@pathname.each_filename do |e|
if e =~ TRAVERSAL
raise(InvalidPattern, "PathPatterns cannot be created with directory traversals.")
end
end
case @pathname.to_s
when CURRENT_DRIVE_RELATIVE_WINDOWS
raise(InvalidPattern, "A PathPattern cannot be a Windows current drive relative path.")
end
end
def initialize(pattern)
begin
@pathname = Pathname.new(pattern.strip)
rescue ArgumentError => error
raise InvalidPattern.new("PathPatterns cannot be created with a zero byte.", error)
end
validate
end
end
class RelativePathPattern < PathPattern
def absolute?
false
end
def validate
super
case @pathname.to_s
when ABSOLUTE_WINDOWS
raise(InvalidPattern, "A relative PathPattern cannot be prefixed with a drive.")
when ABSOLUTE_UNIX
raise(InvalidPattern, "A relative PathPattern cannot be an absolute path.")
end
end
end
class AbsolutePathPattern < PathPattern
def absolute?
true
end
def validate
super
if @pathname.to_s !~ ABSOLUTE_UNIX and @pathname.to_s !~ ABSOLUTE_WINDOWS
raise(InvalidPattern, "An absolute PathPattern cannot be a relative path.")
end
end
end
end