Skip to content

Commit bcc1f57

Browse files
authored
Merge pull request #1175 from yukun-han/fix/retire-lodash-omitby
fix: retire lodash omitby to fix vulnerability
2 parents c3b9d6c + fedcc2e commit bcc1f57

File tree

4 files changed

+18
-34
lines changed

4 files changed

+18
-34
lines changed

package-lock.json

-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
"lodash.isnil": "4.0.0",
111111
"lodash.isundefined": "3.0.1",
112112
"lodash.omit": "^4.5.0",
113-
"lodash.omitby": "4.6.0",
114113
"pkginfo": "^0.4.1",
115114
"ramda": "^0.28.0",
116115
"randexp": "^0.5.3"

src/dsl/graphql.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
*
44
* @module GraphQL
55
*/
6-
import { isNil, extend, omitBy, isUndefined } from 'lodash';
6+
import { isNil, extend, isUndefined } from 'lodash';
7+
import { reject } from 'ramda';
78
import gql from 'graphql-tag';
89
import { Interaction, InteractionStateComplete } from './interaction';
910
import { regex } from './matchers';
@@ -106,17 +107,14 @@ export class GraphQLInteraction extends Interaction {
106107

107108
this.state.request = extend(
108109
{
109-
body: omitBy(
110-
{
111-
operationName: this.operation,
112-
query: regex({
113-
generate: this.query,
114-
matcher: escapeGraphQlQuery(this.query),
115-
}),
116-
variables: this.variables,
117-
},
118-
isUndefined
119-
),
110+
body: reject(isUndefined, {
111+
operationName: this.operation,
112+
query: regex({
113+
generate: this.query,
114+
matcher: escapeGraphQlQuery(this.query),
115+
}),
116+
variables: this.variables,
117+
}),
120118
headers: { 'Content-Type': 'application/json' },
121119
method: 'POST',
122120
},

src/dsl/interaction.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
* @module Interaction
44
*/
55

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

134-
this.state.request = omitBy(requestOpts, isNil) as RequestOptions;
135+
this.state.request = reject(isNil, requestOpts) as RequestOptions;
135136

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

155-
this.state.response = omitBy(
156-
{
157-
body: responseOpts.body,
158-
headers: responseOpts.headers || undefined,
159-
status: responseOpts.status,
160-
},
161-
isNil
162-
) as ResponseOptions;
156+
this.state.response = reject(isNil, {
157+
body: responseOpts.body,
158+
headers: responseOpts.headers || undefined,
159+
status: responseOpts.status,
160+
}) as ResponseOptions;
163161
return this;
164162
}
165163

0 commit comments

Comments
 (0)