validation_hints 8.1.53 → 8.1.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49aca61415cd7b149eda369369bafbd1e69bc10fb8c689fe94ce23bbee00b1f5
4
- data.tar.gz: a17f3a05ef555962d0492ec27357a05d9498881e39eae3741af5e100387281f3
3
+ metadata.gz: b00528564dc763c66657356d4b08594551ee86bf698a02fa57ee532a44e0ef71
4
+ data.tar.gz: b23ff8bf829e423fdf807474113a4df261f7643c95975f14d8cf3a6ee5ac2ac0
5
5
  SHA512:
6
- metadata.gz: b13fb5bf25dd6311ba4fdf3ec8b5b105132bde1a58e657a4c763fd1f0040b6156d6abfc2fedcb84ae75d64c362abdb7fae9658a1a1280b11ed68c6c4eceebd9a
7
- data.tar.gz: be50e09b531540d326291b5ce4030aa68b478bf05902ab98f318829e8f82dd8a07ddc3deefb8b04b8e513250f17b125e4b7018bb9fafe1310525d30412f2e333
6
+ metadata.gz: b81c7341844b612933df4321be3b0342ce2cd3470035fbbd22836a4383dfff601284600ee98e88023a281c2a2faa2bce909f78622eebccbab0e5fb6d294d4138
7
+ data.tar.gz: 4a599c1f2bfa3195081513d453e66154af98b2a583b70e5339123756c5d4d1c438664f8aa5b7218f00886e53e7f1eca62126eacc0474650bfb402161e72cd34f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project are documented here.
4
4
 
5
+ ## 8.1.55
6
+
7
+ ### Fixed
8
+
9
+ - **The published gem is world-readable again.** RubyGems packages each file with its on-disk mode and `gem install` restores it; the release checkout is group-only, so 8.1.53 shipped every file as `0660`, unreadable for anyone but the installing user and group. New `ValidationHints::GemBuild` (loaded by the gemspec) packages files as `0644`, or `0755` if executable. Tested in `test/gem_build_test.rb`. Lockstep with **inline_forms** / **inline_forms_installer** / **inline_forms_schema_edit** **8.1.55**.
10
+
11
+ ## 8.1.54
12
+
13
+ ### Changed
14
+
15
+ - **Version numbering:** aligned with **inline_forms** / **inline_forms_installer** / **inline_forms_schema_edit** **8.1.54** (companion release: Devise password views no longer call the removed `devise_error_messages!`; no API changes in validation_hints).
16
+
5
17
  ## 8.1.53
6
18
 
7
19
  ### Changed
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "delegate"
4
+ require "rubygems/package"
5
+
6
+ # Build-time only (loaded by validation_hints.gemspec): package every file
7
+ # world-readable, 0755 if the owner may execute it, else 0644.
8
+ #
9
+ # RubyGems packages each file's on-disk mode (File.lstat) and `gem install`
10
+ # restores it. The dev checkout is group-only (rw-rw----), so 8.1.53 shipped
11
+ # every file as 0660: only the installing user and group could read the
12
+ # installed gem, and a Docker image that installs as root and runs as another
13
+ # user could not load it. Same fix as InlineFormsGemFiles in inline_forms.
14
+ module ValidationHints
15
+ module GemBuild
16
+ module_function
17
+
18
+ def packaged_mode(mode)
19
+ (mode & 0o100).zero? ? 0o644 : 0o755
20
+ end
21
+
22
+ class ReadableTar < SimpleDelegator
23
+ def add_file_simple(name, mode, size, &block)
24
+ __getobj__.add_file_simple(name, GemBuild.packaged_mode(mode), size, &block)
25
+ end
26
+ end
27
+
28
+ module ReadablePackage
29
+ def add_files(tar)
30
+ super(ReadableTar.new(tar))
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ Gem::Package.prepend(ValidationHints::GemBuild::ReadablePackage) unless Gem::Package <= ValidationHints::GemBuild::ReadablePackage
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module ValidationHints
4
- VERSION = "8.1.53"
4
+ VERSION = "8.1.55"
5
5
  end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "minitest/autorun"
4
+ require "tmpdir"
5
+ require "zlib"
6
+ require_relative "../lib/validation_hints/gem_build"
7
+
8
+ # 8.1.53 shipped every file as 0660 (the checkout's group-only modes), so an
9
+ # installed gem was unreadable for anyone outside the installing user and
10
+ # group. Gem builds now package 0644 / 0755 whatever the on-disk modes.
11
+ class GemBuildTest < Minitest::Test
12
+ REPO_ROOT = File.expand_path("..", __dir__)
13
+
14
+ def packaged_modes(gem_path)
15
+ modes = {}
16
+ File.open(gem_path, "rb") do |io|
17
+ Gem::Package::TarReader.new(io).each do |entry|
18
+ next unless entry.full_name == "data.tar.gz"
19
+
20
+ Gem::Package::TarReader.new(Zlib::GzipReader.new(entry)).each do |file|
21
+ modes[file.full_name] = file.header.mode & 0o777
22
+ end
23
+ end
24
+ end
25
+ modes
26
+ end
27
+
28
+ def build(spec, dir, gem_dir)
29
+ gem_path = File.join(gem_dir, "#{spec.full_name}.gem")
30
+ Dir.chdir(dir) do
31
+ package = Gem::Package.new(gem_path)
32
+ package.spec = spec
33
+ Gem::DefaultUserInteraction.use_ui(Gem::SilentUI.new) { package.build(true) }
34
+ end
35
+ gem_path
36
+ end
37
+
38
+ def test_group_only_files_are_packaged_world_readable
39
+ Dir.mktmpdir do |src|
40
+ Dir.mktmpdir do |out|
41
+ File.write(File.join(src, "plain.rb"), "# plain\n")
42
+ File.write(File.join(src, "tool"), "#!/bin/sh\n")
43
+ File.chmod(0o660, File.join(src, "plain.rb"))
44
+ File.chmod(0o700, File.join(src, "tool"))
45
+
46
+ spec = Gem::Specification.new do |s|
47
+ s.name = "modes_probe"
48
+ s.version = "0.0.1"
49
+ s.summary = "probe"
50
+ s.authors = ["probe"]
51
+ s.files = %w[plain.rb tool]
52
+ end
53
+
54
+ modes = packaged_modes(build(spec, src, out))
55
+
56
+ assert_equal({ "plain.rb" => 0o644, "tool" => 0o755 }, modes)
57
+ end
58
+ end
59
+ end
60
+
61
+ def test_the_gemspec_packages_world_readable_files
62
+ path = File.join(REPO_ROOT, "validation_hints.gemspec")
63
+ spec = Gem::Specification.load(path)
64
+ refute_nil spec
65
+
66
+ Dir.mktmpdir do |out|
67
+ modes = packaged_modes(build(spec, REPO_ROOT, out))
68
+
69
+ refute_empty modes
70
+ unreadable = modes.reject { |_, mode| (mode & 0o444) == 0o444 }
71
+ assert_empty unreadable, "not world-readable in the .gem"
72
+ end
73
+ end
74
+ end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "lib/validation_hints/version"
4
+ # Build-time: package world-readable file modes (see ValidationHints::GemBuild).
5
+ require_relative "lib/validation_hints/gem_build"
4
6
 
5
7
  Gem::Specification.new do |s|
6
8
  s.name = "validation_hints"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validation_hints
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.53
4
+ version: 8.1.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -159,6 +159,7 @@ files:
159
159
  - Rakefile
160
160
  - lib/active_model/hints.rb
161
161
  - lib/validation_hints.rb
162
+ - lib/validation_hints/gem_build.rb
162
163
  - lib/validation_hints/locale/en.yml
163
164
  - lib/validation_hints/railtie.rb
164
165
  - lib/validation_hints/validations_patch.rb
@@ -166,6 +167,7 @@ files:
166
167
  - stuff/rails-8-checklist.md
167
168
  - test/active_model/hints_test.rb
168
169
  - test/active_model/i18n_test.rb
170
+ - test/gem_build_test.rb
169
171
  - test/test_helper.rb
170
172
  - test/validation_hints_test.rb
171
173
  - validation_hints.gemspec