rechrome 1.40.0 → 1.42.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.
package/scoped-upload.js CHANGED
@@ -214,13 +214,14 @@ async function readHostFile(path, hostDirs, limit) {
214
214
  const inside = (real) => roots.some((root) => real.startsWith(root.endsWith(sep) ? root : root + sep));
215
215
  const resolveInside = async () => {
216
216
  let real;
217
+ const refused = () => new Error("Host upload path is not an existing file in the listener's allowed directories");
217
218
  try {
218
219
  real = await realpath(path);
219
220
  } catch {
220
- throw new Error("Host upload file not found");
221
+ throw refused();
221
222
  }
222
223
  if (!inside(real))
223
- throw new Error("Host upload path is outside the listener's allowed directories");
224
+ throw refused();
224
225
  return real;
225
226
  };
226
227
  const handle = await open(await resolveInside(), fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0));
@@ -292,7 +293,7 @@ async function receiveUpload(options) {
292
293
  const failed = (r) => r.status !== 0 || /^### Error\b/m.test(r.stdout);
293
294
  const script = async (mode) => {
294
295
  const file = join(dir, randomBytes(8).toString("hex") + ".js");
295
- await writeFile(file, uploadScript(mode, p.target, path, p), { mode: 384, flag: "wx" });
296
+ await writeFile(file, uploadScript(mode, p.target, path, { ...p, data: bytes.toString("base64") }), { mode: 384, flag: "wx" });
296
297
  return options.run(["run-code", "--filename", file]);
297
298
  };
298
299
  const mode = p.mode ?? "auto";
package/scoped-upload.ts CHANGED
@@ -224,8 +224,10 @@ export async function readHostFile(path: string, hostDirs: string[] | undefined,
224
224
  const inside = (real: string) => roots.some(root => real.startsWith(root.endsWith(sep) ? root : root + sep));
225
225
  const resolveInside = async () => {
226
226
  let real: string;
227
- try { real = await realpath(path); } catch { throw new Error('Host upload file not found'); }
228
- if (!inside(real)) throw new Error('Host upload path is outside the listener\'s allowed directories');
227
+ // One answer for "missing" and "outside", so a link holder can't probe which host paths exist.
228
+ const refused = () => new Error('Host upload path is not an existing file in the listener\'s allowed directories');
229
+ try { real = await realpath(path); } catch { throw refused(); }
230
+ if (!inside(real)) throw refused();
229
231
  return real;
230
232
  };
231
233
  // Open once, then prove the opened file is the one an allowed path names now (same device and
@@ -293,7 +295,8 @@ export async function receiveUpload(options: {
293
295
  const failed = (r: UploadResult) => r.status !== 0 || /^### Error\b/m.test(r.stdout);
294
296
  const script = async (mode: Exclude<UploadMode, 'chooser'>) => {
295
297
  const file = join(dir!, randomBytes(8).toString('hex') + '.js');
296
- await writeFile(file, uploadScript(mode, p.target, path, p), { mode: 0o600, flag: 'wx' });
298
+ // drop/paste embed the bytes in the page script; a --host upload sent none, so use what was read.
299
+ await writeFile(file, uploadScript(mode, p.target, path, { ...p, data: bytes.toString('base64') }), { mode: 0o600, flag: 'wx' });
297
300
  return options.run(['run-code', '--filename', file]);
298
301
  };
299
302
  const mode = p.mode ?? 'auto';
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Zachary Rice
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.