Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 3b7fe02

Browse files
alan-agius4Keen Yee Liau
authored and
Keen Yee Liau
committed
fix: security prototype pollution
Optimist has been deprecated over 2 years ago as has a security vulnerability. With this change we use it's successor `yargs`. Closes: #5413
1 parent 7beca52 commit 3b7fe02

File tree

6 files changed

+284
-78
lines changed

6 files changed

+284
-78
lines changed

‎docs/faq.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,13 @@ is complete before continuing.
187187

188188
How do I switch off an option in the CLI?
189189
-----------------------------------------
190-
i.e. `webdriver-manager update --chrome=false` does not work.
191-
This has to do with the way `optimist` parses command line args. In order to pass a false value, do one of the following:
190+
This has to do with the way `yargs` parses command line args. In order to pass a false value, do one of the following:
192191

193192
1) `webdriver-manager update --chrome=0`
194193

195-
2) `webdriver-manager update --no-chrome` (see https://github.com/substack/node-optimist#negate-fields)
194+
2) `webdriver-manager update --chrome=false`
195+
196+
3) `webdriver-manager update --no-chrome` (see https://github.com/yargs/yargs/blob/HEAD/docs/tricks.md#negate)
196197

197198
Why does Protractor fail when I decorate $timeout?
198199
--------------------------------------------------

‎lib/cli.ts‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs';
2-
import * as optimist from 'optimist';
32
import * as path from 'path';
3+
import * as yargs from 'yargs';
44

55
/**
66
* The command line interface for interacting with the Protractor runner.
@@ -115,7 +115,7 @@ let allowedNames = [
115115
'stackTrace'
116116
];
117117

118-
let optimistOptions: any = {
118+
let yargsOptions: any = {
119119
describes: {
120120
help: 'Print Protractor help menu',
121121
version: 'Print Protractor version',
@@ -153,30 +153,33 @@ let optimistOptions: any = {
153153
strings: {'capabilities.tunnel-identifier': ''}
154154
};
155155

156-
optimist.usage(
156+
yargs.usage(
157157
'Usage: protractor [configFile] [options]\n' +
158158
'configFile defaults to protractor.conf.js\n' +
159159
'The [options] object will override values from the config file.\n' +
160160
'See the reference config for a full list of options.');
161-
for (let key of Object.keys(optimistOptions.describes)) {
162-
optimist.describe(key, optimistOptions.describes[key]);
161+
for (let key of Object.keys(yargsOptions.describes)) {
162+
yargs.describe(key, yargsOptions.describes[key]);
163163
}
164-
for (let key of Object.keys(optimistOptions.aliases)) {
165-
optimist.alias(key, optimistOptions.aliases[key]);
164+
for (let key of Object.keys(yargsOptions.aliases)) {
165+
yargs.alias(key, yargsOptions.aliases[key]);
166166
}
167-
for (let key of Object.keys(optimistOptions.strings)) {
168-
optimist.string(key);
167+
for (let key of Object.keys(yargsOptions.strings)) {
168+
yargs.string(key);
169169
}
170-
optimist.check(function(arg: any) {
170+
171+
yargs.check(function(arg: any) {
171172
if (arg._.length > 1) {
172173
throw new Error('Error: more than one config file specified');
173174
}
175+
176+
return true;
174177
});
175178

176-
let argv: any = optimist.parse(args);
179+
let argv: any = yargs.parse(args);
177180

178181
if (argv.help) {
179-
optimist.showHelp();
182+
yargs.showHelp();
180183
process.exit(0);
181184
}
182185

@@ -233,7 +236,7 @@ if (!configFile && !argv.elementExplorer && args.length < 3) {
233236
console.log(
234237
'**you must either specify a configuration file ' +
235238
'or at least 3 options. See below for the options:\n');
236-
optimist.showHelp();
239+
yargs.showHelp();
237240
process.exit(1);
238241
}
239242

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /