@socketsecurity/cli 0.14.28 → 0.14.30

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 (53) hide show
  1. package/bin/cli.js +7 -0
  2. package/bin/npm-cli.js +7 -0
  3. package/bin/npx-cli.js +7 -0
  4. package/bin/shadow/module-sync/npm +3 -0
  5. package/bin/shadow/module-sync/npx +3 -0
  6. package/bin/shadow/require/npm +3 -0
  7. package/bin/shadow/require/npx +3 -0
  8. package/dist/module-sync/cli.d.ts.map +1 -0
  9. package/dist/module-sync/cli.js +5258 -0
  10. package/dist/module-sync/constants.d.ts +20 -0
  11. package/dist/module-sync/constants.js +72 -0
  12. package/dist/module-sync/npm-cli.js +85 -0
  13. package/dist/module-sync/npm-injection.js +1609 -0
  14. package/dist/module-sync/npx-cli.js +61 -0
  15. package/dist/{sdk.d.ts → module-sync/sdk.d.ts} +1 -5
  16. package/dist/module-sync/sdk.js +253 -0
  17. package/dist/require/cli.d.ts +3 -0
  18. package/dist/require/cli.d.ts.map +1 -0
  19. package/dist/{cli.js → require/cli.js} +80 -82
  20. package/dist/require/color-or-markdown.d.ts +23 -0
  21. package/dist/require/constants.d.ts +20 -0
  22. package/dist/require/constants.js +67 -0
  23. package/dist/require/errors.d.ts +7 -0
  24. package/dist/require/link.d.ts +2 -0
  25. package/dist/require/link.js +45 -0
  26. package/dist/require/npm-cli.d.ts +2 -0
  27. package/dist/{npm-cli.js → require/npm-cli.js} +12 -10
  28. package/dist/require/npm-injection.d.ts +1 -0
  29. package/dist/{npm-injection.js → require/npm-injection.js} +169 -135
  30. package/dist/require/npx-cli.d.ts +2 -0
  31. package/dist/{npx-cli.js → require/npx-cli.js} +12 -12
  32. package/dist/require/path-resolve.d.ts +8 -0
  33. package/dist/require/path-resolve.js +183 -0
  34. package/dist/require/sdk.d.ts +9 -0
  35. package/dist/{sdk.js → require/sdk.js} +16 -36
  36. package/dist/require/settings.d.ts +9 -0
  37. package/dist/{vendor.js → require/vendor.js} +6 -1
  38. package/package.json +54 -19
  39. package/translations.json +190 -287
  40. package/bin/npm +0 -2
  41. package/bin/npx +0 -2
  42. package/dist/cli.d.ts.map +0 -1
  43. /package/dist/{cli.d.ts → module-sync/cli.d.ts} +0 -0
  44. /package/dist/{color-or-markdown.d.ts → module-sync/color-or-markdown.d.ts} +0 -0
  45. /package/dist/{errors.d.ts → module-sync/errors.d.ts} +0 -0
  46. /package/dist/{link.d.ts → module-sync/link.d.ts} +0 -0
  47. /package/dist/{link.js → module-sync/link.js} +0 -0
  48. /package/dist/{npm-cli.d.ts → module-sync/npm-cli.d.ts} +0 -0
  49. /package/dist/{npm-injection.d.ts → module-sync/npm-injection.d.ts} +0 -0
  50. /package/dist/{npx-cli.d.ts → module-sync/npx-cli.d.ts} +0 -0
  51. /package/dist/{path-resolve.d.ts → module-sync/path-resolve.d.ts} +0 -0
  52. /package/dist/{path-resolve.js → module-sync/path-resolve.js} +0 -0
  53. /package/dist/{settings.d.ts → module-sync/settings.d.ts} +0 -0
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var constants = require('./constants.js');
5
+ var require$$0 = require('@babel/runtime/helpers/interopRequireWildcard');
6
+ var require$$1 = require('node:path');
7
+ var require$$1$1 = require('@npmcli/promise-spawn');
8
+ var link = require('./link.js');
9
+
10
+ var npxCli$2 = {};
11
+
12
+ var npxCli$1 = {};
13
+
14
+ var _nodePath = require$$1;
15
+ var _promiseSpawn = require$$1$1;
16
+ var _constants = constants.constants;
17
+ var _link = link.link;
18
+ const npxPath = (0, _link.installLinks)(_constants.shadowBinPath, 'npx');
19
+ const injectionPath = _nodePath.join(_constants.distPath, 'npm-injection.js');
20
+ process.exitCode = 1;
21
+ const spawnPromise = _promiseSpawn(process.execPath, ['--disable-warning', 'ExperimentalWarning', '--require', injectionPath, npxPath, ...process.argv.slice(2)], {
22
+ stdio: 'inherit'
23
+ });
24
+ spawnPromise.process.on('exit', (code, signal) => {
25
+ if (signal) {
26
+ process.kill(process.pid, signal);
27
+ } else if (code !== null) {
28
+ process.exit(code);
29
+ }
30
+ });
31
+
32
+ (function (exports) {
33
+
34
+ var _interopRequireWildcard = require$$0.default;
35
+ Object.defineProperty(exports, "__esModule", {
36
+ value: true
37
+ });
38
+ var _exportNames = {};
39
+ Object.defineProperty(exports, "default", {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _npxCli.default;
43
+ }
44
+ });
45
+ var _npxCli = _interopRequireWildcard(npxCli$1, true);
46
+ Object.keys(_npxCli).forEach(function (key) {
47
+ if (key === "default" || key === "__esModule") return;
48
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
49
+ if (key in exports && exports[key] === _npxCli[key]) return;
50
+ Object.defineProperty(exports, key, {
51
+ enumerable: true,
52
+ get: function () {
53
+ return _npxCli[key];
54
+ }
55
+ });
56
+ });
57
+ } (npxCli$2));
58
+
59
+ var npxCli = /*@__PURE__*/constants.getDefaultExportFromCjs(npxCli$2);
60
+
61
+ module.exports = npxCli;
@@ -3,11 +3,7 @@ import { SocketSdk } from '@socketsecurity/sdk';
3
3
  declare function createDebugLogger(printDebugLogs?: boolean): typeof console.error;
4
4
  declare function isErrnoException(value: unknown): value is NodeJS.ErrnoException;
5
5
  declare function stringJoinWithSeparateFinalSeparator(list: (string | undefined)[], separator?: string): string;
6
- declare const API_V0_URL = "https://api.socket.dev/v0";
7
- declare const ENV: Readonly<{
8
- UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE: boolean;
9
- }>;
10
6
  declare const FREE_API_KEY = "sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api";
11
7
  declare function getDefaultKey(): string | undefined;
12
8
  declare function setupSdk(apiKey?: string | undefined, apiBaseUrl?: string | undefined, proxy?: string | undefined): Promise<SocketSdk>;
13
- export { createDebugLogger, isErrnoException, stringJoinWithSeparateFinalSeparator, API_V0_URL, ENV, FREE_API_KEY, getDefaultKey, setupSdk };
9
+ export { createDebugLogger, isErrnoException, stringJoinWithSeparateFinalSeparator, FREE_API_KEY, getDefaultKey, setupSdk };
@@ -0,0 +1,253 @@
1
+ 'use strict';
2
+
3
+ var require$$0 = require('@babel/runtime/helpers/interopRequireDefault');
4
+ var require$$1 = require('yoctocolors-cjs');
5
+ var require$$2 = require('is-unicode-supported');
6
+ var require$$3 = require('terminal-link');
7
+ var require$$1$2 = require('@inquirer/prompts');
8
+ var require$$2$2 = require('hpagent');
9
+ var require$$3$2 = require('is-interactive');
10
+ var require$$4 = require('@socketsecurity/sdk');
11
+ var constants = require('./constants.js');
12
+ var require$$0$1 = require('node:fs');
13
+ var require$$2$1 = require('node:os');
14
+ var require$$1$1 = require('node:path');
15
+ var require$$3$1 = require('@socketregistry/yocto-spinner');
16
+
17
+ var errors = {};
18
+
19
+ Object.defineProperty(errors, "__esModule", {
20
+ value: true
21
+ });
22
+ errors.InputError = errors.AuthError = void 0;
23
+ class AuthError extends Error {}
24
+ errors.AuthError = AuthError;
25
+ class InputError extends Error {
26
+ constructor(message, body) {
27
+ super(message);
28
+ this.body = body;
29
+ }
30
+ }
31
+ errors.InputError = InputError;
32
+
33
+ var colorOrMarkdown = {};
34
+
35
+ var _interopRequireDefault$1 = require$$0.default;
36
+ Object.defineProperty(colorOrMarkdown, "__esModule", {
37
+ value: true
38
+ });
39
+ colorOrMarkdown.logSymbols = colorOrMarkdown.ColorOrMarkdown = void 0;
40
+ var _yoctocolorsCjs = require$$1;
41
+ var _isUnicodeSupported = _interopRequireDefault$1(require$$2);
42
+ var _terminalLink = _interopRequireDefault$1(require$$3);
43
+ // From the 'log-symbols' module
44
+ const unicodeLogSymbols = {
45
+ __proto__: null,
46
+ info: _yoctocolorsCjs.blue('ℹ'),
47
+ success: _yoctocolorsCjs.green('✔'),
48
+ warning: _yoctocolorsCjs.yellow('⚠'),
49
+ error: _yoctocolorsCjs.red('✖')
50
+ };
51
+
52
+ // From the 'log-symbols' module
53
+ const fallbackLogSymbols = {
54
+ __proto__: null,
55
+ info: _yoctocolorsCjs.blue('i'),
56
+ success: _yoctocolorsCjs.green('√'),
57
+ warning: _yoctocolorsCjs.yellow('‼'),
58
+ error: _yoctocolorsCjs.red('×')
59
+ };
60
+
61
+ // From the 'log-symbols' module
62
+ const logSymbols = colorOrMarkdown.logSymbols = (0, _isUnicodeSupported.default)() ? unicodeLogSymbols : fallbackLogSymbols;
63
+ const markdownLogSymbols = {
64
+ __proto__: null,
65
+ info: ':information_source:',
66
+ error: ':stop_sign:',
67
+ success: ':white_check_mark:',
68
+ warning: ':warning:'
69
+ };
70
+ class ColorOrMarkdown {
71
+ constructor(useMarkdown) {
72
+ this.useMarkdown = !!useMarkdown;
73
+ }
74
+ header(text, level = 1) {
75
+ return this.useMarkdown ? `\n${''.padStart(level, '#')} ${text}\n` : _yoctocolorsCjs.underline(`\n${level === 1 ? _yoctocolorsCjs.bold(text) : text}\n`);
76
+ }
77
+ bold(text) {
78
+ return this.useMarkdown ? `**${text}**` : _yoctocolorsCjs.bold(`${text}`);
79
+ }
80
+ italic(text) {
81
+ return this.useMarkdown ? `_${text}_` : _yoctocolorsCjs.italic(`${text}`);
82
+ }
83
+ hyperlink(text, url, {
84
+ fallback = true,
85
+ fallbackToUrl
86
+ } = {}) {
87
+ if (!url) return text;
88
+ return this.useMarkdown ? `[${text}](${url})` : (0, _terminalLink.default)(text, url, {
89
+ fallback: fallbackToUrl ? (_text, url) => url : fallback
90
+ });
91
+ }
92
+ list(items) {
93
+ const indentedContent = items.map(item => this.indent(item).trimStart());
94
+ return this.useMarkdown ? `* ${indentedContent.join('\n* ')}\n` : `${indentedContent.join('\n')}\n`;
95
+ }
96
+ get logSymbols() {
97
+ return this.useMarkdown ? markdownLogSymbols : logSymbols;
98
+ }
99
+ indent(text, level = 1) {
100
+ const indent = ''.padStart(level * 2, ' ');
101
+ return indent + text.split('\n').join('\n' + indent);
102
+ }
103
+ json(value) {
104
+ return this.useMarkdown ? '```json\n' + JSON.stringify(value) + '\n```' : JSON.stringify(value);
105
+ }
106
+ }
107
+ colorOrMarkdown.ColorOrMarkdown = ColorOrMarkdown;
108
+
109
+ var misc = {};
110
+
111
+ Object.defineProperty(misc, "__esModule", {
112
+ value: true
113
+ });
114
+ misc.createDebugLogger = createDebugLogger;
115
+ misc.isErrnoException = isErrnoException;
116
+ misc.stringJoinWithSeparateFinalSeparator = stringJoinWithSeparateFinalSeparator;
117
+ var _colorOrMarkdown = colorOrMarkdown;
118
+ function createDebugLogger(printDebugLogs) {
119
+ return printDebugLogs ? (...params) => console.error(_colorOrMarkdown.logSymbols.info, ...params) : () => {};
120
+ }
121
+ function isErrnoException(value) {
122
+ if (!(value instanceof Error)) {
123
+ return false;
124
+ }
125
+ return value.code !== undefined;
126
+ }
127
+ function stringJoinWithSeparateFinalSeparator(list, separator = ' and ') {
128
+ const values = list.filter(value => !!value);
129
+ if (values.length < 2) {
130
+ return values[0] || '';
131
+ }
132
+ const finalValue = values.pop();
133
+ return values.join(', ') + separator + finalValue;
134
+ }
135
+
136
+ var sdk = {};
137
+
138
+ var settings$1 = {};
139
+
140
+ Object.defineProperty(settings$1, "__esModule", {
141
+ value: true
142
+ });
143
+ settings$1.getSetting = getSetting;
144
+ settings$1.updateSetting = updateSetting;
145
+ var _nodeFs = require$$0$1;
146
+ var _nodeOs = require$$2$1;
147
+ var _nodePath = require$$1$1;
148
+ var _yoctoSpinner = require$$3$1;
149
+ let dataHome = process.platform === 'win32' ? process.env['LOCALAPPDATA'] : process.env['XDG_DATA_HOME'];
150
+ if (!dataHome) {
151
+ if (process.platform === 'win32') throw new Error('missing %LOCALAPPDATA%');
152
+ const home = _nodeOs.homedir();
153
+ dataHome = _nodePath.join(home, ...(process.platform === 'darwin' ? ['Library', 'Application Support'] : ['.local', 'share']));
154
+ }
155
+ const settingsPath = _nodePath.join(dataHome, 'socket', 'settings');
156
+ let settings = {};
157
+ if ((0, _nodeFs.existsSync)(settingsPath)) {
158
+ const raw = (0, _nodeFs.readFileSync)(settingsPath, 'utf-8');
159
+ try {
160
+ settings = JSON.parse(Buffer.from(raw, 'base64').toString());
161
+ } catch {
162
+ _yoctoSpinner().warning(`Failed to parse settings at ${settingsPath}`);
163
+ }
164
+ } else {
165
+ (0, _nodeFs.mkdirSync)(_nodePath.dirname(settingsPath), {
166
+ recursive: true
167
+ });
168
+ }
169
+ function getSetting(key) {
170
+ return settings[key];
171
+ }
172
+ let pendingSave = false;
173
+ function updateSetting(key, value) {
174
+ settings[key] = value;
175
+ if (!pendingSave) {
176
+ pendingSave = true;
177
+ process.nextTick(() => {
178
+ pendingSave = false;
179
+ (0, _nodeFs.writeFileSync)(settingsPath, Buffer.from(JSON.stringify(settings)).toString('base64'));
180
+ });
181
+ }
182
+ }
183
+
184
+ var _interopRequireDefault = require$$0.default;
185
+ Object.defineProperty(sdk, "__esModule", {
186
+ value: true
187
+ });
188
+ sdk.FREE_API_KEY = void 0;
189
+ sdk.getDefaultKey = getDefaultKey;
190
+ sdk.setupSdk = setupSdk;
191
+ var _prompts = require$$1$2;
192
+ var _hpagent = require$$2$2;
193
+ var _isInteractive = _interopRequireDefault(require$$3$2);
194
+ var _sdk = require$$4;
195
+ var _constants = constants.constants;
196
+ var _errors = errors;
197
+ var _settings = settings$1;
198
+ sdk.FREE_API_KEY = 'sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api';
199
+
200
+ // This API key should be stored globally for the duration of the CLI execution
201
+ let defaultKey;
202
+ function getDefaultKey() {
203
+ defaultKey = process.env['SOCKET_SECURITY_API_KEY'] || (0, _settings.getSetting)('apiKey') || defaultKey;
204
+ return defaultKey;
205
+ }
206
+
207
+ // The API server that should be used for operations
208
+ let defaultAPIBaseUrl;
209
+ function getDefaultAPIBaseUrl() {
210
+ defaultAPIBaseUrl = process.env['SOCKET_SECURITY_API_BASE_URL'] || (0, _settings.getSetting)('apiBaseUrl') || undefined;
211
+ return defaultAPIBaseUrl;
212
+ }
213
+
214
+ // The API server that should be used for operations
215
+ let defaultApiProxy;
216
+ function getDefaultHTTPProxy() {
217
+ defaultApiProxy = process.env['SOCKET_SECURITY_API_PROXY'] || (0, _settings.getSetting)('apiProxy') || undefined;
218
+ return defaultApiProxy;
219
+ }
220
+ async function setupSdk(apiKey = getDefaultKey(), apiBaseUrl = getDefaultAPIBaseUrl(), proxy = getDefaultHTTPProxy()) {
221
+ if (typeof apiKey !== 'string' && (0, _isInteractive.default)()) {
222
+ apiKey = await (0, _prompts.password)({
223
+ message: 'Enter your Socket.dev API key (not saved, use socket login to persist)'
224
+ });
225
+ defaultKey = apiKey;
226
+ }
227
+ if (!apiKey) {
228
+ throw new _errors.AuthError('You need to provide an API key');
229
+ }
230
+ let agent;
231
+ if (proxy) {
232
+ agent = {
233
+ http: new _hpagent.HttpProxyAgent({
234
+ proxy
235
+ }),
236
+ https: new _hpagent.HttpsProxyAgent({
237
+ proxy
238
+ })
239
+ };
240
+ }
241
+ const sdkOptions = {
242
+ agent,
243
+ baseUrl: apiBaseUrl,
244
+ userAgent: (0, _sdk.createUserAgentFromPkgJson)(require(_constants.rootPkgJsonPath))
245
+ };
246
+ return new _sdk.SocketSdk(apiKey || '', sdkOptions);
247
+ }
248
+
249
+ exports.colorOrMarkdown = colorOrMarkdown;
250
+ exports.errors = errors;
251
+ exports.misc = misc;
252
+ exports.sdk = sdk;
253
+ exports.settings = settings$1;
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts","../../src/utils/formatting.ts","../../src/flags.ts","../../src/utils/meow-with-subcommands.ts","../../src/commands/cdxgen.ts","../../src/utils/api-helpers.ts","../../src/utils/objects.ts","../../src/utils/format-issues.ts","../../src/commands/info.ts","../../src/commands/login.ts","../../src/commands/logout.ts","../../src/commands/npm.ts","../../src/commands/npx.ts","../../src/utils/fs.ts","../../src/utils/package-manager-detector.ts","../../src/commands/optimize.ts","../../src/commands/organization.ts","../../src/commands/raw-npm.ts","../../src/commands/raw-npx.ts","../../src/commands/report/view.ts","../../src/commands/report/create.ts","../../src/commands/report/index.ts","../../src/commands/wrapper.ts","../../src/commands/scan/create.ts","../../src/commands/scan/delete.ts","../../src/commands/scan/list.ts","../../src/commands/scan/metadata.ts","../../src/commands/scan/stream.ts","../../src/commands/scan/index.ts","../../src/commands/audit-log.ts","../../src/commands/repos/create.ts","../../src/commands/repos/delete.ts","../../src/commands/repos/list.ts","../../src/commands/repos/update.ts","../../src/commands/repos/view.ts","../../src/commands/repos/index.ts","../../src/commands/dependencies.ts","../../src/commands/analytics.ts","../../src/commands/diff-scan/get.ts","../../src/commands/diff-scan/index.ts","../../src/commands/threat-feed.ts","../../src/commands/index.ts"],"names":[],"mappings":""}