Skip to content

Commit

Permalink
feat: patching vulnerable lodash with @snyk/lodash
Browse files Browse the repository at this point in the history
Vulnerability in lodash@4.17.15
No fix available so using @snyk/lodash

Using @snyk/inquirer and @snyk/graphlib because of transitive
dependencies on vulnerable lodash

Bump to snyk internal packages that include lodash patch
  • Loading branch information
lili2311 authored and Joe Holdcroft committed Apr 30, 2020
1 parent 39a5284 commit c359e05
Show file tree
Hide file tree
Showing 26 changed files with 67 additions and 67 deletions.
29 changes: 14 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _ from 'lodash';
import * as _ from '@snyk/lodash';
import chalk from 'chalk';
import * as url from 'url';

Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/protect/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/protect/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/protect/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _ from 'lodash';
import * as _ from '@snyk/lodash';
import chalk from 'chalk';

export function createDockerBinaryHeading(pkgInfo): string {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/test/formatters/legacy-format-issue.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/test/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
5 changes: 4 additions & 1 deletion src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/lib/detect.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/find-files.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/lib/module-info/index.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/monitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/get-multi-plugin-result.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/rubygems/index.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/lib/policy/pluck-policies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _ from 'lodash';
import * as _ from '@snyk/lodash';

export function pluckPolicies(pkg) {
if (!pkg) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/reachable-vulns.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as graphlib from 'graphlib';
import * as graphlib from '@snyk/graphlib';
import { CallGraph } from '@snyk/cli-interface/legacy/common';

import {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snyk-test/legacy.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snyk-test/run-test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion test/prompts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion test/utils.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/wizard-instrumented.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(_);
Expand Down
28 changes: 0 additions & 28 deletions test/wizard-patch-multiple-locations.test.js

This file was deleted.

26 changes: 26 additions & 0 deletions test/wizard-patch-multiple-locations.test.ts
Original file line number Diff line number Diff line change
@@ -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');
});
2 changes: 1 addition & 1 deletion test/wizard-prepare.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down

0 comments on commit c359e05

Please sign in to comment.