diff --git a/package.json b/package.json index 0de4a19f0c..77db0e5659 100644 --- a/package.json +++ b/package.json @@ -53,12 +53,15 @@ "author": "snyk.io", "license": "Apache-2.0", "dependencies": { - "@snyk/cli-interface": "^2.4.0", + "@snyk/cli-interface": "2.6.0", "@snyk/configstore": "^3.2.0-rc1", - "@snyk/dep-graph": "1.16.1", + "@snyk/dep-graph": "1.18.2", "@snyk/gemfile": "1.2.0", - "@snyk/ruby-semver": "2.1.2", - "@snyk/snyk-cocoapods-plugin": "2.1.1", + "@snyk/graphlib": "2.1.9-patch", + "@snyk/inquirer": "6.2.2-patch", + "@snyk/lodash": "^4.17.15-patch", + "@snyk/ruby-semver": "2.2.0", + "@snyk/snyk-cocoapods-plugin": "2.2.0", "@snyk/update-notifier": "^2.5.1-rc2", "@types/agent-base": "^4.2.0", "abbrev": "^1.1.1", @@ -69,24 +72,21 @@ "diff": "^4.0.1", "git-url-parse": "11.1.2", "glob": "^7.1.3", - "graphlib": "^2.1.8", - "inquirer": "^6.2.2", - "lodash": "^4.17.14", "needle": "^2.2.4", "open": "^7.0.3", "os-name": "^3.0.0", "proxy-agent": "^3.1.1", "proxy-from-env": "^1.0.0", "semver": "^6.0.0", - "snyk-config": "^2.2.1", - "snyk-docker-plugin": "3.0.0", - "snyk-go-plugin": "1.13.0", + "snyk-config": "3.1.0", + "snyk-docker-plugin": "3.1.0", + "snyk-go-plugin": "1.14.0", "snyk-gradle-plugin": "3.2.5", "snyk-module": "1.9.1", - "snyk-mvn-plugin": "2.11.0", - "snyk-nodejs-lockfile-parser": "1.21.0", - "snyk-nuget-plugin": "1.16.0", - "snyk-php-plugin": "1.7.0", + "snyk-mvn-plugin": "2.15.0", + "snyk-nodejs-lockfile-parser": "1.22.0", + "snyk-nuget-plugin": "1.17.0", + "snyk-php-plugin": "1.9.0", "snyk-policy": "1.13.5", "snyk-python-plugin": "1.17.0", "snyk-resolve": "1.0.1", @@ -103,7 +103,6 @@ }, "devDependencies": { "@types/diff": "^3.5.2", - "@types/lodash": "^4.14.136", "@types/needle": "^2.0.4", "@types/node": "8.10.59", "@types/restify": "^8.4.2", diff --git a/src/cli/commands/monitor/formatters/format-monitor-response.ts b/src/cli/commands/monitor/formatters/format-monitor-response.ts index b8d39751f4..be875f729e 100644 --- a/src/cli/commands/monitor/formatters/format-monitor-response.ts +++ b/src/cli/commands/monitor/formatters/format-monitor-response.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import chalk from 'chalk'; import * as url from 'url'; diff --git a/src/cli/commands/protect/prompts.ts b/src/cli/commands/protect/prompts.ts index 046d880441..b6ec4a112a 100644 --- a/src/cli/commands/protect/prompts.ts +++ b/src/cli/commands/protect/prompts.ts @@ -7,7 +7,7 @@ export { startOver, }; -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import * as semver from 'semver'; import { format as fmt } from 'util'; import * as debugModule from 'debug'; diff --git a/src/cli/commands/protect/tasks.ts b/src/cli/commands/protect/tasks.ts index a9304e0cfe..34f093fe5b 100644 --- a/src/cli/commands/protect/tasks.ts +++ b/src/cli/commands/protect/tasks.ts @@ -2,7 +2,7 @@ export = answersToTasks; import * as debugModule from 'debug'; const debug = debugModule('snyk'); -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; function answersToTasks(answers) { const tasks = { diff --git a/src/cli/commands/protect/wizard.ts b/src/cli/commands/protect/wizard.ts index 4d68c042d7..1ee371393e 100644 --- a/src/cli/commands/protect/wizard.ts +++ b/src/cli/commands/protect/wizard.ts @@ -10,12 +10,12 @@ import * as debugModule from 'debug'; const debug = debugModule('snyk'); import * as path from 'path'; -import * as inquirer from 'inquirer'; +import * as inquirer from '@snyk/inquirer'; import * as fs from 'then-fs'; import * as tryRequire from 'snyk-try-require'; import chalk from 'chalk'; import * as url from 'url'; -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import { exec } from 'child_process'; import { apiTokenExists } from '../../../lib/api-token'; import * as auth from '../auth/is-authed'; diff --git a/src/cli/commands/test/formatters/docker/format-docker-binary-heading.ts b/src/cli/commands/test/formatters/docker/format-docker-binary-heading.ts index c8f648f083..1450e90563 100644 --- a/src/cli/commands/test/formatters/docker/format-docker-binary-heading.ts +++ b/src/cli/commands/test/formatters/docker/format-docker-binary-heading.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import chalk from 'chalk'; export function createDockerBinaryHeading(pkgInfo): string { diff --git a/src/cli/commands/test/formatters/docker/format-docker-binary-issues.ts b/src/cli/commands/test/formatters/docker/format-docker-binary-issues.ts index e256115fa9..32d056746f 100644 --- a/src/cli/commands/test/formatters/docker/format-docker-binary-issues.ts +++ b/src/cli/commands/test/formatters/docker/format-docker-binary-issues.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import { createDockerBinaryHeading } from './format-docker-binary-heading'; import { Options, TestOptions } from '../../../../../lib/types'; import { formatIssues } from '../legacy-format-issue'; diff --git a/src/cli/commands/test/formatters/legacy-format-issue.ts b/src/cli/commands/test/formatters/legacy-format-issue.ts index 2d8b483507..da5c7ab986 100644 --- a/src/cli/commands/test/formatters/legacy-format-issue.ts +++ b/src/cli/commands/test/formatters/legacy-format-issue.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import chalk from 'chalk'; import * as config from '../../../../lib/config'; import { Options, TestOptions, ShowVulnPaths } from '../../../../lib/types'; diff --git a/src/cli/commands/test/index.ts b/src/cli/commands/test/index.ts index e6252fdfad..a922026de1 100644 --- a/src/cli/commands/test/index.ts +++ b/src/cli/commands/test/index.ts @@ -1,6 +1,6 @@ export = test; -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import chalk from 'chalk'; import * as snyk from '../../../lib'; import * as config from '../../../lib/config'; diff --git a/src/lib/config.ts b/src/lib/config.ts index 2a0cfb2f7e..e5f24ee645 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -15,7 +15,10 @@ interface Config { TOKEN: string; } -const config: Config = snykConfig(__dirname + '/../..'); +// TODO: fix the types! +const config = (snykConfig.loadConfig( + __dirname + '/../..', +) as unknown) as Config; // allow user config override of the api end point const endpoint = userConfig.get('endpoint'); diff --git a/src/lib/detect.ts b/src/lib/detect.ts index 9aeaaa7fd0..643fcba40a 100644 --- a/src/lib/detect.ts +++ b/src/lib/detect.ts @@ -1,7 +1,7 @@ import * as fs from 'then-fs'; import * as pathLib from 'path'; import * as debugLib from 'debug'; -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import { NoSupportedManifestsFoundError } from './errors'; import { SupportedPackageManagers } from './package-managers'; diff --git a/src/lib/find-files.ts b/src/lib/find-files.ts index 5eb9cab53c..3fd24bd194 100644 --- a/src/lib/find-files.ts +++ b/src/lib/find-files.ts @@ -1,6 +1,6 @@ import * as fs from 'fs'; import * as pathLib from 'path'; -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import { detectPackageManagerFromFile } from './detect'; import * as debugModule from 'debug'; const debug = debugModule('snyk'); diff --git a/src/lib/module-info/index.ts b/src/lib/module-info/index.ts index 24ba35df7e..1edb1028d4 100644 --- a/src/lib/module-info/index.ts +++ b/src/lib/module-info/index.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import * as Debug from 'debug'; import { legacyPlugin as pluginApi } from '@snyk/cli-interface'; diff --git a/src/lib/monitor/index.ts b/src/lib/monitor/index.ts index e1dbb630cb..ed41c43c6c 100644 --- a/src/lib/monitor/index.ts +++ b/src/lib/monitor/index.ts @@ -5,7 +5,7 @@ import { apiTokenExists } from '../api-token'; import request = require('../request'); import * as config from '../config'; import * as os from 'os'; -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import { isCI } from '../is-ci'; import * as analytics from '../analytics'; import { DepTree, MonitorMeta, MonitorResult } from '../types'; diff --git a/src/lib/plugins/get-multi-plugin-result.ts b/src/lib/plugins/get-multi-plugin-result.ts index b9851b46e3..d56559773e 100644 --- a/src/lib/plugins/get-multi-plugin-result.ts +++ b/src/lib/plugins/get-multi-plugin-result.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import * as path from 'path'; import * as cliInterface from '@snyk/cli-interface'; import chalk from 'chalk'; diff --git a/src/lib/plugins/rubygems/index.ts b/src/lib/plugins/rubygems/index.ts index 55c09c5c2b..efc284c7d5 100644 --- a/src/lib/plugins/rubygems/index.ts +++ b/src/lib/plugins/rubygems/index.ts @@ -1,7 +1,7 @@ import { inspectors, Spec } from './inspectors'; import { MissingTargetFileError } from '../../errors/missing-targetfile-error'; import gemfileLockToDependencies = require('./gemfile-lock-to-dependencies'); -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import { MultiProjectResult } from '@snyk/cli-interface/legacy/plugin'; export async function inspect( diff --git a/src/lib/policy/pluck-policies.ts b/src/lib/policy/pluck-policies.ts index 207f73e7d2..08347e6c51 100644 --- a/src/lib/policy/pluck-policies.ts +++ b/src/lib/policy/pluck-policies.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; export function pluckPolicies(pkg) { if (!pkg) { diff --git a/src/lib/reachable-vulns.ts b/src/lib/reachable-vulns.ts index 10e35b8d14..9ff39b1fc5 100644 --- a/src/lib/reachable-vulns.ts +++ b/src/lib/reachable-vulns.ts @@ -1,4 +1,4 @@ -import * as graphlib from 'graphlib'; +import * as graphlib from '@snyk/graphlib'; import { CallGraph } from '@snyk/cli-interface/legacy/common'; import { diff --git a/src/lib/snyk-test/legacy.ts b/src/lib/snyk-test/legacy.ts index f49981b117..175053f187 100644 --- a/src/lib/snyk-test/legacy.ts +++ b/src/lib/snyk-test/legacy.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import * as depGraphLib from '@snyk/dep-graph'; import { SupportedPackageManagers } from '../package-managers'; import { SEVERITIES } from './common'; diff --git a/src/lib/snyk-test/run-test.ts b/src/lib/snyk-test/run-test.ts index 436703e41c..c835f14275 100644 --- a/src/lib/snyk-test/run-test.ts +++ b/src/lib/snyk-test/run-test.ts @@ -1,5 +1,5 @@ import * as fs from 'fs'; -import * as _ from 'lodash'; +import * as _ from '@snyk/lodash'; import * as path from 'path'; import * as debugModule from 'debug'; import * as pathUtil from 'path'; diff --git a/test/prompts.test.ts b/test/prompts.test.ts index 317b8199cb..62d8b04d8f 100644 --- a/test/prompts.test.ts +++ b/test/prompts.test.ts @@ -3,7 +3,7 @@ import { test } from 'tap'; import * as _ from 'lodash'; import * as path from 'path'; import * as sinon from 'sinon'; -import * as inquirer from 'inquirer'; +import * as inquirer from '@snyk/inquirer'; import wizard = require('../src/cli/commands/protect/wizard'); diff --git a/test/utils.ts b/test/utils.ts index 3941b59fd6..df6f3e306b 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -1,7 +1,7 @@ import { tmpdir } from 'os'; import { join } from 'path'; import { mkdir, readFileSync } from 'fs'; -import * as graphlib from 'graphlib'; +import * as graphlib from '@snyk/graphlib'; export function silenceLog() { const old = console.log; diff --git a/test/wizard-instrumented.js b/test/wizard-instrumented.js index 4b70b48f6c..87080553b3 100644 --- a/test/wizard-instrumented.js +++ b/test/wizard-instrumented.js @@ -4,7 +4,7 @@ var proxyquire = require('proxyquire'); var sinon = require('sinon'); var spy; var wizard = proxyquire('../src/cli/commands/protect/wizard', { - inquirer: { + '@snyk/inquirer': { prompt: function(q, cb) { if (!cb) { cb = (_) => Promise.resolve(_); diff --git a/test/wizard-patch-multiple-locations.test.js b/test/wizard-patch-multiple-locations.test.js deleted file mode 100644 index a984120bbf..0000000000 --- a/test/wizard-patch-multiple-locations.test.js +++ /dev/null @@ -1,28 +0,0 @@ -var test = require('tap').test; -var interactive = require('./wizard-instrumented'); -var answersToTasks = require('../src/cli/commands/protect/tasks'); -var snykPolicy = require('snyk-policy'); -var proxyquire = require('proxyquire'); -var patch = proxyquire('../src/lib/protect/patch', { - './apply-patch': function() { - return Promise.resolve(true); - }, -}); - -test('patch does not try to apply the same patch more than once (SC-965)', function(t) { - var responses = ['default:patch', 'default:patch', 'n', 'n']; - - var vulns = require(__dirname + '/fixtures/scenarios/SC-965.json'); - - return interactive(vulns, responses).then(function(answers) { - var tasks = answersToTasks(answers); - return patch(tasks.patch, false).then(function(v) { - var demunged = snykPolicy.demunge(v); - var count = demunged.patch.reduce(function(acc, curr) { - acc += curr.paths.length; - return acc; - }, 0); - t.equal(count, 6, 'all patches in place'); - }); - }); -}); diff --git a/test/wizard-patch-multiple-locations.test.ts b/test/wizard-patch-multiple-locations.test.ts new file mode 100644 index 0000000000..c4f943907e --- /dev/null +++ b/test/wizard-patch-multiple-locations.test.ts @@ -0,0 +1,26 @@ +import { test } from 'tap'; +import interactive = require('./wizard-instrumented'); +import answersToTasks = require('../src/cli/commands/protect/tasks'); +import * as snykPolicy from 'snyk-policy'; +import * as proxyquire from 'proxyquire'; +const patch = proxyquire('../src/lib/protect/patch', { + './apply-patch': () => { + return Promise.resolve(true); + }, +}); + +test('patch does not try to apply the same patch more than once', async (t) => { + const responses = ['default:patch', 'default:patch', 'n', 'n']; + + const vulns = require(__dirname + '/fixtures/scenarios/SC-965.json'); + + const answers = await interactive(vulns, responses); + const tasks = answersToTasks(answers); + const res = await patch(tasks.patch, false); + const demunged = snykPolicy.demunge(res); + const count = demunged.patch.reduce((acc, curr) => { + acc += curr.paths.length; + return acc; + }, 0); + t.equal(count, 6, 'all patches in place'); +}); diff --git a/test/wizard-prepare.test.js b/test/wizard-prepare.test.js index 89d5ada80c..28cfa0f401 100644 --- a/test/wizard-prepare.test.js +++ b/test/wizard-prepare.test.js @@ -7,7 +7,7 @@ var dir = __dirname + '/fixtures/protect-via-snyk/'; var fixture = require('./fixtures/protect-via-snyk/package.json'); var wizard = proxyquire('../src/cli/commands/protect/wizard', { - inquirer: { + '@snyk/inquirer': { prompt: function(q, cb) { cb(q); },