ember-cli-rails 0.14.2 → 0.14.4

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: 205edc4e10aa3f203c8cd2f372ba62a3ce75890712207924b4a845dbbfd610d2
4
- data.tar.gz: 20f5b025ff819827debf7c33d3ec396c206b1ccb2e61f26551c08638dbaa415c
3
+ metadata.gz: e0986ec5bf3dcf1656ad150a4ab25153d609c19b8389bc5a1984f4de7f719ef0
4
+ data.tar.gz: 5d792cebbb4ae393ff1beff1ddd948c42af86a654f7e8089bca7c962b8c96d3f
5
5
  SHA512:
6
- metadata.gz: 42a1be898ab5343abb64fbecdea9146cfb0b28ece2a21071ef82abece673ea19bb524b5f1f501cc83619cb9d1189846cd87ce2a52607c3b0296dfd201af3f0f7
7
- data.tar.gz: 894db060b527d318f5282cc81b72c447fb4452a0a94b23967a7b3fcb9a9ba31187ff2f82ae135245e5a50aa287af81898959339c7fe066cec7187ba7e134e47a
6
+ metadata.gz: 21e68ca9d8f73bcac834ebed7a68e305c678a2c1784e32cf85d5138becc67cba56fb8c83ca136c9e9753fa571397781d33f596acef642fc09b56cae31a83232a
7
+ data.tar.gz: 1a2a27faa8e0e5fb487894182ddb81ad7f59e32ac3c4e5f32dcd729ccc0dba20c725f0ba132517318356ec4fda19367089927ab9165ffaae7921c30c68c3e133
data/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ 0.14.4
2
+ ------
3
+
4
+ * Read the mount point `render_ember_app` remaps a Vite build's asset URLs
5
+ onto from the route `mount_ember_app` draws, rather than from `params`. A
6
+ page that called `render_ember_app` from any other route took it from the
7
+ query string, so a link such as `/?ember_mount_point=//attacker.example`
8
+ made the page load its scripts and stylesheets from another host (a
9
+ reflected XSS). Affects Vite-based applications since 0.13.2
10
+ ([GHSA-whxv-9q4m-932c](https://github.com/tricknotes/ember-cli-rails/security/advisories/GHSA-whxv-9q4m-932c))
11
+
12
+ 0.14.3
13
+ ------
14
+
15
+ * Quote the paths of the executables `ember-cli-rails` runs (`ember`, `vite`,
16
+ `npm`, `yarn`, `pnpm`, `bower` and `bundler`) before handing their command
17
+ lines to the shell. An application, or an executable configured with an
18
+ option such as `npm_path`, under a directory whose name contained a space
19
+ or another character the shell treats specially failed to build or install
20
+ * Stop passing `format: :html` to the route `mount_ember_app` draws. Rails
21
+ ignored a Symbol `format:` until rails/rails#59418, which makes it a
22
+ format requirement with `html` as the default. With it, the route's glob
23
+ swallowed the extension of an asset path such as `/assets/app.js`, so the
24
+ request was treated as HTML and answered with the application's
25
+ `index.html` instead of reaching the mounted assets
26
+
1
27
  0.14.2
2
28
  ------
3
29
 
@@ -11,9 +11,21 @@ module EmberRailsHelper
11
11
  index_html = EmberCli[name].index_html(
12
12
  head: head,
13
13
  body: body,
14
- mount_point: params[:ember_mount_point],
14
+ mount_point: ember_mount_point,
15
15
  )
16
16
 
17
17
  render html: index_html.html_safe
18
18
  end
19
+
20
+ private
21
+
22
+ # The mount point `mount_ember_app` declares for the route being served.
23
+ #
24
+ # It is written into the document's asset URLs, so read it from the route
25
+ # alone: `params` also carries the query string and the request body, which
26
+ # would let a request choose where a page rendered from any other route
27
+ # loads its scripts from.
28
+ def ember_mount_point
29
+ request.path_parameters[:ember_mount_point]
30
+ end
19
31
  end
@@ -1,3 +1,4 @@
1
+ require "shellwords"
1
2
  require "terrapin"
2
3
 
3
4
  module EmberCli
@@ -8,7 +9,7 @@ module EmberCli
8
9
  end
9
10
 
10
11
  def test
11
- line = Terrapin::CommandLine.new(paths.ember, "test --environment test")
12
+ line = Terrapin::CommandLine.new(executable(paths.ember), "test --environment test")
12
13
 
13
14
  line.command
14
15
  end
@@ -25,7 +26,7 @@ module EmberCli
25
26
  # Vite-based blueprint (`ember-cli >= 6.8`). This is what the blueprint's
26
27
  # own `npm start` script runs.
27
28
  def dev_server(host:, port:)
28
- line = Terrapin::CommandLine.new(paths.vite, [
29
+ line = Terrapin::CommandLine.new(executable(paths.vite), [
29
30
  "--host :host",
30
31
  "--port :port",
31
32
  "--strictPort",
@@ -39,6 +40,13 @@ module EmberCli
39
40
 
40
41
  attr_reader :options, :paths
41
42
 
43
+ # Terrapin quotes the values it interpolates into a command line, but not
44
+ # the executable it starts with, so quote that before it reaches the
45
+ # shell.
46
+ def executable(path)
47
+ Shellwords.escape(path.to_s)
48
+ end
49
+
42
50
  def process_watcher
43
51
  options.fetch(:watcher) { EmberCli.configuration.watcher }
44
52
  end
@@ -67,7 +75,7 @@ module EmberCli
67
75
  # Ember application, where Vite leaves stale files in place unless asked
68
76
  # to clear them.
69
77
  def vite_build
70
- line = Terrapin::CommandLine.new(paths.vite, [
78
+ line = Terrapin::CommandLine.new(executable(paths.vite), [
71
79
  "build",
72
80
  "--mode :mode",
73
81
  "--outDir :output_path",
@@ -90,7 +98,7 @@ module EmberCli
90
98
  # `--watcher` names the backend that watches, so it rides along only
91
99
  # when the build watches.
92
100
  def ember_build(watch: false)
93
- line = Terrapin::CommandLine.new(paths.ember, [
101
+ line = Terrapin::CommandLine.new(executable(paths.ember), [
94
102
  "build",
95
103
  ("--watch" if watch),
96
104
  ("--watcher :watcher" if watch && process_watcher),
@@ -12,7 +12,6 @@ module ActionDispatch
12
12
  routing_options.reverse_merge!(
13
13
  controller: "ember_cli/ember",
14
14
  action: "index",
15
- format: :html,
16
15
  )
17
16
 
18
17
  scope constraints: ::EmberCli::EmberConstraint.new do
@@ -1,3 +1,5 @@
1
+ require "shellwords"
2
+
1
3
  require "ember_cli/command"
2
4
  require "ember_cli/runner"
3
5
 
@@ -62,7 +64,7 @@ module EmberCli
62
64
 
63
65
  def install
64
66
  if paths.gemfile.exist?
65
- run! "#{paths.bundler} install"
67
+ run! "#{executable(paths.bundler)} install"
66
68
  end
67
69
 
68
70
  if invalid_ember_dependencies?
@@ -71,15 +73,17 @@ module EmberCli
71
73
 
72
74
  case paths.package_manager
73
75
  when :yarn
74
- run! "#{paths.yarn} install"
76
+ run! "#{executable(paths.yarn)} install"
75
77
  when :pnpm
76
- run! "#{paths.pnpm} install"
78
+ run! "#{executable(paths.pnpm)} install"
77
79
  else
78
- run! "#{paths.npm} prune && #{paths.npm} install"
80
+ npm = executable(paths.npm)
81
+ run! "#{npm} prune && #{npm} install"
79
82
  end
80
83
 
81
84
  if paths.bower_json.exist?
82
- run! "#{paths.bower} prune && #{paths.bower} install"
85
+ bower = executable(paths.bower)
86
+ run! "#{bower} prune && #{bower} install"
83
87
  end
84
88
  end
85
89
 
@@ -94,8 +98,14 @@ module EmberCli
94
98
 
95
99
  delegate :run, :run!, to: :runner
96
100
 
101
+ # The executables come from configuration and the filesystem, so quote
102
+ # them before interpolating them into a command line for the shell.
103
+ def executable(path)
104
+ Shellwords.escape(path.to_s)
105
+ end
106
+
97
107
  def invalid_ember_dependencies?
98
- !run("#{paths.ember} version").success?
108
+ !run("#{executable(paths.ember)} version").success?
99
109
  rescue DependencyError
100
110
  false
101
111
  end
@@ -1,3 +1,3 @@
1
1
  module EmberCli
2
- VERSION = "0.14.2".freeze
2
+ VERSION = "0.14.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-cli-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.14.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  - !ruby/object:Gem::Version
217
217
  version: '0'
218
218
  requirements: []
219
- rubygems_version: 4.0.16
219
+ rubygems_version: 4.0.20
220
220
  specification_version: 4
221
221
  summary: Integration between Ember CLI and Rails
222
222
  test_files: []