activestorage-hotcell-server 1.0.0 → 1.1.0

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: bf17ea2179bb687a22b71617e04962d371dec1f92a53eec85e04f1a03df6ae01
4
- data.tar.gz: 52ee3dedc13811e9e71882c1a26bfe342a3f28013c9005842f1969e1cce1d3fe
3
+ metadata.gz: 564a7c12f6ca3517a73524b53f1fe3a4e2eeb8227def645557cc840b0a6fedca
4
+ data.tar.gz: b40a4dedbf29c4c7164670fda7466fe40c54740317d5d740940279cf15149aee
5
5
  SHA512:
6
- metadata.gz: d7375a3807281a2f753fcaf71300f7aabbc6fd3e5312964232e75547565667264bada483eb7f0c67bc7a0b4d2093f39851b401ba144860098174da91b3b60b37
7
- data.tar.gz: 1d2fe8b510a6eaffc40a19a21f5fee3bd20077a399a83c436f6616ce8476270541a8fe8347743bf736f77b80f29961e18e206f4bf96a49c8ac63524db70681e1
6
+ metadata.gz: 276349261e10c73ec526f98ac2cfa5883a350b5dd943f833a523b8af626fb647ee3de51acac42cd83d55c36d3e23d489a09860a0188e81f2399032963fc8e3ed
7
+ data.tar.gz: 6770cd3d3e91768735583b5583045dbfd5b7005702955dffe1ef8a56af26f7cdb7cec7848c0fd74c2f1ecf76d7e98323ceccd57f0df1f9f9fca4919a1f5c36a2
@@ -22,7 +22,8 @@ module ActiveStorage
22
22
  # separate change.
23
23
  def render(source, destination, page:, resolution:)
24
24
  run! "mutool", "draw", "-F", "png", "-r", resolution.to_s, "-o", destination.path,
25
- source.fd_path, page.to_s, pass: [ source.to_io ]
25
+ source.fd_path, page.to_s, pass: [ source.to_io ],
26
+ causes: { /cannot authenticate password/ => ProtectedDocument }
26
27
  end
27
28
 
28
29
  def tool
@@ -22,7 +22,7 @@ module ActiveStorage
22
22
  def render(source, destination, page:, resolution:)
23
23
  run! "pdftoppm", "-png", "-singlefile", "-cropbox", "-r", resolution.to_s,
24
24
  "-f", page.to_s, "-l", page.to_s, source.fd_path, destination.path,
25
- pass: [ source.to_io ]
25
+ pass: [ source.to_io ], causes: { /Incorrect password/ => ProtectedDocument }
26
26
 
27
27
  destination.adopt destination.path(extension: "png")
28
28
  end
@@ -20,16 +20,25 @@ module ActiveStorage
20
20
  # UnreadableInput is always in the rescue list, and this descends from it.
21
21
  class UnreadableDocument < ::HotCell::UnreadableInput; end
22
22
 
23
+ # The document demands credentials the cell does not have.
24
+ class ProtectedDocument < UnreadableDocument
25
+ def self.cause
26
+ ::HotCell::Codes::PROTECTED
27
+ end
28
+ end
29
+
23
30
  private
24
31
  # Runs the tool with unsetenv_others and a written environment, and turns a non-zero exit into
25
32
  # `unreadable`. The tool's own stderr is the only useful diagnostic, and it is attacker-influenced,
26
33
  # so it is capped and scrubbed on its way onto the wire like any other error message.
27
- def run!(*command, pass: [])
34
+ # `causes` maps stderr patterns to the UnreadableDocument subclass to raise instead.
35
+ def run!(*command, pass: [], causes: {})
28
36
  result = run_tool(*command, pass: pass)
29
37
  return result if result.ok?
30
38
 
31
- raise UnreadableDocument, "#{command.first} exited #{result.status.exitstatus}: " \
32
- "#{result.err.to_s.strip[0, 200]}"
39
+ error = causes.detect { |pattern, _| result.err.to_s.match?(pattern) }&.last || UnreadableDocument
40
+ raise error, "#{command.first} exited #{result.status.exitstatus}: " \
41
+ "#{result.err.to_s.strip[0, 200]}"
33
42
  end
34
43
 
35
44
  # An empty output means the tool said it succeeded and produced nothing, which the client would
@@ -10,7 +10,8 @@ module ActiveStorage
10
10
  module Image
11
11
  # What `ActiveStorage::Transformers::ImageProcessingTransformer` does, moved out of the application,
12
12
  # and deliberately nothing more: the transformations and the format reach ImageProcessing exactly as
13
- # Rails hands them over.
13
+ # Rails hands them over, except that the client sends a web image's format as its content type's
14
+ # canonical extension, so `jfif` arrives as `jpg` (#84).
14
15
  #
15
16
  # There is no allowlist here, and that mirrors Rails: the vips path validates exactly one thing —
16
17
  # `combine_options` is refused — and `ActiveStorage.supported_image_processing_methods` is enforced by
@@ -3,7 +3,7 @@
3
3
  module ActiveStorage
4
4
  module HotCell
5
5
  module Server
6
- VERSION = "1.0.0"
6
+ VERSION = "1.1.0"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage-hotcell-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 1.0.0
18
+ version: 1.1.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 1.0.0
25
+ version: 1.1.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: image_processing
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -99,8 +99,8 @@ licenses:
99
99
  - MIT
100
100
  metadata:
101
101
  homepage_uri: https://github.com/basecamp/hotcell
102
- source_code_uri: https://github.com/basecamp/hotcell/tree/v1.0.0/activestorage-hotcell-server
103
- changelog_uri: https://github.com/basecamp/hotcell/blob/v1.0.0/CHANGELOG.md
102
+ source_code_uri: https://github.com/basecamp/hotcell/tree/v1.1.0/activestorage-hotcell-server
103
+ changelog_uri: https://github.com/basecamp/hotcell/blob/v1.1.0/CHANGELOG.md
104
104
  documentation_uri: https://basecamp.github.io/hotcell/
105
105
  bug_tracker_uri: https://github.com/basecamp/hotcell/issues
106
106
  rubygems_mfa_required: 'true'
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubygems_version: 4.0.6
121
+ rubygems_version: 4.0.16
122
122
  specification_version: 4
123
123
  summary: The operations a cell runs on behalf of Active Storage.
124
124
  test_files: []