snyk 1.1113.0 → 1.1114.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/bin/snyk +1 -1
- package/package.json +44 -17
- package/.snyk +0 -20
- package/jest.config.js +0 -3
- package/src/bootstrap.ts +0 -27
- package/src/common.ts +0 -368
- package/src/generated/binary-deployments.json +0 -16
- package/src/generated/sha256sums.txt +0 -10
- package/src/generated/version +0 -1
- package/src/index.ts +0 -66
- package/test/acceptance/basic.spec.ts +0 -105
- package/test/unit/common.spec.ts +0 -311
- package/test/util/prepareEnvironment.ts +0 -84
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -4163
- package/wrapper_dist/bootstrap.d.ts +0 -1
- package/wrapper_dist/bootstrap.js +0 -23
- package/wrapper_dist/bootstrap.js.map +0 -1
- package/wrapper_dist/common.d.ts +0 -26
- package/wrapper_dist/common.js +0 -289
- package/wrapper_dist/common.js.map +0 -1
- package/wrapper_dist/generated/binary-deployments.json +0 -16
- package/wrapper_dist/generated/sha256sums.txt +0 -10
- package/wrapper_dist/generated/version +0 -1
- package/wrapper_dist/index.d.ts +0 -2
- package/wrapper_dist/index.js +0 -53
- package/wrapper_dist/index.js.map +0 -1
package/bin/snyk
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require('../
|
|
2
|
+
require('../dist/cli/index.js');
|
package/package.json
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snyk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1114.0",
|
|
4
4
|
"description": "snyk library and cli utility",
|
|
5
5
|
"files": [
|
|
6
|
-
"
|
|
6
|
+
"help/cli-commands",
|
|
7
|
+
"dist",
|
|
8
|
+
"bin",
|
|
9
|
+
"pysrc",
|
|
10
|
+
"config.default.json",
|
|
11
|
+
"SECURITY.md",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"README.md"
|
|
7
14
|
],
|
|
8
15
|
"directories": {
|
|
9
16
|
"lib": "src",
|
|
10
|
-
"test": "test"
|
|
17
|
+
"test": "test",
|
|
18
|
+
"doc": "help/cli-commands"
|
|
11
19
|
},
|
|
12
20
|
"bin": {
|
|
13
21
|
"snyk": "bin/snyk"
|
|
@@ -15,11 +23,27 @@
|
|
|
15
23
|
"engines": {
|
|
16
24
|
"node": ">=12"
|
|
17
25
|
},
|
|
26
|
+
"workspaces": [
|
|
27
|
+
"packages/*"
|
|
28
|
+
],
|
|
18
29
|
"scripts": {
|
|
19
|
-
"clean": "npx rimraf
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
30
|
+
"clean": "npx rimraf node_modules dist binary-releases test-results *.tgz tsconfig.tsbuildinfo .eslintcache pysrc packages/*/node_modules packages/*/dist packages/*/tsconfig.tsbuildinfo packages/*/*.tgz",
|
|
31
|
+
"format": "prettier --write '**/*.{js,ts,json,yaml,yml,md}' && npm run lint:js -- --fix",
|
|
32
|
+
"format:changes": "./scripts/format/prettier-changes.sh",
|
|
33
|
+
"lint": "npm-run-all --serial --continue-on-error lint:*",
|
|
34
|
+
"lint:js": "eslint --quiet --color --cache '**/*.{js,ts}'",
|
|
35
|
+
"lint:formatting": "prettier --check '**/*.{js,ts,json,yaml,yml,md}'",
|
|
36
|
+
"build": "patch-package && npm run build:dev",
|
|
37
|
+
"build:dev": "patch-package && npm run build --workspaces && npm run build-cli:dev",
|
|
38
|
+
"build:prod": "patch-package && npm run build --workspaces && npm run build-cli:prod",
|
|
39
|
+
"build-cli:dev": "node --max-old-space-size=8192 node_modules/webpack/bin/webpack.js --config webpack.dev.ts",
|
|
40
|
+
"build-cli:prod": "node --max-old-space-size=8192 node_modules/webpack/bin/webpack.js --config webpack.prod.ts",
|
|
41
|
+
"watch": "npm run build-cli:dev -- --watch",
|
|
42
|
+
"test": "npm run test:unit && npm run test:acceptance && npm run test:tap",
|
|
43
|
+
"test:unit": "jest --runInBand --testPathPattern '/test(/jest)?/unit/'",
|
|
44
|
+
"test:acceptance": "jest --runInBand --testPathPattern '/test(/jest)?/acceptance/'",
|
|
45
|
+
"test:tap": "tap -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register test/tap/*.test.* ",
|
|
46
|
+
"test:smoke": "./scripts/run-smoke-tests-locally.sh"
|
|
23
47
|
},
|
|
24
48
|
"keywords": [
|
|
25
49
|
"security",
|
|
@@ -34,22 +58,25 @@
|
|
|
34
58
|
],
|
|
35
59
|
"author": "snyk.io",
|
|
36
60
|
"license": "Apache-2.0",
|
|
61
|
+
"dependencies": {},
|
|
62
|
+
"devDependencies": {},
|
|
37
63
|
"repository": {
|
|
38
64
|
"type": "git",
|
|
39
65
|
"url": "https://github.com/snyk/snyk.git"
|
|
40
66
|
},
|
|
67
|
+
"pkg": {
|
|
68
|
+
"scripts": [
|
|
69
|
+
"dist/**/*.js",
|
|
70
|
+
"bin/snyk"
|
|
71
|
+
],
|
|
72
|
+
"assets": [
|
|
73
|
+
"config.default.json",
|
|
74
|
+
"dist",
|
|
75
|
+
"help"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
41
78
|
"publishConfig": {
|
|
42
79
|
"registry": "https://registry.npmjs.org/",
|
|
43
80
|
"access": "public"
|
|
44
|
-
},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"jest": "^29.4.1",
|
|
47
|
-
"rimraf": "^4.1.2",
|
|
48
|
-
"ts-jest": "^29.0.5",
|
|
49
|
-
"typescript": "^4.9.5"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@sentry/node": "^7.36.0",
|
|
53
|
-
"global-agent": "^3.0.0"
|
|
54
81
|
}
|
|
55
82
|
}
|
package/.snyk
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
|
2
|
-
version: v1.25.0
|
|
3
|
-
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
|
|
4
|
-
ignore:
|
|
5
|
-
SNYK-JS-SNYK-3037342:
|
|
6
|
-
- '*':
|
|
7
|
-
reason: Based on default version number
|
|
8
|
-
expires: 2030-01-10T00:00:00.000Z
|
|
9
|
-
created: 2023-03-03T14:26:54.682Z
|
|
10
|
-
SNYK-JS-SNYK-3038622:
|
|
11
|
-
- '*':
|
|
12
|
-
reason: Based on default version number
|
|
13
|
-
expires: 2030-01-10T00:00:00.000Z
|
|
14
|
-
created: 2023-03-03T14:32:41.690Z
|
|
15
|
-
SNYK-JS-SNYK-3111871:
|
|
16
|
-
- '*':
|
|
17
|
-
reason: Based on default version number
|
|
18
|
-
expires: 2030-01-10T00:00:00.000Z
|
|
19
|
-
created: 2023-03-03T14:33:35.717Z
|
|
20
|
-
patch: {}
|
package/jest.config.js
DELETED
package/src/bootstrap.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as common from './common';
|
|
2
|
-
import * as process from 'process';
|
|
3
|
-
|
|
4
|
-
const errorContextMessage = 'Download Error';
|
|
5
|
-
|
|
6
|
-
(async () => {
|
|
7
|
-
try {
|
|
8
|
-
const config = common.getCurrentConfiguration();
|
|
9
|
-
const executable = config.getLocalLocation();
|
|
10
|
-
|
|
11
|
-
if (process.argv.includes('exec')) {
|
|
12
|
-
const filenameShasum = config.getShasumFile();
|
|
13
|
-
const downloadUrl = config.getDownloadLocation();
|
|
14
|
-
|
|
15
|
-
const downloadError = await common.downloadExecutable(
|
|
16
|
-
downloadUrl,
|
|
17
|
-
executable,
|
|
18
|
-
filenameShasum,
|
|
19
|
-
);
|
|
20
|
-
if (downloadError !== undefined) {
|
|
21
|
-
throw downloadError;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
} catch (err) {
|
|
25
|
-
await common.logError(errorContextMessage, err);
|
|
26
|
-
}
|
|
27
|
-
})();
|
package/src/common.ts
DELETED
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
// must be set before we import 'global-agent/bootstrap'
|
|
2
|
-
process.env.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE = '';
|
|
3
|
-
process.env.HTTPS_PROXY =
|
|
4
|
-
process.env.HTTPS_PROXY ?? process.env.https_proxy ?? '';
|
|
5
|
-
process.env.HTTP_PROXY = process.env.HTTP_PROXY ?? process.env.http_proxy ?? '';
|
|
6
|
-
process.env.NO_PROXY = process.env.NO_PROXY ?? process.env.no_proxy ?? '';
|
|
7
|
-
|
|
8
|
-
import 'global-agent/bootstrap';
|
|
9
|
-
import * as path from 'path';
|
|
10
|
-
import * as os from 'os';
|
|
11
|
-
import * as fs from 'fs';
|
|
12
|
-
import { spawnSync } from 'child_process';
|
|
13
|
-
import * as https from 'https';
|
|
14
|
-
import { createHash } from 'crypto';
|
|
15
|
-
import * as Sentry from '@sentry/node';
|
|
16
|
-
|
|
17
|
-
export const versionFile = path.join(__dirname, 'generated', 'version');
|
|
18
|
-
export const shasumFile = path.join(__dirname, 'generated', 'sha256sums.txt');
|
|
19
|
-
const binaryDeploymentsFilePath = path.join(
|
|
20
|
-
__dirname,
|
|
21
|
-
'generated',
|
|
22
|
-
'binary-deployments.json',
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export class WrapperConfiguration {
|
|
26
|
-
private version: string;
|
|
27
|
-
private binaryName: string;
|
|
28
|
-
private expectedSha256sum: string;
|
|
29
|
-
|
|
30
|
-
public constructor(
|
|
31
|
-
version: string,
|
|
32
|
-
binaryName: string,
|
|
33
|
-
expectedSha256sum: string,
|
|
34
|
-
) {
|
|
35
|
-
this.version = version;
|
|
36
|
-
this.binaryName = binaryName;
|
|
37
|
-
this.expectedSha256sum = expectedSha256sum;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public getVersion(): string {
|
|
41
|
-
return this.version;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public getBinaryName(): string {
|
|
45
|
-
return this.binaryName;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public getDownloadLocation(): string {
|
|
49
|
-
const baseUrl = 'https://static.snyk.io/cli/v';
|
|
50
|
-
return baseUrl + this.version + '/' + this.binaryName;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public getLocalLocation(): string {
|
|
54
|
-
const currentFolder = __dirname;
|
|
55
|
-
return path.join(currentFolder, this.binaryName);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public getShasumFile(): string {
|
|
59
|
-
return this.expectedSha256sum;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function determineBinaryName(platform: string, arch: string): string {
|
|
64
|
-
let osname = platform;
|
|
65
|
-
let archname = arch;
|
|
66
|
-
|
|
67
|
-
switch (osname) {
|
|
68
|
-
case 'win32':
|
|
69
|
-
osname = 'windows';
|
|
70
|
-
break;
|
|
71
|
-
case 'linux': {
|
|
72
|
-
let isAlpine = false;
|
|
73
|
-
try {
|
|
74
|
-
const result = spawnSync('cat /etc/os-release', { shell: true });
|
|
75
|
-
isAlpine = result.stdout
|
|
76
|
-
.toString()
|
|
77
|
-
.toLowerCase()
|
|
78
|
-
.includes('id=alpine');
|
|
79
|
-
} catch {
|
|
80
|
-
isAlpine = false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (isAlpine) {
|
|
84
|
-
osname = 'alpine';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
switch (arch) {
|
|
92
|
-
case 'x64':
|
|
93
|
-
case 'amd64':
|
|
94
|
-
archname = 'amd64';
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const supportedPlatforms = require(binaryDeploymentsFilePath);
|
|
99
|
-
const binaryName = supportedPlatforms[osname][archname];
|
|
100
|
-
|
|
101
|
-
if (binaryName === undefined) {
|
|
102
|
-
const defaultErrorMsg =
|
|
103
|
-
' The current platform (' +
|
|
104
|
-
osname +
|
|
105
|
-
' ' +
|
|
106
|
-
archname +
|
|
107
|
-
') is not supported by Snyk.\n' +
|
|
108
|
-
' You may want to consider using Docker to run Snyk, for details see: https://docs.snyk.io/snyk-cli/install-the-snyk-cli#snyk-cli-in-a-docker-image\n' +
|
|
109
|
-
' If you experience errors please check http://support.snyk.io/.';
|
|
110
|
-
throw Error(getWarningMessage(defaultErrorMsg));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return binaryName;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function getCurrentVersion(filename: string): string {
|
|
117
|
-
try {
|
|
118
|
-
const version = fs.readFileSync(filename);
|
|
119
|
-
return version.toString().trim();
|
|
120
|
-
} catch {
|
|
121
|
-
return '';
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function getCurrentSha256sum(
|
|
126
|
-
binaryName: string,
|
|
127
|
-
filename: string,
|
|
128
|
-
): string {
|
|
129
|
-
try {
|
|
130
|
-
const allsums = fs.readFileSync(filename).toString();
|
|
131
|
-
const re = new RegExp('^([a-zA-Z0-9]+)[\\s\\*]+' + binaryName + '$', 'mig');
|
|
132
|
-
const result = re.exec(allsums);
|
|
133
|
-
if (result) {
|
|
134
|
-
return result[1];
|
|
135
|
-
}
|
|
136
|
-
} catch {
|
|
137
|
-
//
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return 'unknown-shasum-' + binaryName;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export function getCurrentConfiguration(): WrapperConfiguration {
|
|
144
|
-
const binaryName = determineBinaryName(os.platform(), os.arch());
|
|
145
|
-
const version = getCurrentVersion(versionFile);
|
|
146
|
-
const expectedSha256sum = getCurrentSha256sum(binaryName, shasumFile);
|
|
147
|
-
return new WrapperConfiguration(version, binaryName, expectedSha256sum);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export function getCliArguments(inputArgv: string[]): string[] {
|
|
151
|
-
const cliArguments = inputArgv.slice(2);
|
|
152
|
-
return cliArguments;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function debugEnabled(cliArguments: string[]): boolean {
|
|
156
|
-
let debugIndex = cliArguments.indexOf('--debug');
|
|
157
|
-
|
|
158
|
-
if (debugIndex < 0) {
|
|
159
|
-
debugIndex = cliArguments.indexOf('-d');
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return debugIndex >= 0;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function runWrapper(executable: string, cliArguments: string[]): number {
|
|
166
|
-
interface SpawnError extends Error {
|
|
167
|
-
errno: number;
|
|
168
|
-
code: string;
|
|
169
|
-
syscall: string;
|
|
170
|
-
path: string;
|
|
171
|
-
spawnargs: string[];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const debug = debugEnabled(cliArguments);
|
|
175
|
-
|
|
176
|
-
if (debug) {
|
|
177
|
-
console.error('Executing: ' + executable + ' ' + cliArguments.join(' '));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const res = spawnSync(executable, cliArguments, {
|
|
181
|
-
shell: false,
|
|
182
|
-
stdio: 'inherit',
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
if (res.status !== null) {
|
|
186
|
-
if (debug) {
|
|
187
|
-
console.error(res);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return res.status;
|
|
191
|
-
} else {
|
|
192
|
-
console.error(res);
|
|
193
|
-
if (!formatErrorMessage((res.error as SpawnError).code)) {
|
|
194
|
-
console.error('Failed to spawn child process. (' + executable + ')');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return 2;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export function getWarningMessage(message: string): string {
|
|
202
|
-
return `\n------------------------------- Warning -------------------------------\n${message}\n------------------------------- Warning -------------------------------\n`;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export function formatErrorMessage(message: string): boolean {
|
|
206
|
-
const eaccesWarning =
|
|
207
|
-
"You don't have the permissions to install Snyk. Please try the following options:\n" +
|
|
208
|
-
'* If you are installing with increased privileges (for example sudo), try adding --unsafe-perm as a parameter to npm install\n' +
|
|
209
|
-
'* If you run NPM <= 6, please upgrade to a later version.\n' +
|
|
210
|
-
'If the problems persist please check http://support.snyk.io/.';
|
|
211
|
-
|
|
212
|
-
const certificateError =
|
|
213
|
-
'If you are running Snyk in an environment that intercepts SSL traffic, please specify\n' +
|
|
214
|
-
'your custom CA certificates via the NODE_EXTRA_CA_CERTS environment variable.\n' +
|
|
215
|
-
'See https://nodejs.org/api/cli.html#node_extra_ca_certsfile for additional information.';
|
|
216
|
-
|
|
217
|
-
const degradedCLIWarning =
|
|
218
|
-
'You are currently running a degraded version of the Snyk CLI.\n' +
|
|
219
|
-
'As a result, some features of the CLI will be unavailable.\n' +
|
|
220
|
-
'For information on how to resolve this, please see this article: https://docs.snyk.io/snyk-cli/installing-snyk-cli-as-a-binary-via-npm\n' +
|
|
221
|
-
'For any assistance, please check http://support.snyk.io/.';
|
|
222
|
-
|
|
223
|
-
let warning = '';
|
|
224
|
-
|
|
225
|
-
if (message.includes('EACCES')) {
|
|
226
|
-
warning = eaccesWarning;
|
|
227
|
-
} else if (message.includes('certificate')) {
|
|
228
|
-
warning = certificateError;
|
|
229
|
-
} else if (message.includes('legacy-cli')) {
|
|
230
|
-
warning = degradedCLIWarning;
|
|
231
|
-
} else {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
console.error(getWarningMessage(warning));
|
|
236
|
-
return true;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export function downloadExecutable(
|
|
240
|
-
downloadUrl: string,
|
|
241
|
-
filename: string,
|
|
242
|
-
filenameShasum: string,
|
|
243
|
-
): Promise<Error | undefined> {
|
|
244
|
-
return new Promise<Error | undefined>(function(resolve) {
|
|
245
|
-
const options = new URL(downloadUrl);
|
|
246
|
-
const temp = path.join(__dirname, Date.now().toString());
|
|
247
|
-
const fileStream = fs.createWriteStream(temp);
|
|
248
|
-
fileStream.on('error', (e) => {
|
|
249
|
-
cleanupAfterError(e);
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
const cleanupAfterError = (error: Error) => {
|
|
253
|
-
try {
|
|
254
|
-
fs.unlinkSync(temp);
|
|
255
|
-
} catch (e) {
|
|
256
|
-
// ignoring any error during cleaning up after an error
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
resolve(error);
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
console.error(
|
|
263
|
-
"Downloading from '" + downloadUrl + "' to '" + filename + "'",
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
const req = https.request(options, (res) => {
|
|
267
|
-
const shasum = createHash('sha256');
|
|
268
|
-
|
|
269
|
-
shasum.on('error', cleanupAfterError);
|
|
270
|
-
res.on('error', cleanupAfterError);
|
|
271
|
-
res.on('end', () => {
|
|
272
|
-
// compare shasums
|
|
273
|
-
const actualShasum = shasum.digest('hex');
|
|
274
|
-
|
|
275
|
-
const debugMessage =
|
|
276
|
-
'Shasums:\n- actual: ' +
|
|
277
|
-
actualShasum +
|
|
278
|
-
'\n- expected: ' +
|
|
279
|
-
filenameShasum;
|
|
280
|
-
|
|
281
|
-
if (filenameShasum && actualShasum != filenameShasum) {
|
|
282
|
-
fileStream.close();
|
|
283
|
-
shasum.end();
|
|
284
|
-
cleanupAfterError(
|
|
285
|
-
Error('Shasum comparison failed!\n' + debugMessage),
|
|
286
|
-
);
|
|
287
|
-
} else {
|
|
288
|
-
console.error(debugMessage);
|
|
289
|
-
|
|
290
|
-
// finally rename the file and change permissions
|
|
291
|
-
fs.renameSync(temp, filename);
|
|
292
|
-
fs.chmodSync(filename, 0o755);
|
|
293
|
-
console.error('Downloaded successfull! ');
|
|
294
|
-
|
|
295
|
-
shasum.end();
|
|
296
|
-
fileStream.close();
|
|
297
|
-
resolve(undefined);
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
res.pipe(fileStream);
|
|
302
|
-
res.pipe(shasum);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
req.on('error', (e) => {
|
|
306
|
-
cleanupAfterError(e);
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
req.on('response', (incoming) => {
|
|
310
|
-
if (
|
|
311
|
-
incoming.statusCode &&
|
|
312
|
-
!(200 <= incoming.statusCode && incoming.statusCode < 300)
|
|
313
|
-
) {
|
|
314
|
-
req.destroy();
|
|
315
|
-
cleanupAfterError(
|
|
316
|
-
Error(
|
|
317
|
-
'Download failed! Server Response: ' +
|
|
318
|
-
incoming.statusCode +
|
|
319
|
-
' ' +
|
|
320
|
-
incoming.statusMessage,
|
|
321
|
-
),
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
req.end();
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
export async function logError(
|
|
331
|
-
context: string,
|
|
332
|
-
err,
|
|
333
|
-
printToConsole = true,
|
|
334
|
-
): Promise<void> {
|
|
335
|
-
if (isAnalyticsEnabled()) {
|
|
336
|
-
// init error reporting
|
|
337
|
-
const version = getCurrentVersion(versionFile);
|
|
338
|
-
Sentry.init({
|
|
339
|
-
dsn:
|
|
340
|
-
'https://3e845233db8c4f43b4c4b9245f1d7bd6@o30291.ingest.sentry.io/4504599528079360',
|
|
341
|
-
release: version,
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
// report error
|
|
345
|
-
const sentryError = new Error('[' + context + '] ' + err.message);
|
|
346
|
-
sentryError.stack = err.stack;
|
|
347
|
-
Sentry.captureException(sentryError);
|
|
348
|
-
await Sentry.close();
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// finally log the error to the console as well
|
|
352
|
-
if (printToConsole) {
|
|
353
|
-
console.error('\n');
|
|
354
|
-
console.error(err);
|
|
355
|
-
formatErrorMessage(err.message);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
export function isAnalyticsEnabled(): boolean {
|
|
360
|
-
if (
|
|
361
|
-
process.env.snyk_disable_analytics == '1' ||
|
|
362
|
-
process.env.SNYK_DISABLE_ANALYTICS == '1'
|
|
363
|
-
) {
|
|
364
|
-
return false;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return true;
|
|
368
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
25edd6c8122d4ae543e70011ee7c12a9799c4ed27e95fe11fb6a09d5a3eda7e3 docker-mac-signed-bundle.tar.gz
|
|
2
|
-
2c6e639b79589e5f4df4318de7f75b46fdfb8bcb9f8167e466292ea1ec5927cf snyk-alpine
|
|
3
|
-
d3e2b45e1e578079170b0d42300ac8bdf35ab894cb612186e78c60c5d85b8ee8 snyk-fix.tgz
|
|
4
|
-
762089b89140f316648fa581702c3d8c7f735b5ab36f19b481dc538262ee250b snyk-for-docker-desktop-darwin-arm64.tar.gz
|
|
5
|
-
151505e83102f2aef3e3bfb1e8618bfe3b27d13070f22a18e7cfc37bf4b030b3 snyk-for-docker-desktop-darwin-x64.tar.gz
|
|
6
|
-
e4c8f2afb7d4885e6d4da6286092587a3f2c912f4720aeb69e2a316196cc0e7b snyk-linux-arm64
|
|
7
|
-
9c4ad8cc87b44c48500fddcfa08dae580b13c91f9b700251e5eca3a155c570b2 snyk-linux
|
|
8
|
-
a330b76362f95d8cbd88673795f007b2d97602e1ef60273151f619ba3219c5b8 snyk-macos
|
|
9
|
-
a213b276e3f5f3b45fd30166d8d4b5f83700dc4884e90881fd4318763b3fdd6d snyk-protect.tgz
|
|
10
|
-
10dd32be5d5ba5a669c037900f58cc523d568f62c5167b09cb708957a5e320cf snyk-win.exe
|
package/src/generated/version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.1113.0
|
package/src/index.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { argv } from 'process';
|
|
4
|
-
import * as common from './common';
|
|
5
|
-
import * as fs from 'fs';
|
|
6
|
-
import * as path from 'path';
|
|
7
|
-
|
|
8
|
-
const errorContextMessage = 'Runtime';
|
|
9
|
-
const fallbackScript = path.join(__dirname, '..', 'dist', 'cli', 'index.js');
|
|
10
|
-
const legacyCLIflag = '--legacy-cli';
|
|
11
|
-
|
|
12
|
-
function run(executable: string): number {
|
|
13
|
-
let cliArguments = common.getCliArguments(argv);
|
|
14
|
-
|
|
15
|
-
if (executable.endsWith('.js')) {
|
|
16
|
-
cliArguments = [executable].concat(cliArguments);
|
|
17
|
-
executable = argv[0]; // node runtime
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const exitCode = common.runWrapper(executable, cliArguments);
|
|
21
|
-
return exitCode;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
(async () => {
|
|
25
|
-
let fallbackToLegacyCLI = argv.includes(legacyCLIflag);
|
|
26
|
-
|
|
27
|
-
if (fallbackToLegacyCLI === false) {
|
|
28
|
-
try {
|
|
29
|
-
const config = common.getCurrentConfiguration();
|
|
30
|
-
const executable = config.getLocalLocation();
|
|
31
|
-
|
|
32
|
-
if (!fs.existsSync(executable)) {
|
|
33
|
-
console.error("Executable doesn't exist, trying to download.");
|
|
34
|
-
|
|
35
|
-
const downloadError = await common.downloadExecutable(
|
|
36
|
-
config.getDownloadLocation(),
|
|
37
|
-
executable,
|
|
38
|
-
config.getShasumFile(),
|
|
39
|
-
);
|
|
40
|
-
if (downloadError !== undefined) {
|
|
41
|
-
throw downloadError;
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
process.exit(run(executable));
|
|
45
|
-
}
|
|
46
|
-
} catch (error) {
|
|
47
|
-
fallbackToLegacyCLI = true;
|
|
48
|
-
await common.logError(errorContextMessage, error);
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
// if --legacy-clli is enabled create a log messaeg
|
|
52
|
-
await common.logError(
|
|
53
|
-
errorContextMessage,
|
|
54
|
-
Error(legacyCLIflag + 'is set'),
|
|
55
|
-
false,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (fallbackToLegacyCLI) {
|
|
60
|
-
common.formatErrorMessage('legacy-cli');
|
|
61
|
-
const exitCode = run(fallbackScript);
|
|
62
|
-
common.formatErrorMessage('legacy-cli');
|
|
63
|
-
|
|
64
|
-
process.exit(exitCode);
|
|
65
|
-
}
|
|
66
|
-
})();
|