no-mistakes 0.20.0 → 0.20.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "no-mistakes",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "description": "Static codebase analysis tools for TS/JS dependencies, dependents, and symbols",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -60,8 +60,26 @@ function request(
60
60
  reject(new Error(`Redirect missing Location header while downloading ${url}`));
61
61
  return;
62
62
  }
63
+
64
+ let redirectedUrl;
65
+ try {
66
+ redirectedUrl = new URL(response.headers.location, url);
67
+ } catch {
68
+ reject(
69
+ new Error(
70
+ `Invalid redirect Location header while downloading ${url}: ${response.headers.location}`,
71
+ ),
72
+ );
73
+ return;
74
+ }
75
+
76
+ if (redirectedUrl.protocol !== "http:" && redirectedUrl.protocol !== "https:") {
77
+ reject(new Error(`Unsupported redirect protocol: ${redirectedUrl.protocol}`));
78
+ return;
79
+ }
80
+
63
81
  request(
64
- new URL(response.headers.location, url).toString(),
82
+ redirectedUrl.toString(),
65
83
  handleResponse,
66
84
  redirects + 1,
67
85
  clients,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const { createHash } = require("node:crypto");
3
+ const { createHash, randomBytes } = require("node:crypto");
4
4
  const { closeSync, createReadStream, existsSync, openSync, readSync } = require("node:fs");
5
5
  const { chmod, mkdir, rename, rm } = require("node:fs/promises");
6
6
  const { join } = require("node:path");
@@ -60,7 +60,7 @@ async function install(binName, repository, options = {}) {
60
60
  const validateReleaseDownloadUrl = (url) =>
61
61
  validateReleaseBaseUrl(url, repository, { enforcePath: false });
62
62
 
63
- const temp = `${destination}.tmp-${process.pid}`;
63
+ const temp = `${destination}.tmp-${randomBytes(8).toString("hex")}`;
64
64
 
65
65
  await mkdir(vendorDir, { recursive: true });
66
66