@socketsecurity/cli-with-sentry 0.14.44

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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -0
  3. package/bin/cli.js +57 -0
  4. package/bin/npm-cli.js +6 -0
  5. package/bin/npx-cli.js +6 -0
  6. package/dist/constants.d.ts +162 -0
  7. package/dist/constants.js +8 -0
  8. package/dist/constants.js.map +1 -0
  9. package/dist/init.gradle +250 -0
  10. package/dist/instrument-with-sentry.d.ts +1 -0
  11. package/dist/instrument-with-sentry.js +58 -0
  12. package/dist/instrument-with-sentry.js.map +1 -0
  13. package/dist/module-sync/cli.d.ts +2 -0
  14. package/dist/module-sync/cli.js +6851 -0
  15. package/dist/module-sync/cli.js.map +1 -0
  16. package/dist/module-sync/constants.js +3 -0
  17. package/dist/module-sync/constants2.d.ts +0 -0
  18. package/dist/module-sync/constants2.js +231 -0
  19. package/dist/module-sync/constants2.js.map +1 -0
  20. package/dist/module-sync/debug.d.ts +3 -0
  21. package/dist/module-sync/edge.d.ts +66 -0
  22. package/dist/module-sync/errors.d.ts +14 -0
  23. package/dist/module-sync/index.d.ts +192 -0
  24. package/dist/module-sync/index.js +1879 -0
  25. package/dist/module-sync/index.js.map +1 -0
  26. package/dist/module-sync/logging.d.ts +16 -0
  27. package/dist/module-sync/node.d.ts +84 -0
  28. package/dist/module-sync/npm-injection.d.ts +1 -0
  29. package/dist/module-sync/npm-injection.js +26 -0
  30. package/dist/module-sync/npm-injection.js.map +1 -0
  31. package/dist/module-sync/npm-paths.d.ts +15 -0
  32. package/dist/module-sync/npm-paths.js +423 -0
  33. package/dist/module-sync/npm-paths.js.map +1 -0
  34. package/dist/module-sync/npm.d.ts +24 -0
  35. package/dist/module-sync/npm.js +99 -0
  36. package/dist/module-sync/npm.js.map +1 -0
  37. package/dist/module-sync/path-resolve.d.ts +12 -0
  38. package/dist/module-sync/proc-log.d.ts +3 -0
  39. package/dist/module-sync/reify.d.ts +1018 -0
  40. package/dist/module-sync/sdk.d.ts +5 -0
  41. package/dist/module-sync/settings.d.ts +15 -0
  42. package/dist/module-sync/shadow-bin.d.ts +2 -0
  43. package/dist/module-sync/shadow-bin.js +103 -0
  44. package/dist/module-sync/shadow-bin.js.map +1 -0
  45. package/dist/module-sync/types.d.ts +45 -0
  46. package/dist/require/cli.js +6848 -0
  47. package/dist/require/constants.js +3 -0
  48. package/dist/require/index.js +3 -0
  49. package/dist/require/npm-injection.js +3 -0
  50. package/dist/require/npm-paths.js +3 -0
  51. package/dist/require/npm.js +3 -0
  52. package/dist/require/shadow-bin.js +3 -0
  53. package/dist/require/vendor.js +11474 -0
  54. package/package.json +245 -0
  55. package/shadow-bin/npm +4 -0
  56. package/shadow-bin/npx +4 -0
  57. package/translations.json +592 -0
@@ -0,0 +1,5 @@
1
+ import { SocketSdk } from '@socketsecurity/sdk';
2
+ declare function getDefaultToken(): string | undefined;
3
+ declare function getPublicToken(): string;
4
+ declare function setupSdk(apiToken?: string | undefined, apiBaseUrl?: string | undefined, proxy?: string | undefined): Promise<SocketSdk>;
5
+ export { getDefaultToken, getPublicToken, setupSdk };
@@ -0,0 +1,15 @@
1
+ import config from '@socketsecurity/config';
2
+ interface Settings {
3
+ apiBaseUrl?: string | null | undefined;
4
+ apiKey?: string | null | undefined;
5
+ apiProxy?: string | null | undefined;
6
+ enforcedOrgs?: string[] | null | undefined;
7
+ apiToken?: string | null | undefined;
8
+ }
9
+ declare function findSocketYmlSync(): {
10
+ path: string;
11
+ parsed: config.SocketYml;
12
+ } | null;
13
+ declare function getSetting<Key extends keyof Settings>(key: Key): Settings[Key];
14
+ declare function updateSetting<Key extends keyof Settings>(key: Key, value: Settings[Key]): void;
15
+ export { findSocketYmlSync, getSetting, updateSetting };
@@ -0,0 +1,2 @@
1
+ declare function shadowBin(binName: 'npm' | 'npx', args?: string[]): Promise<void>;
2
+ export { shadowBin as default };
@@ -0,0 +1,103 @@
1
+ 'use strict';
2
+
3
+ function _socketInterop(e) {
4
+ let c = 0
5
+ for (const k in e ?? {}) {
6
+ c = c === 0 && k === 'default' ? 1 : 0
7
+ if (!c && k !== '__esModule') break
8
+ }
9
+ return c ? e.default : e
10
+ }
11
+
12
+ var process = require('node:process');
13
+ var spawn = _socketInterop(require('@npmcli/promise-spawn'));
14
+ var path = require('node:path');
15
+ var cmdShim = _socketInterop(require('cmd-shim'));
16
+ var npmPaths = require('./npm-paths.js');
17
+ var constants = require('./constants2.js');
18
+ var npm = require('./npm.js');
19
+
20
+ const {
21
+ CLI,
22
+ NPX
23
+ } = constants.constants;
24
+ async function installLinks(realBinPath, binName) {
25
+ const isNpx = binName === NPX;
26
+ // Find package manager being shadowed by this process.
27
+ const binPath = isNpx ? npmPaths.getNpxBinPath() : npmPaths.getNpmBinPath();
28
+ // Lazily access constants.WIN32.
29
+ const {
30
+ WIN32
31
+ } = constants.constants;
32
+ // TODO: Is this early exit needed?
33
+ if (WIN32 && binPath) {
34
+ return binPath;
35
+ }
36
+ const shadowed = isNpx ? npmPaths.isNpxBinPathShadowed() : npmPaths.isNpmBinPathShadowed();
37
+ // Move our bin directory to front of PATH so its found first.
38
+ if (!shadowed) {
39
+ if (WIN32) {
40
+ await cmdShim(
41
+ // Lazily access constants.rootDistPath.
42
+ path.join(constants.constants.rootDistPath, `${binName}-${CLI}.js`), path.join(realBinPath, binName));
43
+ }
44
+ process.env['PATH'] = `${realBinPath}${path.delimiter}${process.env['PATH']}`;
45
+ }
46
+ return binPath;
47
+ }
48
+
49
+ const {
50
+ SOCKET_CLI_SAFE_WRAPPER,
51
+ SOCKET_CLI_SENTRY_BUILD,
52
+ SOCKET_IPC_HANDSHAKE,
53
+ abortSignal
54
+ } = constants.constants;
55
+ async function shadowBin(binName, args = process.argv.slice(2)) {
56
+ process.exitCode = 1;
57
+ const terminatorPos = args.indexOf('--');
58
+ const binArgs = (terminatorPos === -1 ? args : args.slice(0, terminatorPos)).filter(a => !npm.isProgressFlag(a));
59
+ const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos);
60
+ const spawnPromise = spawn(
61
+ // Lazily access constants.execPath.
62
+ constants.constants.execPath, [
63
+ // Lazily access constants.nodeNoWarningsFlags.
64
+ ...constants.constants.nodeNoWarningsFlags,
65
+ // Lazily access constants.ENV[SOCKET_CLI_SENTRY_BUILD].
66
+ ...(constants.constants.ENV[SOCKET_CLI_SENTRY_BUILD] ? ['--require',
67
+ // Lazily access constants.instrumentWithSentryPath.
68
+ constants.constants.instrumentWithSentryPath] : []), '--require',
69
+ // Lazily access constants.npmInjectionPath.
70
+ constants.constants.npmInjectionPath,
71
+ // Lazily access constants.shadowBinPath.
72
+ await installLinks(constants.constants.shadowBinPath, binName),
73
+ // Add `--no-progress` and `--quiet` flags to fix input being swallowed by
74
+ // the spinner when running the command with recent versions of npm.
75
+ '--no-progress',
76
+ // Add the '--quiet' flag if a loglevel flag is not provided.
77
+ ...(binArgs.some(npm.isLoglevelFlag) ? [] : ['--quiet']), ...binArgs, ...otherArgs], {
78
+ signal: abortSignal,
79
+ // 'inherit' + 'ipc'
80
+ stdio: [0, 1, 2, 'ipc']
81
+ });
82
+ // See https://nodejs.org/api/all.html#all_child_process_event-exit.
83
+ spawnPromise.process.on('exit', (code, signalName) => {
84
+ if (abortSignal.aborted) {
85
+ return;
86
+ }
87
+ if (signalName) {
88
+ process.kill(process.pid, signalName);
89
+ } else if (code !== null) {
90
+ process.exit(code);
91
+ }
92
+ });
93
+ spawnPromise.process.send({
94
+ [SOCKET_IPC_HANDSHAKE]: {
95
+ [SOCKET_CLI_SAFE_WRAPPER]: true
96
+ }
97
+ });
98
+ await spawnPromise;
99
+ }
100
+
101
+ module.exports = shadowBin;
102
+ //# debugId=4e5b63c6-e098-4ed6-837b-8200334878cf
103
+ //# sourceMappingURL=shadow-bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shadow-bin.js","sources":["../../src/shadow/link.ts","../../src/shadow/shadow-bin.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\n\nimport cmdShim from 'cmd-shim'\n\nimport {\n getNpmBinPath,\n getNpxBinPath,\n isNpmBinPathShadowed,\n isNpxBinPathShadowed\n} from './npm-paths'\nimport constants from '../constants'\n\nconst { CLI, NPX } = constants\n\nexport async function installLinks(\n realBinPath: string,\n binName: 'npm' | 'npx'\n): Promise<string> {\n const isNpx = binName === NPX\n // Find package manager being shadowed by this process.\n const binPath = isNpx ? getNpxBinPath() : getNpmBinPath()\n // Lazily access constants.WIN32.\n const { WIN32 } = constants\n // TODO: Is this early exit needed?\n if (WIN32 && binPath) {\n return binPath\n }\n const shadowed = isNpx ? isNpxBinPathShadowed() : isNpmBinPathShadowed()\n // Move our bin directory to front of PATH so its found first.\n if (!shadowed) {\n if (WIN32) {\n await cmdShim(\n // Lazily access constants.rootDistPath.\n path.join(constants.rootDistPath, `${binName}-${CLI}.js`),\n path.join(realBinPath, binName)\n )\n }\n process.env['PATH'] =\n `${realBinPath}${path.delimiter}${process.env['PATH']}`\n }\n return binPath\n}\n","import process from 'node:process'\n\nimport spawn from '@npmcli/promise-spawn'\n\nimport { installLinks } from './link'\nimport constants from '../constants'\nimport { isLoglevelFlag, isProgressFlag } from '../utils/npm'\n\nconst {\n SOCKET_CLI_SAFE_WRAPPER,\n SOCKET_CLI_SENTRY_BUILD,\n SOCKET_IPC_HANDSHAKE,\n abortSignal\n} = constants\n\nexport default async function shadowBin(\n binName: 'npm' | 'npx',\n args = process.argv.slice(2)\n) {\n process.exitCode = 1\n const terminatorPos = args.indexOf('--')\n const binArgs = (\n terminatorPos === -1 ? args : args.slice(0, terminatorPos)\n ).filter(a => !isProgressFlag(a))\n const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos)\n const spawnPromise = spawn(\n // Lazily access constants.execPath.\n constants.execPath,\n [\n // Lazily access constants.nodeNoWarningsFlags.\n ...constants.nodeNoWarningsFlags,\n // Lazily access constants.ENV[SOCKET_CLI_SENTRY_BUILD].\n ...(constants.ENV[SOCKET_CLI_SENTRY_BUILD]\n ? [\n '--require',\n // Lazily access constants.instrumentWithSentryPath.\n constants.instrumentWithSentryPath\n ]\n : []),\n '--require',\n // Lazily access constants.npmInjectionPath.\n constants.npmInjectionPath,\n // Lazily access constants.shadowBinPath.\n await installLinks(constants.shadowBinPath, binName),\n // Add `--no-progress` and `--quiet` flags to fix input being swallowed by\n // the spinner when running the command with recent versions of npm.\n '--no-progress',\n // Add the '--quiet' flag if a loglevel flag is not provided.\n ...(binArgs.some(isLoglevelFlag) ? [] : ['--quiet']),\n ...binArgs,\n ...otherArgs\n ],\n {\n signal: abortSignal,\n // 'inherit' + 'ipc'\n stdio: [0, 1, 2, 'ipc']\n }\n )\n // See https://nodejs.org/api/all.html#all_child_process_event-exit.\n spawnPromise.process.on('exit', (code, signalName) => {\n if (abortSignal.aborted) {\n return\n }\n if (signalName) {\n process.kill(process.pid, signalName)\n } else if (code !== null) {\n process.exit(code)\n }\n })\n spawnPromise.process.send({\n [SOCKET_IPC_HANDSHAKE]: {\n [SOCKET_CLI_SAFE_WRAPPER]: true\n }\n })\n await spawnPromise\n}\n"],"names":["NPX","WIN32","process","abortSignal","constants","signal","spawnPromise"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA;;AAAaA;AAAI;AAEV;AAIL;AACA;;AAEA;;AACQC;AAAM;AACd;;AAEE;AACF;;AAEA;;AAEE;AACE;AACE;;AAIJ;AACAC;AAEF;AACA;AACF;;AClCA;;;;AAIEC;AACF;AAEe;;AAKb;AACA;AAGA;;AAEE;;AAGE;;AAEA;;AAIM;AACAC;AAIN;AACAA;AACA;AACA;AACA;AACA;;AAEA;;AAMAC;AACA;;AAEF;AAEF;;;AAGI;AACF;AACA;;AAEA;AACEH;AACF;AACF;AACAI;AACE;AACE;AACF;AACF;AACA;AACF;;","debugId":"4e5b63c6-e098-4ed6-837b-8200334878cf"}
@@ -0,0 +1,45 @@
1
+ /// <reference types="npmcli__arborist" />
2
+ import { SafeNode } from "./node.js";
3
+ import { ReifyOptions } from '@npmcli/arborist';
4
+ import { Options as ArboristOptions } from "@npmcli/arborist";
5
+ import { Advisory as BaseAdvisory } from "@npmcli/arborist";
6
+ import { Arborist as BaseArborist } from "@npmcli/arborist";
7
+ import { AuditReport as BaseAuditReport } from "@npmcli/arborist";
8
+ import { Diff as BaseDiff } from "@npmcli/arborist";
9
+ type ArboristClass = ArboristInstance & {
10
+ new (...args: any): ArboristInstance;
11
+ };
12
+ type ArboristInstance = Omit<typeof BaseArborist, 'actualTree' | 'auditReport' | 'diff' | 'idealTree' | 'reify'> & {
13
+ auditReport?: AuditReportInstance | null | undefined;
14
+ actualTree?: SafeNode | null | undefined;
15
+ diff: Diff | null;
16
+ idealTree?: SafeNode | null | undefined;
17
+ reify(options?: ArboristReifyOptions): Promise<SafeNode>;
18
+ };
19
+ type ArboristReifyOptions = ReifyOptions & ArboristOptions;
20
+ type AuditReportInstance = Omit<BaseAuditReport, 'report'> & {
21
+ report: {
22
+ [dependency: string]: AuditAdvisory[];
23
+ };
24
+ };
25
+ type AuditAdvisory = Omit<BaseAdvisory, 'id'> & {
26
+ id: number;
27
+ cwe: string[];
28
+ cvss: {
29
+ score: number;
30
+ vectorString: string;
31
+ };
32
+ vulnerable_versions: string;
33
+ };
34
+ type Diff = Omit<BaseDiff, 'actual' | 'children' | 'filterSet' | 'ideal' | 'leaves' | 'removed' | 'shrinkwrapInflated' | 'unchanged'> & {
35
+ actual: SafeNode;
36
+ children: Diff[];
37
+ filterSet: Set<SafeNode>;
38
+ ideal: SafeNode;
39
+ leaves: SafeNode[];
40
+ parent: Diff | null;
41
+ removed: SafeNode[];
42
+ shrinkwrapInflated: Set<SafeNode>;
43
+ unchanged: SafeNode[];
44
+ };
45
+ export { ArboristClass, ArboristInstance, ArboristReifyOptions, AuditReportInstance, AuditAdvisory, Diff };