Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retire lodash omitby to fix vulnerability #1175

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
"lodash.isnil": "4.0.0",
"lodash.isundefined": "3.0.1",
"lodash.omit": "^4.5.0",
"lodash.omitby": "4.6.0",
"pkginfo": "^0.4.1",
"ramda": "^0.28.0",
"randexp": "^0.5.3"
Expand Down
22 changes: 10 additions & 12 deletions src/dsl/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* @module GraphQL
*/
import { isNil, extend, omitBy, isUndefined } from 'lodash';
import { isNil, extend, isUndefined } from 'lodash';
import { reject } from 'ramda';
import gql from 'graphql-tag';
import { Interaction, InteractionStateComplete } from './interaction';
import { regex } from './matchers';
Expand Down Expand Up @@ -106,17 +107,14 @@ export class GraphQLInteraction extends Interaction {

this.state.request = extend(
{
body: omitBy(
{
operationName: this.operation,
query: regex({
generate: this.query,
matcher: escapeGraphQlQuery(this.query),
}),
variables: this.variables,
},
isUndefined
),
body: reject(isUndefined, {
operationName: this.operation,
query: regex({
generate: this.query,
matcher: escapeGraphQlQuery(this.query),
}),
variables: this.variables,
}),
headers: { 'Content-Type': 'application/json' },
method: 'POST',
},
Expand Down
18 changes: 8 additions & 10 deletions src/dsl/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* @module Interaction
*/

import { isNil, keys, omitBy } from 'lodash';
import { isNil, keys } from 'lodash';
import { reject } from 'ramda';
import { HTTPMethods, HTTPMethod } from '../common/request';
import { Matcher, isMatcher, AnyTemplate } from './matchers';
import ConfigurationError from '../errors/configurationError';
Expand Down Expand Up @@ -131,7 +132,7 @@ export class Interaction {
throwIfQueryObjectInvalid(requestOpts.query);
}

this.state.request = omitBy(requestOpts, isNil) as RequestOptions;
this.state.request = reject(isNil, requestOpts) as RequestOptions;

return this;
}
Expand All @@ -152,14 +153,11 @@ export class Interaction {
throw new ConfigurationError('You must provide a status code.');
}

this.state.response = omitBy(
{
body: responseOpts.body,
headers: responseOpts.headers || undefined,
status: responseOpts.status,
},
isNil
) as ResponseOptions;
this.state.response = reject(isNil, {
body: responseOpts.body,
headers: responseOpts.headers || undefined,
status: responseOpts.status,
}) as ResponseOptions;
return this;
}

Expand Down
Loading