puppet 6.21.0-x64-mingw32 → 6.24.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +5 -5
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +29 -23
  5. data/README.md +4 -4
  6. data/ext/osx/puppet.plist +2 -0
  7. data/ext/project_data.yaml +3 -2
  8. data/lib/puppet.rb +3 -3
  9. data/lib/puppet/application/agent.rb +12 -5
  10. data/lib/puppet/application/apply.rb +2 -1
  11. data/lib/puppet/application/device.rb +2 -1
  12. data/lib/puppet/application/filebucket.rb +1 -0
  13. data/lib/puppet/application/resource.rb +17 -3
  14. data/lib/puppet/application/script.rb +2 -1
  15. data/lib/puppet/application/ssl.rb +12 -0
  16. data/lib/puppet/configurer/downloader.rb +2 -1
  17. data/lib/puppet/defaults.rb +27 -5
  18. data/lib/puppet/environments.rb +26 -1
  19. data/lib/puppet/face/facts.rb +128 -30
  20. data/lib/puppet/face/help/action.erb +1 -0
  21. data/lib/puppet/face/help/face.erb +1 -0
  22. data/lib/puppet/face/node/clean.rb +11 -0
  23. data/lib/puppet/file_serving/fileset.rb +14 -2
  24. data/lib/puppet/file_system/file_impl.rb +1 -1
  25. data/lib/puppet/file_system/memory_file.rb +8 -1
  26. data/lib/puppet/file_system/windows.rb +4 -2
  27. data/lib/puppet/forge.rb +3 -3
  28. data/lib/puppet/functions/all.rb +1 -1
  29. data/lib/puppet/functions/camelcase.rb +1 -1
  30. data/lib/puppet/functions/capitalize.rb +2 -2
  31. data/lib/puppet/functions/downcase.rb +2 -2
  32. data/lib/puppet/functions/empty.rb +8 -0
  33. data/lib/puppet/functions/get.rb +5 -5
  34. data/lib/puppet/functions/group_by.rb +13 -5
  35. data/lib/puppet/functions/lest.rb +1 -1
  36. data/lib/puppet/functions/new.rb +100 -100
  37. data/lib/puppet/functions/partition.rb +12 -4
  38. data/lib/puppet/functions/require.rb +5 -5
  39. data/lib/puppet/functions/sort.rb +3 -3
  40. data/lib/puppet/functions/strftime.rb +1 -0
  41. data/lib/puppet/functions/tree_each.rb +7 -9
  42. data/lib/puppet/functions/type.rb +4 -4
  43. data/lib/puppet/functions/unwrap.rb +17 -2
  44. data/lib/puppet/functions/upcase.rb +2 -2
  45. data/lib/puppet/http/resolver/server_list.rb +15 -4
  46. data/lib/puppet/http/service/compiler.rb +69 -0
  47. data/lib/puppet/http/service/file_server.rb +2 -1
  48. data/lib/puppet/indirector/catalog/compiler.rb +1 -0
  49. data/lib/puppet/indirector/facts/facter.rb +24 -3
  50. data/lib/puppet/indirector/file_metadata/rest.rb +1 -0
  51. data/lib/puppet/indirector/resource/ral.rb +6 -1
  52. data/lib/puppet/interface/documentation.rb +1 -0
  53. data/lib/puppet/module_tool/applications/installer.rb +4 -0
  54. data/lib/puppet/module_tool/errors/shared.rb +17 -0
  55. data/lib/puppet/network/formats.rb +67 -0
  56. data/lib/puppet/network/http/factory.rb +4 -0
  57. data/lib/puppet/parser/functions/fqdn_rand.rb +14 -6
  58. data/lib/puppet/pops/types/p_sem_ver_type.rb +8 -2
  59. data/lib/puppet/pops/types/p_sensitive_type.rb +10 -0
  60. data/lib/puppet/pops/types/type_mismatch_describer.rb +1 -1
  61. data/lib/puppet/provider/exec/posix.rb +16 -4
  62. data/lib/puppet/provider/package/dnfmodule.rb +1 -1
  63. data/lib/puppet/provider/package/nim.rb +11 -6
  64. data/lib/puppet/provider/package/pip.rb +15 -3
  65. data/lib/puppet/provider/parsedfile.rb +3 -0
  66. data/lib/puppet/provider/service/systemd.rb +14 -4
  67. data/lib/puppet/provider/service/windows.rb +38 -0
  68. data/lib/puppet/provider/user/directoryservice.rb +25 -12
  69. data/lib/puppet/provider/user/useradd.rb +9 -2
  70. data/lib/puppet/reference/configuration.rb +1 -1
  71. data/lib/puppet/settings.rb +30 -7
  72. data/lib/puppet/settings/environment_conf.rb +1 -0
  73. data/lib/puppet/transaction/additional_resource_generator.rb +1 -1
  74. data/lib/puppet/type/exec.rb +16 -3
  75. data/lib/puppet/type/file.rb +19 -1
  76. data/lib/puppet/type/file/mode.rb +6 -0
  77. data/lib/puppet/type/file/selcontext.rb +1 -1
  78. data/lib/puppet/type/service.rb +18 -38
  79. data/lib/puppet/type/tidy.rb +22 -3
  80. data/lib/puppet/type/user.rb +38 -20
  81. data/lib/puppet/util/fact_dif.rb +36 -17
  82. data/lib/puppet/util/monkey_patches.rb +7 -0
  83. data/lib/puppet/util/selinux.rb +30 -4
  84. data/lib/puppet/util/symbolic_file_mode.rb +29 -17
  85. data/lib/puppet/util/windows/adsi.rb +46 -0
  86. data/lib/puppet/util/windows/api_types.rb +1 -1
  87. data/lib/puppet/util/windows/principal.rb +9 -2
  88. data/lib/puppet/util/windows/sid.rb +6 -2
  89. data/lib/puppet/version.rb +1 -1
  90. data/locales/puppet.pot +360 -280
  91. data/man/man5/puppet.conf.5 +279 -251
  92. data/man/man8/puppet-agent.8 +1 -1
  93. data/man/man8/puppet-apply.8 +1 -1
  94. data/man/man8/puppet-catalog.8 +9 -9
  95. data/man/man8/puppet-config.8 +1 -1
  96. data/man/man8/puppet-describe.8 +1 -1
  97. data/man/man8/puppet-device.8 +1 -1
  98. data/man/man8/puppet-doc.8 +1 -1
  99. data/man/man8/puppet-epp.8 +1 -1
  100. data/man/man8/puppet-facts.8 +65 -7
  101. data/man/man8/puppet-filebucket.8 +1 -1
  102. data/man/man8/puppet-generate.8 +1 -1
  103. data/man/man8/puppet-help.8 +1 -1
  104. data/man/man8/puppet-key.8 +7 -7
  105. data/man/man8/puppet-lookup.8 +1 -1
  106. data/man/man8/puppet-man.8 +1 -1
  107. data/man/man8/puppet-module.8 +1 -1
  108. data/man/man8/puppet-node.8 +5 -5
  109. data/man/man8/puppet-parser.8 +1 -1
  110. data/man/man8/puppet-plugin.8 +1 -1
  111. data/man/man8/puppet-report.8 +5 -5
  112. data/man/man8/puppet-resource.8 +1 -1
  113. data/man/man8/puppet-script.8 +1 -1
  114. data/man/man8/puppet-ssl.8 +5 -1
  115. data/man/man8/puppet-status.8 +4 -4
  116. data/man/man8/puppet.8 +2 -2
  117. data/spec/fixtures/ssl/127.0.0.1-key.pem +107 -57
  118. data/spec/fixtures/ssl/127.0.0.1.pem +52 -31
  119. data/spec/fixtures/ssl/bad-basic-constraints.pem +57 -35
  120. data/spec/fixtures/ssl/bad-int-basic-constraints.pem +57 -35
  121. data/spec/fixtures/ssl/ca.pem +57 -35
  122. data/spec/fixtures/ssl/crl.pem +28 -18
  123. data/spec/fixtures/ssl/ec-key.pem +11 -11
  124. data/spec/fixtures/ssl/ec.pem +33 -24
  125. data/spec/fixtures/ssl/encrypted-ec-key.pem +12 -12
  126. data/spec/fixtures/ssl/encrypted-key.pem +108 -58
  127. data/spec/fixtures/ssl/intermediate-agent-crl.pem +28 -19
  128. data/spec/fixtures/ssl/intermediate-agent.pem +57 -36
  129. data/spec/fixtures/ssl/intermediate-crl.pem +31 -21
  130. data/spec/fixtures/ssl/intermediate.pem +57 -36
  131. data/spec/fixtures/ssl/oid-key.pem +117 -0
  132. data/spec/fixtures/ssl/oid.pem +69 -0
  133. data/spec/fixtures/ssl/pluto-key.pem +107 -57
  134. data/spec/fixtures/ssl/pluto.pem +52 -30
  135. data/spec/fixtures/ssl/request-key.pem +107 -57
  136. data/spec/fixtures/ssl/request.pem +47 -26
  137. data/spec/fixtures/ssl/revoked-key.pem +107 -57
  138. data/spec/fixtures/ssl/revoked.pem +52 -30
  139. data/spec/fixtures/ssl/signed-key.pem +107 -57
  140. data/spec/fixtures/ssl/signed.pem +52 -30
  141. data/spec/fixtures/ssl/tampered-cert.pem +52 -30
  142. data/spec/fixtures/ssl/tampered-csr.pem +47 -26
  143. data/spec/fixtures/ssl/trusted_oid_mapping.yaml +5 -0
  144. data/spec/fixtures/ssl/unknown-127.0.0.1-key.pem +107 -57
  145. data/spec/fixtures/ssl/unknown-127.0.0.1.pem +50 -29
  146. data/spec/fixtures/ssl/unknown-ca-key.pem +107 -57
  147. data/spec/fixtures/ssl/unknown-ca.pem +55 -33
  148. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset +9 -0
  149. data/spec/integration/application/filebucket_spec.rb +11 -0
  150. data/spec/integration/application/module_spec.rb +21 -0
  151. data/spec/integration/application/plugin_spec.rb +1 -1
  152. data/spec/integration/application/resource_spec.rb +64 -0
  153. data/spec/integration/application/ssl_spec.rb +20 -0
  154. data/spec/integration/environments/settings_interpolation_spec.rb +0 -4
  155. data/spec/integration/http/client_spec.rb +12 -0
  156. data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
  157. data/spec/integration/indirector/facts/facter_spec.rb +90 -36
  158. data/spec/integration/type/exec_spec.rb +70 -45
  159. data/spec/integration/util/windows/adsi_spec.rb +18 -0
  160. data/spec/integration/util/windows/principal_spec.rb +21 -0
  161. data/spec/integration/util/windows/registry_spec.rb +6 -0
  162. data/spec/lib/puppet/test_ca.rb +7 -2
  163. data/spec/lib/puppet_spec/settings.rb +1 -0
  164. data/spec/spec_helper.rb +11 -1
  165. data/spec/unit/application/agent_spec.rb +7 -2
  166. data/spec/unit/application/facts_spec.rb +482 -3
  167. data/spec/unit/application/ssl_spec.rb +23 -0
  168. data/spec/unit/configurer/downloader_spec.rb +6 -0
  169. data/spec/unit/configurer_spec.rb +23 -0
  170. data/spec/unit/defaults_spec.rb +16 -0
  171. data/spec/unit/environments_spec.rb +199 -88
  172. data/spec/unit/face/facts_spec.rb +4 -0
  173. data/spec/unit/file_serving/fileset_spec.rb +60 -0
  174. data/spec/unit/file_system_spec.rb +15 -0
  175. data/spec/unit/functions/assert_type_spec.rb +1 -1
  176. data/spec/unit/functions/empty_spec.rb +10 -0
  177. data/spec/unit/functions/unwrap_spec.rb +8 -0
  178. data/spec/unit/functions4_spec.rb +2 -2
  179. data/spec/unit/gettext/config_spec.rb +12 -0
  180. data/spec/unit/http/service/compiler_spec.rb +123 -0
  181. data/spec/unit/indirector/catalog/compiler_spec.rb +14 -10
  182. data/spec/unit/indirector/facts/facter_spec.rb +95 -0
  183. data/spec/unit/indirector/resource/ral_spec.rb +40 -75
  184. data/spec/unit/module_tool/applications/installer_spec.rb +12 -0
  185. data/spec/unit/network/formats_spec.rb +41 -0
  186. data/spec/unit/network/http/factory_spec.rb +19 -0
  187. data/spec/unit/parser/functions/fqdn_rand_spec.rb +15 -1
  188. data/spec/unit/parser/templatewrapper_spec.rb +12 -2
  189. data/spec/unit/pops/types/p_sem_ver_type_spec.rb +18 -0
  190. data/spec/unit/pops/types/p_sensitive_type_spec.rb +18 -0
  191. data/spec/unit/provider/package/dnfmodule_spec.rb +10 -1
  192. data/spec/unit/provider/package/nim_spec.rb +42 -0
  193. data/spec/unit/provider/package/pip_spec.rb +37 -0
  194. data/spec/unit/provider/parsedfile_spec.rb +10 -0
  195. data/spec/unit/provider/service/init_spec.rb +1 -0
  196. data/spec/unit/provider/service/openwrt_spec.rb +3 -1
  197. data/spec/unit/provider/service/systemd_spec.rb +53 -8
  198. data/spec/unit/provider/service/windows_spec.rb +202 -0
  199. data/spec/unit/provider/user/directoryservice_spec.rb +67 -35
  200. data/spec/unit/provider/user/useradd_spec.rb +21 -6
  201. data/spec/unit/resource/catalog_spec.rb +1 -1
  202. data/spec/unit/settings_spec.rb +97 -56
  203. data/spec/unit/ssl/state_machine_spec.rb +19 -5
  204. data/spec/unit/transaction/additional_resource_generator_spec.rb +0 -2
  205. data/spec/unit/transaction_spec.rb +18 -20
  206. data/spec/unit/type/exec_spec.rb +76 -29
  207. data/spec/unit/type/file/selinux_spec.rb +3 -3
  208. data/spec/unit/type/file/source_spec.rb +4 -4
  209. data/spec/unit/type/service_spec.rb +59 -188
  210. data/spec/unit/type/tidy_spec.rb +24 -7
  211. data/spec/unit/type/user_spec.rb +45 -0
  212. data/spec/unit/util/selinux_spec.rb +87 -16
  213. data/spec/unit/util/windows/sid_spec.rb +41 -0
  214. data/tasks/generate_cert_fixtures.rake +12 -3
  215. metadata +24 -9
  216. data/spec/lib/matchers/include.rb +0 -27
  217. data/spec/lib/matchers/include_spec.rb +0 -32
@@ -225,6 +225,9 @@ module Puppet::Environments
225
225
  private
226
226
 
227
227
  def create_environment(name)
228
+ # interpolated modulepaths may be cached from prior environment instances
229
+ Puppet.settings.clear_environment_settings(name)
230
+
228
231
  env_symbol = name.intern
229
232
  setting_values = Puppet.settings.values(env_symbol, Puppet.settings.preferred_run_mode)
230
233
  env = Puppet::Node::Environment.create(
@@ -350,7 +353,29 @@ module Puppet::Environments
350
353
 
351
354
  # @!macro loader_list
352
355
  def list
353
- @loader.list
356
+ # Evict all that have expired, in the same way as `get`
357
+ clear_all_expired
358
+
359
+ # Evict all that was removed from diks
360
+ cached_envs = @cache.keys.map!(&:to_sym)
361
+ loader_envs = @loader.list.map!(&:name)
362
+ removed_envs = cached_envs - loader_envs
363
+
364
+ removed_envs.each do |env_name|
365
+ Puppet.debug { "Environment no longer exists '#{env_name}'"}
366
+ clear(env_name)
367
+ end
368
+
369
+ @loader.list.map do |env|
370
+ name = env.name
371
+ old_entry = @cache[name]
372
+ if old_entry
373
+ old_entry.value
374
+ else
375
+ add_entry(name, entry(env))
376
+ env
377
+ end
378
+ end
354
379
  end
355
380
 
356
381
  # @!macro loader_search_paths
@@ -2,28 +2,20 @@ require 'puppet/indirector/face'
2
2
  require 'puppet/node/facts'
3
3
  require 'puppet/util/fact_dif'
4
4
 
5
- EXCLUDE_LIST = %w[facterversion
6
- swapfree_mb swapsize_mb
7
- load_averages\.*
8
- memory\.swap\.available_bytes memory\.swap\.capacity memory\.swap\.total_bytes
9
- memory\.swap\.used_bytes memory\.swap\.available
10
- memory\.system\.available memory\.system\.available_bytes memory\.system\.capacity memory\.swap\.used
11
- memory\.system\.total_bytes memory\.system\.used memory\.system\.used_bytes
12
- memoryfree memoryfree_mb memorysize_mb
13
- mountpoints\..* mtu_.* mountpoints\..*\.capacity
14
- networking\.interfaces\..*\.mtu networking\.mtu partitions\..*\.filesystem
15
- partitions\..*\.size_bytes partitions\..*\.mount partitions\..*\.uuid
16
- disks\..*\.size_bytes
17
- hypervisors\.lpar\.partition_number hypervisors\.xen\.privileged hypervisors\.zone\..* hypervisors\.ldom\..*
18
- processors\.speed
19
- ldom_.*
20
- boardassettag dmi\.board\.asset_tag
21
- blockdevice_.*_vendor blockdevice_.*_size
22
- system_uptime\.days system_uptime\.hours system_uptime\.seconds system_uptime\.uptime
23
- uptime_days uptime_hours uptime_seconds
24
- system_profiler\.uptime
25
- sp_uptime
26
- uptime]
5
+ EXCLUDE_LIST = %w[ ^facterversion$
6
+ ^load_averages\..*$
7
+ ^processors\.speed$
8
+ ^swapfree$ ^swapfree_mb$
9
+ ^memoryfree$ ^memoryfree_mb$
10
+ ^memory\.swap\.available_bytes$ ^memory\.swap\.used_bytes$
11
+ ^memory\.swap\.available$ ^memory\.swap\.capacity$ ^memory\.swap\.used$
12
+ ^memory\.system\.available_bytes$ ^memory\.system\.used_bytes$
13
+ ^memory\.system\.available$ ^memory\.system\.capacity$ ^memory\.system\.used$
14
+ ^mountpoints\..*\.available.*$ ^mountpoints\..*\.capacity$ ^mountpoints\..*\.used.*$
15
+ ^sp_uptime$ ^system_profiler\.uptime$
16
+ ^uptime$ ^uptime_days$ ^uptime_hours$ ^uptime_seconds$
17
+ ^system_uptime\.uptime$ ^system_uptime\.days$ ^system_uptime\.hours$ ^system_uptime\.seconds$
18
+ ]
27
19
 
28
20
  Puppet::Indirector::Face.define(:facts, '0.0.1') do
29
21
  copyright "Puppet Inc.", 2011
@@ -125,26 +117,132 @@ Puppet::Indirector::Face.define(:facts, '0.0.1') do
125
117
  $ puppet facts diff
126
118
  EOT
127
119
 
128
- render_as :json
120
+ option("--structured") do
121
+ default_to { false }
122
+ summary _("Render the different facts as structured.")
123
+ end
124
+
125
+ option("--exclude " + _("<regex>")) do
126
+ summary _("Regex used to exclude specific facts from diff.")
127
+ end
129
128
 
130
129
  when_invoked do |*args|
130
+ options = args.pop
131
+
131
132
  Puppet.settings.preferred_run_mode = :agent
132
133
  Puppet::Node::Facts.indirection.terminus_class = :facter
133
134
 
134
135
  if Puppet::Util::Package.versioncmp(Facter.value('facterversion'), '4.0.0') < 0
135
- facter3_result = Puppet::Node::Facts.indirection.find(Puppet.settings[:certname])
136
- begin
137
- require 'facter-ng'
138
- facter4_result = Puppet::Node::Facts.indirection.find(Puppet.settings[:certname])
139
- rescue LoadError
140
- raise ArgumentError, 'facter-ng could not be loaded'
136
+ cmd_flags = '--render-as json --show-legacy'
137
+
138
+ # puppet/ruby are in PATH since it was updated in the wrapper script
139
+ puppet_show_cmd = "puppet facts show"
140
+ if Puppet::Util::Platform.windows?
141
+ puppet_show_cmd = "ruby -S -- #{puppet_show_cmd}"
141
142
  end
142
- fact_diff = FactDif.new(facter3_result.to_json, facter4_result.to_json, EXCLUDE_LIST)
143
+
144
+ facter_3_result = Puppet::Util::Execution.execute("#{puppet_show_cmd} --no-facterng #{cmd_flags}", combine: false)
145
+ facter_ng_result = Puppet::Util::Execution.execute("#{puppet_show_cmd} --facterng #{cmd_flags}", combine: false)
146
+
147
+ exclude_list = options[:exclude].nil? ? EXCLUDE_LIST : EXCLUDE_LIST + [ options[:exclude] ]
148
+ fact_diff = FactDif.new(facter_3_result, facter_ng_result, exclude_list, options[:structured])
143
149
  fact_diff.difs
144
150
  else
145
151
  Puppet.warning _("Already using Facter 4. To use `puppet facts diff` remove facterng from the .conf file or run `puppet config set facterng false`.")
146
152
  exit 0
147
153
  end
148
154
  end
155
+
156
+ when_rendering :console do |result|
157
+ case result
158
+ when Array, Hash
159
+ Puppet::Util::Json.dump(result, :pretty => true)
160
+ else
161
+ result
162
+ end
163
+ end
164
+ end
165
+
166
+ action(:show) do
167
+ summary _("Retrieve current node's facts.")
168
+ arguments _("[<facts>]")
169
+ description <<-'EOT'
170
+ Reads facts from the local system using `facter` terminus.
171
+ A query can be provided to retrieve just a specific fact or a set of facts.
172
+ EOT
173
+ returns "The output of facter with added puppet specific facts."
174
+ notes <<-'EOT'
175
+
176
+ EOT
177
+ examples <<-'EOT'
178
+ retrieve facts:
179
+
180
+ $ puppet facts show os
181
+ EOT
182
+
183
+ option("--config-file " + _("<path>")) do
184
+ default_to { nil }
185
+ summary _("The location of the config file for Facter.")
186
+ end
187
+
188
+ option("--custom-dir " + _("<path>")) do
189
+ default_to { nil }
190
+ summary _("The path to a directory that contains custom facts.")
191
+ end
192
+
193
+ option("--external-dir " + _("<path>")) do
194
+ default_to { nil }
195
+ summary _("The path to a directory that contains external facts.")
196
+ end
197
+
198
+ option("--no-block") do
199
+ summary _("Disable fact blocking mechanism.")
200
+ end
201
+
202
+ option("--no-cache") do
203
+ summary _("Disable fact caching mechanism.")
204
+ end
205
+
206
+ option("--show-legacy") do
207
+ summary _("Show legacy facts when querying all facts.")
208
+ end
209
+
210
+ option("--value-only") do
211
+ summary _("Show only the value when the action is called with a single query")
212
+ end
213
+
214
+ when_invoked do |*args|
215
+ options = args.pop
216
+
217
+ Puppet.settings.preferred_run_mode = :agent
218
+ Puppet::Node::Facts.indirection.terminus_class = :facter
219
+
220
+ if options[:value_only] && !args.count.eql?(1)
221
+ options[:value_only] = nil
222
+ Puppet.warning("Incorrect use of --value-only argument; it can only be used when querying for a single fact!")
223
+ end
224
+
225
+ options[:user_query] = args
226
+ options[:resolve_options] = true
227
+ result = Puppet::Node::Facts.indirection.find(Puppet.settings[:certname], options)
228
+
229
+ if options[:value_only]
230
+ result.values.values.first
231
+ else
232
+ result.values
233
+ end
234
+ end
235
+
236
+ when_rendering :console do |result|
237
+ # VALID_TYPES = [Integer, Float, TrueClass, FalseClass, NilClass, Symbol, String, Array, Hash].freeze
238
+ # from https://github.com/puppetlabs/facter/blob/4.0.49/lib/facter/custom_facts/util/normalization.rb#L8
239
+
240
+ case result
241
+ when Array, Hash
242
+ Puppet::Util::Json.dump(result, :pretty => true)
243
+ else # one of VALID_TYPES above
244
+ result
245
+ end
246
+ end
149
247
  end
150
248
  end
@@ -54,6 +54,7 @@ undocumented option
54
54
  end
55
55
  unless action.options.empty?
56
56
  action.options.sort.each do |name|
57
+ next if name == :extra
57
58
  option = action.get_option name -%>
58
59
  <%= " " + option.optparse.join(" | ")[0,(optionroom - 1)].ljust(optionroom) + ' - ' -%>
59
60
  <% if !(option.summary) -%>
@@ -49,6 +49,7 @@ undocumented option
49
49
  end
50
50
  unless face.options.empty?
51
51
  face.options.sort.each do |name|
52
+ next if name == :extra
52
53
  option = face.get_option name -%>
53
54
  <%= " " + option.optparse.join(" | ")[0,(optionroom - 1)].ljust(optionroom) + ' - ' -%>
54
55
  <% if !(option.summary) -%>
@@ -47,6 +47,17 @@ Puppet::Face.define(:node, '0.0.1') do
47
47
  end
48
48
 
49
49
  class LoggerIO
50
+ def debug(message)
51
+ Puppet.debug(message)
52
+ end
53
+
54
+ # Notice: For Puppet 6.x, the function below does not matter as it
55
+ # does not have any functionality. But we decided to keep it here
56
+ # for the ease of merge up to 7.x and having the same code base.
57
+ def warn(message)
58
+ Puppet.warning(message) unless message =~ /cadir is currently configured to be inside/
59
+ end
60
+
50
61
  def err(message)
51
62
  Puppet.err(message) unless message =~ /^\s*Error:\s*/
52
63
  end
@@ -5,7 +5,7 @@ require 'puppet/file_serving/metadata'
5
5
  # Operate recursively on a path, returning a set of file paths.
6
6
  class Puppet::FileServing::Fileset
7
7
  attr_reader :path, :ignore, :links
8
- attr_accessor :recurse, :recurselimit, :checksum_type
8
+ attr_accessor :recurse, :recurselimit, :max_files, :checksum_type
9
9
 
10
10
  # Produce a hash of files, with merged so that earlier files
11
11
  # with the same postfix win. E.g., /dir1/subfile beats /dir2/subfile.
@@ -40,6 +40,7 @@ class Puppet::FileServing::Fileset
40
40
  self.links = :manage
41
41
  @recurse = false
42
42
  @recurselimit = :infinite
43
+ @max_files = 0
43
44
 
44
45
  if options.is_a?(Puppet::Indirector::Request)
45
46
  initialize_from_request(options)
@@ -58,6 +59,17 @@ class Puppet::FileServing::Fileset
58
59
  # level deep, which Find doesn't do.
59
60
  def files
60
61
  files = perform_recursion
62
+ soft_max_files = 1000
63
+
64
+ # munged_max_files is needed since puppet http handler is keeping negative numbers as strings
65
+ # https://github.com/puppetlabs/puppet/blob/main/lib/puppet/network/http/handler.rb#L196-L197
66
+ munged_max_files = max_files == '-1' ? -1 : max_files
67
+
68
+ if munged_max_files > 0 && files.size > munged_max_files
69
+ raise Puppet::Error.new _("The directory '%{path}' contains %{entries} entries, which exceeds the limit of %{munged_max_files} specified by the max_files parameter for this resource. The limit may be increased, but be aware that large number of file resources can result in excessive resource consumption and degraded performance. Consider using an alternate method to manage large directory trees") % { path: path, entries: files.size, munged_max_files: munged_max_files }
70
+ elsif munged_max_files == 0 && files.size > soft_max_files
71
+ Puppet.warning _("The directory '%{path}' contains %{entries} entries, which exceeds the default soft limit %{soft_max_files} and may cause excessive resource consumption and degraded performance. To remove this warning set a value for `max_files` parameter or consider using an alternate method to manage large directory trees") % { path: path, entries: files.size, soft_max_files: soft_max_files }
72
+ end
61
73
 
62
74
  # Now strip off the leading path, so each file becomes relative, and remove
63
75
  # any slashes that might end up at the beginning of the path.
@@ -96,7 +108,7 @@ class Puppet::FileServing::Fileset
96
108
  end
97
109
 
98
110
  def initialize_from_request(request)
99
- [:links, :ignore, :recurse, :recurselimit, :checksum_type].each do |param|
111
+ [:links, :ignore, :recurse, :recurselimit, :max_files, :checksum_type].each do |param|
100
112
  if request.options.include?(param) # use 'include?' so the values can be false
101
113
  value = request.options[param]
102
114
  elsif request.options.include?(param.to_s)
@@ -84,7 +84,7 @@ class Puppet::FileSystem::FileImpl
84
84
  end
85
85
 
86
86
  def read_preserve_line_endings(path)
87
- read(path)
87
+ read(path, encoding: "bom|#{Encoding.default_external.name}")
88
88
  end
89
89
 
90
90
  def binread(path)
@@ -7,6 +7,13 @@ class Puppet::FileSystem::MemoryFile
7
7
  new(path, :exist? => false, :executable? => false)
8
8
  end
9
9
 
10
+ def self.a_missing_directory(path)
11
+ new(path,
12
+ :exist? => false,
13
+ :executable? => false,
14
+ :directory? => true)
15
+ end
16
+
10
17
  def self.a_regular_file_containing(path, content)
11
18
  new(path, :exist? => true, :executable? => false, :content => content)
12
19
  end
@@ -18,7 +25,7 @@ class Puppet::FileSystem::MemoryFile
18
25
  def self.a_directory(path, children = [])
19
26
  new(path,
20
27
  :exist? => true,
21
- :excutable? => true,
28
+ :executable? => true,
22
29
  :directory? => true,
23
30
  :children => children)
24
31
  end
@@ -109,8 +109,8 @@ class Puppet::FileSystem::Windows < Puppet::FileSystem::Posix
109
109
  end
110
110
 
111
111
  def read_preserve_line_endings(path)
112
- contents = path.read( :mode => 'rb', :encoding => Encoding::UTF_8)
113
- contents = path.read( :mode => 'rb', :encoding => Encoding::default_external) unless contents.valid_encoding?
112
+ contents = path.read( :mode => 'rb', :encoding => 'bom|utf-8')
113
+ contents = path.read( :mode => 'rb', :encoding => "bom|#{Encoding::default_external.name}") unless contents.valid_encoding?
114
114
  contents = path.read unless contents.valid_encoding?
115
115
 
116
116
  contents
@@ -128,6 +128,8 @@ class Puppet::FileSystem::Windows < Puppet::FileSystem::Posix
128
128
  end
129
129
 
130
130
  current_sid = Puppet::Util::Windows::SID.name_to_sid(Puppet::Util::Windows::ADSI::User.current_user_name)
131
+ current_sid = Puppet::Util::Windows::SID.name_to_sid(Puppet::Util::Windows::ADSI::User.current_sam_compatible_user_name) unless current_sid
132
+
131
133
  dacl = case mode
132
134
  when 0644
133
135
  dacl = secure_dacl(current_sid)
data/lib/puppet/forge.rb CHANGED
@@ -70,7 +70,7 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
70
70
  uri = decode_uri(result['pagination']['next'])
71
71
  matches.concat result['results']
72
72
  else
73
- raise ResponseError.new(:uri => URI.parse(@host).merge(uri), :response => response)
73
+ raise ResponseError.new(:uri => response.url, :response => response)
74
74
  end
75
75
  end
76
76
 
@@ -105,7 +105,7 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
105
105
  if response.code == 200
106
106
  response = Puppet::Util::Json.load(response.body)
107
107
  else
108
- raise ResponseError.new(:uri => URI.parse(@host).merge(uri), :response => response)
108
+ raise ResponseError.new(:uri => response.url, :response => response)
109
109
  end
110
110
 
111
111
  releases.concat(process(response['results']))
@@ -208,7 +208,7 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
208
208
  response = @source.make_http_request(uri, destination)
209
209
  destination.flush and destination.close
210
210
  unless response.code == 200
211
- raise Puppet::Forge::Errors::ResponseError.new(:uri => uri, :response => response)
211
+ raise Puppet::Forge::Errors::ResponseError.new(:uri => response.url, :response => response)
212
212
  end
213
213
  end
214
214
 
@@ -51,7 +51,7 @@
51
51
  # notice $data.all |$key, $value| { $value % 10 == 0 and $key =~ /^abc/ }
52
52
  # ```
53
53
  #
54
- # Would notice true.
54
+ # Would notice `true`.
55
55
  #
56
56
  # For an general examples that demonstrates iteration, see the Puppet
57
57
  # [iteration](https://puppet.com/docs/puppet/latest/lang_iteration.html)
@@ -3,7 +3,7 @@
3
3
  # This function is compatible with the stdlib function with the same name.
4
4
  #
5
5
  # The function does the following:
6
- # * For a `String` the conversion replaces all combinations of *_<char>* with an upcased version of the
6
+ # * For a `String` the conversion replaces all combinations of `*_<char>*` with an upcased version of the
7
7
  # character following the _. This is done using Ruby system locale which handles some, but not all
8
8
  # special international up-casing rules (for example German double-s ß is upcased to "Ss").
9
9
  # * For an `Iterable[Variant[String, Numeric]]` (for example an `Array`) each value is capitalized and the conversion is not recursive.
@@ -18,14 +18,14 @@
18
18
  # 'hello'.capitalize()
19
19
  # upcase('hello')
20
20
  # ```
21
- # Would both result in "Hello"
21
+ # Would both result in `"Hello"`
22
22
  #
23
23
  # @example Capitalizing strings in an Array
24
24
  # ```puppet
25
25
  # ['abc', 'bcd'].capitalize()
26
26
  # capitalize(['abc', 'bcd'])
27
27
  # ```
28
- # Would both result in ['Abc', 'Bcd']
28
+ # Would both result in `['Abc', 'Bcd']`
29
29
  #
30
30
  Puppet::Functions.create_function(:capitalize) do
31
31
 
@@ -22,14 +22,14 @@
22
22
  # 'HELLO'.downcase()
23
23
  # downcase('HEllO')
24
24
  # ```
25
- # Would both result in "hello"
25
+ # Would both result in `"hello"`
26
26
  #
27
27
  # @example Converting an Array to lower case
28
28
  # ```puppet
29
29
  # ['A', 'B'].downcase()
30
30
  # downcase(['A', 'B'])
31
31
  # ```
32
- # Would both result in ['a', 'b']
32
+ # Would both result in `['a', 'b']`
33
33
  #
34
34
  # @example Converting a Hash to lower case
35
35
  # ```puppet
@@ -26,6 +26,10 @@ Puppet::Functions.create_function(:empty) do
26
26
  param 'Collection', :coll
27
27
  end
28
28
 
29
+ dispatch :sensitive_string_empty do
30
+ param 'Sensitive[String]', :str
31
+ end
32
+
29
33
  dispatch :string_empty do
30
34
  param 'String', :str
31
35
  end
@@ -46,6 +50,10 @@ Puppet::Functions.create_function(:empty) do
46
50
  coll.empty?
47
51
  end
48
52
 
53
+ def sensitive_string_empty(str)
54
+ str.unwrap.empty?
55
+ end
56
+
49
57
  def string_empty(str)
50
58
  str.empty?
51
59
  end