diff --git a/package-lock.json b/package-lock.json index 1b8d4c56bf..88bd3bd722 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ ], "dependencies": { "@open-policy-agent/opa-wasm": "^1.6.0", + "@sentry/node": "^7.34.0", "@snyk/cli-interface": "2.11.0", "@snyk/cloud-config-parser": "^1.14.5", "@snyk/code-client": "^4.15.0", @@ -1843,6 +1844,87 @@ "node": ">=10.0.0" } }, + "node_modules/@sentry/core": { + "version": "7.34.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.34.0.tgz", + "integrity": "sha512-J1oxsYZX1N0tkEcaHt/uuDqk6zOnaivyampp+EvBsUMCdemjg7rwKvawlRB0ZtBEQu3HAhi8zecm03mlpWfCDw==", + "dependencies": { + "@sentry/types": "7.34.0", + "@sentry/utils": "7.34.0", + "tslib": "^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/node": { + "version": "7.34.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.34.0.tgz", + "integrity": "sha512-VM4XeydRdgeaNTRe8kwqYg2oNPddVyY74PlCFEFnPEN1NccycNuwiFno68kNrApeqxxLlTTmzkJy0BWo16x2Yg==", + "dependencies": { + "@sentry/core": "7.34.0", + "@sentry/types": "7.34.0", + "@sentry/utils": "7.34.0", + "cookie": "^0.4.1", + "https-proxy-agent": "^5.0.0", + "lru_map": "^0.3.3", + "tslib": "^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/node/node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/@sentry/node/node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/@sentry/node/node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/@sentry/types": { + "version": "7.34.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.34.0.tgz", + "integrity": "sha512-K+OeHIrl35PSYn6Zwqe4b8WWyAJQoI5NeWxHVkM7oQTGJ1YLG4BvLsR+UiUXnKdR5krE4EDtEA5jLsDlBEyPvw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/utils": { + "version": "7.34.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.34.0.tgz", + "integrity": "sha512-VIHHXEBw0htzqxnU8A7WkXKvmsG2pZVqHlAn0H9W/yyFQtXMuP1j1i0NsjADB/3JXUKK83kTNWGzScXvp0o+Jg==", + "dependencies": { + "@sentry/types": "7.34.0", + "tslib": "^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@sindresorhus/is": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.1.tgz", @@ -12612,6 +12694,11 @@ "node": ">=8" } }, + "node_modules/lru_map": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz", + "integrity": "sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==" + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -21644,6 +21731,68 @@ "cross-fetch": "^3.0.6" } }, + "@sentry/core": { + "version": "7.34.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.34.0.tgz", + "integrity": "sha512-J1oxsYZX1N0tkEcaHt/uuDqk6zOnaivyampp+EvBsUMCdemjg7rwKvawlRB0ZtBEQu3HAhi8zecm03mlpWfCDw==", + "requires": { + "@sentry/types": "7.34.0", + "@sentry/utils": "7.34.0", + "tslib": "^1.9.3" + } + }, + "@sentry/node": { + "version": "7.34.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-7.34.0.tgz", + "integrity": "sha512-VM4XeydRdgeaNTRe8kwqYg2oNPddVyY74PlCFEFnPEN1NccycNuwiFno68kNrApeqxxLlTTmzkJy0BWo16x2Yg==", + "requires": { + "@sentry/core": "7.34.0", + "@sentry/types": "7.34.0", + "@sentry/utils": "7.34.0", + "cookie": "^0.4.1", + "https-proxy-agent": "^5.0.0", + "lru_map": "^0.3.3", + "tslib": "^1.9.3" + }, + "dependencies": { + "agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "requires": { + "debug": "4" + } + }, + "cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==" + }, + "https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "requires": { + "agent-base": "6", + "debug": "4" + } + } + } + }, + "@sentry/types": { + "version": "7.34.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.34.0.tgz", + "integrity": "sha512-K+OeHIrl35PSYn6Zwqe4b8WWyAJQoI5NeWxHVkM7oQTGJ1YLG4BvLsR+UiUXnKdR5krE4EDtEA5jLsDlBEyPvw==" + }, + "@sentry/utils": { + "version": "7.34.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.34.0.tgz", + "integrity": "sha512-VIHHXEBw0htzqxnU8A7WkXKvmsG2pZVqHlAn0H9W/yyFQtXMuP1j1i0NsjADB/3JXUKK83kTNWGzScXvp0o+Jg==", + "requires": { + "@sentry/types": "7.34.0", + "tslib": "^1.9.3" + } + }, "@sindresorhus/is": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.0.1.tgz", @@ -30163,6 +30312,11 @@ "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==" }, + "lru_map": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.3.3.tgz", + "integrity": "sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==" + }, "lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", diff --git a/package.json b/package.json index c9f1b6ae28..e440575051 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "license": "Apache-2.0", "dependencies": { "@open-policy-agent/opa-wasm": "^1.6.0", + "@sentry/node": "^7.34.0", "@snyk/cli-interface": "2.11.0", "@snyk/cloud-config-parser": "^1.14.5", "@snyk/code-client": "^4.15.0", diff --git a/src/cli/index.ts b/src/cli/index.ts index 802b2ca176..6b69aa4457 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -1,5 +1,6 @@ import { callHandlingUnexpectedErrors } from '../lib/unexpected-error'; import { EXIT_CODES } from './exit-codes'; +import { testPlatformSupport } from '../lib/common'; /** * By using a dynamic import, we can add error handlers before evaluating any @@ -7,6 +8,7 @@ import { EXIT_CODES } from './exit-codes'; * handled as we expect. */ callHandlingUnexpectedErrors(async () => { + testPlatformSupport(); const { main } = await import('./main'); await main(); }, EXIT_CODES.ERROR); diff --git a/src/lib/common.ts b/src/lib/common.ts index d03c47d58b..d60a05c90c 100644 --- a/src/lib/common.ts +++ b/src/lib/common.ts @@ -1,3 +1,9 @@ +import * as os from 'os'; +import * as alerts from './alerts'; +import * as Sentry from '@sentry/node'; +import * as version from './version'; +import * as analytics from './analytics/index'; + export async function sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); } @@ -6,3 +12,47 @@ export const reTryMessage = 'Tip: Re-run in debug mode to see more information: DEBUG=*snyk* '; export const contactSupportMessage = 'If the issue persists contact support@snyk.io'; + +export function testPlatformSupport() { + const supportedPlatforms = [ + 'darwin amd64', + 'darwin x64', + 'darwin arm64', + 'linux amd64', + 'linux x64', + 'linux arm64', + 'win32 amd64', + 'win32 x64', + 'win32 arm64', + ]; + + const currentPlatform = os.platform() + ' ' + os.arch(); + if (!supportedPlatforms.includes(currentPlatform)) { + const platformWarning = + '------------------------------- Warning -------------------------------\n' + + ' The current platform (' + + currentPlatform + + ') is not supported by Snyk.\n' + + ' You may want to consider using docker to run Snyk.\n' + + ' If you experience errors please reach out to support@snyk.io.\n' + + '-----------------------------------------------------------------------'; + + alerts.registerAlerts([ + { + type: 'warning', + name: 'testPlatformSupport', + msg: platformWarning, + }, + ]); + + if (analytics.allowAnalytics()) { + const sentryError = new Error('Unsupported Platform: ' + currentPlatform); + Sentry.init({ + dsn: + 'https://3e845233db8c4f43b4c4b9245f1d7bd6@o30291.ingest.sentry.io/4504599528079360', + release: version.getVersion(), + }); + Sentry.captureException(sentryError); + } + } +}