@socketsecurity/lib 5.11.1 → 5.11.3

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/abort.js +1 -3
  3. package/dist/agent.js +12 -1
  4. package/dist/ansi.js +1 -1
  5. package/dist/archives.js +7 -6
  6. package/dist/argv/flags.d.ts +0 -7
  7. package/dist/argv/flags.js +12 -1
  8. package/dist/argv/parse.js +5 -9
  9. package/dist/bin.js +2 -1
  10. package/dist/cache-with-ttl.js +10 -3
  11. package/dist/constants/node.js +14 -3
  12. package/dist/cover/code.js +13 -2
  13. package/dist/cover/type.js +12 -1
  14. package/dist/dlx/binary.js +16 -5
  15. package/dist/dlx/manifest.js +22 -33
  16. package/dist/env/package-manager.js +12 -1
  17. package/dist/env/rewire.js +14 -3
  18. package/dist/external/@npmcli/package-json.js +5 -3
  19. package/dist/external/adm-zip.js +1 -0
  20. package/dist/external/debug.js +18 -10
  21. package/dist/external/external-pack.js +8 -2
  22. package/dist/external/libnpmexec.js +2 -2
  23. package/dist/external/npm-pack.js +380 -367
  24. package/dist/external/p-map.js +240 -0
  25. package/dist/external/pico-pack.js +245 -12
  26. package/dist/external/zod.js +1 -0
  27. package/dist/fs.d.ts +0 -4
  28. package/dist/fs.js +13 -2
  29. package/dist/git.js +12 -1
  30. package/dist/github.js +15 -6
  31. package/dist/http-request.d.ts +29 -0
  32. package/dist/http-request.js +23 -2
  33. package/dist/ipc.js +17 -5
  34. package/dist/json/edit.js +14 -3
  35. package/dist/logger.js +5 -4
  36. package/dist/memoization.js +46 -13
  37. package/dist/packages/isolation.js +9 -1
  38. package/dist/performance.js +13 -2
  39. package/dist/process-lock.js +16 -3
  40. package/dist/promise-queue.d.ts +2 -0
  41. package/dist/promise-queue.js +20 -9
  42. package/dist/promises.js +1 -3
  43. package/dist/releases/github.js +9 -4
  44. package/dist/sea.js +12 -1
  45. package/dist/shadow.js +14 -3
  46. package/dist/spawn.js +5 -4
  47. package/dist/spinner.d.ts +0 -4
  48. package/dist/spinner.js +2 -1
  49. package/dist/stdio/clear.d.ts +0 -21
  50. package/dist/stdio/clear.js +20 -9
  51. package/dist/stdio/mask.js +27 -16
  52. package/dist/stdio/progress.js +3 -2
  53. package/dist/stdio/stderr.d.ts +0 -13
  54. package/dist/stdio/stderr.js +12 -1
  55. package/dist/stdio/stdout.js +17 -6
  56. package/dist/suppress-warnings.d.ts +0 -9
  57. package/dist/suppress-warnings.js +17 -6
  58. package/dist/temporary-executor.js +14 -3
  59. package/dist/validation/json-parser.js +10 -12
  60. package/package.json +8 -6
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var suppress_warnings_exports = {};
21
31
  __export(suppress_warnings_exports, {
@@ -26,13 +36,14 @@ __export(suppress_warnings_exports, {
26
36
  withSuppressedWarnings: () => withSuppressedWarnings
27
37
  });
28
38
  module.exports = __toCommonJS(suppress_warnings_exports);
39
+ var import_node_process = __toESM(require("node:process"));
29
40
  const { apply: ReflectApply } = Reflect;
30
41
  let originalEmitWarning;
31
42
  const suppressedWarnings = /* @__PURE__ */ new Set();
32
43
  function setupSuppression() {
33
44
  if (!originalEmitWarning) {
34
- originalEmitWarning = process.emitWarning;
35
- process.emitWarning = (warning, ...args) => {
45
+ originalEmitWarning = import_node_process.default.emitWarning;
46
+ import_node_process.default.emitWarning = (warning, ...args) => {
36
47
  if (typeof warning === "string") {
37
48
  for (const suppressedType of suppressedWarnings) {
38
49
  if (warning.includes(suppressedType)) {
@@ -47,7 +58,7 @@ function setupSuppression() {
47
58
  }
48
59
  return ReflectApply(
49
60
  originalEmitWarning,
50
- process,
61
+ import_node_process.default,
51
62
  [warning, ...args]
52
63
  );
53
64
  };
@@ -76,14 +87,14 @@ function setMaxEventTargetListeners(target, maxListeners = 10) {
76
87
  }
77
88
  function restoreWarnings() {
78
89
  if (originalEmitWarning) {
79
- process.emitWarning = originalEmitWarning;
90
+ import_node_process.default.emitWarning = originalEmitWarning;
80
91
  originalEmitWarning = void 0;
81
92
  suppressedWarnings.clear();
82
93
  }
83
94
  }
84
95
  async function withSuppressedWarnings(warningType, callback) {
85
96
  const wasAlreadySuppressed = suppressedWarnings.has(warningType);
86
- const original = process.emitWarning;
97
+ const original = import_node_process.default.emitWarning;
87
98
  suppressWarningType(warningType);
88
99
  try {
89
100
  return await callback();
@@ -91,7 +102,7 @@ async function withSuppressedWarnings(warningType, callback) {
91
102
  if (!wasAlreadySuppressed) {
92
103
  suppressedWarnings.delete(warningType);
93
104
  }
94
- process.emitWarning = original;
105
+ import_node_process.default.emitWarning = original;
95
106
  }
96
107
  }
97
108
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with esbuild */
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,21 +18,30 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var temporary_executor_exports = {};
21
31
  __export(temporary_executor_exports, {
22
32
  isRunningInTemporaryExecutor: () => isRunningInTemporaryExecutor
23
33
  });
24
34
  module.exports = __toCommonJS(temporary_executor_exports);
35
+ var import_node_process = __toESM(require("node:process"));
25
36
  var import_platform = require("./constants/platform");
26
37
  var import_normalize = require("./paths/normalize");
27
- function isRunningInTemporaryExecutor(cwd = process.cwd()) {
28
- const userAgent = process.env["npm_config_user_agent"];
38
+ function isRunningInTemporaryExecutor(cwd = import_node_process.default.cwd()) {
39
+ const userAgent = import_node_process.default.env["npm_config_user_agent"];
29
40
  if (userAgent?.includes("exec") || userAgent?.includes("npx") || userAgent?.includes("dlx")) {
30
41
  return true;
31
42
  }
32
43
  const normalizedCwd = (0, import_normalize.normalizePath)(cwd);
33
- const npmCache = process.env["npm_config_cache"];
44
+ const npmCache = import_node_process.default.env["npm_config_cache"];
34
45
  if (npmCache && normalizedCwd.includes((0, import_normalize.normalizePath)(npmCache))) {
35
46
  return true;
36
47
  }
@@ -27,7 +27,15 @@ __export(json_parser_exports, {
27
27
  tryJsonParse: () => tryJsonParse
28
28
  });
29
29
  module.exports = __toCommonJS(json_parser_exports);
30
- const { hasOwn: ObjectHasOwn } = Object;
30
+ const DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
31
+ function prototypePollutionReviver(key, value) {
32
+ if (DANGEROUS_KEYS.has(key)) {
33
+ throw new Error(
34
+ "JSON contains potentially malicious prototype pollution keys"
35
+ );
36
+ }
37
+ return value;
38
+ }
31
39
  function safeJsonParse(jsonString, schema, options = {}) {
32
40
  const { allowPrototype = false, maxSize = 10 * 1024 * 1024 } = options;
33
41
  const byteLength = Buffer.byteLength(jsonString, "utf8");
@@ -38,20 +46,10 @@ function safeJsonParse(jsonString, schema, options = {}) {
38
46
  }
39
47
  let parsed;
40
48
  try {
41
- parsed = JSON.parse(jsonString);
49
+ parsed = allowPrototype ? JSON.parse(jsonString) : JSON.parse(jsonString, prototypePollutionReviver);
42
50
  } catch (error) {
43
51
  throw new Error(`Failed to parse JSON: ${error}`);
44
52
  }
45
- if (!allowPrototype && typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
46
- const dangerous = ["__proto__", "constructor", "prototype"];
47
- for (const key of dangerous) {
48
- if (ObjectHasOwn(parsed, key)) {
49
- throw new Error(
50
- "JSON contains potentially malicious prototype pollution keys"
51
- );
52
- }
53
- }
54
- }
55
53
  if (schema) {
56
54
  const result = schema.safeParse(parsed);
57
55
  if (!result.success) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/lib",
3
- "version": "5.11.1",
3
+ "version": "5.11.3",
4
4
  "packageManager": "pnpm@10.33.0",
5
5
  "license": "MIT",
6
6
  "description": "Core utilities and infrastructure for Socket.dev security tools",
@@ -734,7 +734,7 @@
734
734
  "@socketregistry/is-unicode-supported": "1.0.5",
735
735
  "@socketregistry/packageurl-js": "1.3.5",
736
736
  "@socketregistry/yocto-spinner": "1.0.25",
737
- "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.11.0",
737
+ "@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.11.2",
738
738
  "@types/node": "24.9.2",
739
739
  "@typescript/native-preview": "7.0.0-dev.20250920.1",
740
740
  "@vitest/coverage-v8": "4.0.3",
@@ -764,15 +764,16 @@
764
764
  "npm-package-arg": "13.0.0",
765
765
  "oxfmt": "^0.37.0",
766
766
  "oxlint": "1.53.0",
767
+ "p-map": "7.0.4",
767
768
  "pacote": "21.0.1",
768
- "picomatch": "2.3.1",
769
+ "picomatch": "4.0.4",
769
770
  "pony-cause": "2.1.11",
770
771
  "semver": "7.7.2",
771
772
  "signal-exit": "4.1.0",
772
773
  "spdx-correct": "3.2.0",
773
774
  "spdx-expression-parse": "4.0.0",
774
775
  "streaming-iterables": "8.0.1",
775
- "supports-color": "10.0.0",
776
+ "supports-color": "10.2.2",
776
777
  "tar-fs": "3.1.2",
777
778
  "tar-stream": "3.1.8",
778
779
  "taze": "19.9.2",
@@ -821,7 +822,8 @@
821
822
  "minizlib": "3.1.0",
822
823
  "npm-package-arg": "12.0.2",
823
824
  "npm-pick-manifest": "10.0.0",
824
- "picomatch": "4.0.3",
825
+ "p-map": "7.0.4",
826
+ "picomatch": "4.0.4",
825
827
  "proc-log": "6.1.0",
826
828
  "semver": "7.7.2",
827
829
  "signal-exit": "4.1.0",
@@ -829,7 +831,7 @@
829
831
  "ssri": "12.0.0",
830
832
  "string-width": "8.1.0",
831
833
  "strip-ansi": "7.1.2",
832
- "supports-color": "10.0.0",
834
+ "supports-color": "10.2.2",
833
835
  "tar": "7.5.11",
834
836
  "which": "5.0.0",
835
837
  "wrap-ansi": "9.0.2",