Skip to content

Commit e851237

Browse files
authored
Merge branch 'master' into fix-security-vulnerability-in-local-nodejs-repo
2 parents 5707a1a + ad0d814 commit e851237

File tree

4 files changed

+64
-7
lines changed

4 files changed

+64
-7
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ To enable verbose logging -
4545
```js
4646
bs_local_args = { 'key': '<browserstack-accesskey>', 'verbose': 'true' }
4747
```
48+
Note - Possible values for 'verbose' modifier are '1', '2', '3' and 'true'
4849

4950
#### Folder Testing
5051
To test local folder rather internal server, provide path to folder as value of this option -
@@ -82,6 +83,27 @@ To use a proxy for local testing -
8283
bs_local_args = { 'key': '<browserstack-accesskey>', 'proxyHost': '127.0.0.1', 'proxyPort': '8000', 'proxyUser': 'user', 'proxyPass': 'password' }
8384
```
8485

86+
#### Local Proxy
87+
To use local proxy in local testing -
88+
89+
* localProxyHost: Hostname/IP of proxy, remaining proxy options are ignored if this option is absent
90+
* localProxyPort: Port for the proxy, defaults to 8081 when -localProxyHost is used
91+
* localProxyUser: Username for connecting to proxy (Basic Auth Only)
92+
* localProxyPass: Password for USERNAME, will be ignored if USERNAME is empty or not specified
93+
94+
```
95+
bs_local_args = { 'key': '<browserstack-accesskey>', 'localProxyHost': '127.0.0.1', 'localProxyPort': '8000', 'localProxyUser': 'user', 'localProxyPass': 'password' }
96+
```
97+
98+
#### PAC (Proxy Auto-Configuration)
99+
To use PAC (Proxy Auto-Configuration) in local testing -
100+
101+
* pac-file: PAC (Proxy Auto-Configuration) file’s absolute path
102+
103+
```
104+
bs_local_args = { 'key': '<browserstack-accesskey>', 'pac-file': '<pac_file_abs_path>' }
105+
```
106+
85107
#### Local Identifier
86108
If doing simultaneous multiple local testing connections, set this uniquely for different processes -
87109
```js

index.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
declare module 'browserstack-local' {
2+
interface Options {
3+
key: string
4+
verbose: boolean
5+
force: boolean
6+
only: string
7+
onlyAutomate: boolean
8+
forceLocal: boolean
9+
localIdentifier: string
10+
folder: string
11+
proxyHost: string
12+
proxyPort: string
13+
proxyUser: string
14+
proxyPass: string
15+
forceProxy: boolean
16+
logFile: string
17+
parallelRuns: string
18+
binarypath: string
19+
[key: string]: string | boolean
20+
}
21+
22+
class Local {
23+
start(options: Partial<Options>, callback: () => void): void
24+
isRunning(): boolean
25+
stop(callback: () => void): void
26+
}
27+
}

lib/Local.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var childProcess = require('child_process'),
2+
os = require('os'),
23
fs = require('fs'),
34
path = require('path'),
45
running = require('is-running'),
@@ -7,11 +8,17 @@ var childProcess = require('child_process'),
78
psTree = require('ps-tree');
89

910
function Local(){
11+
this.sanitizePath = function(rawPath) {
12+
var doubleQuoteIfRequired = this.windows && !rawPath.match(/"[^"]+"/) ? '"' : '';
13+
return doubleQuoteIfRequired + rawPath + doubleQuoteIfRequired;
14+
};
15+
16+
this.windows = os.platform().match(/mswin|msys|mingw|cygwin|bccwin|wince|emc|win32/i);
1017
this.pid = undefined;
1118
this.isProcessRunning = false;
1219
this.retriesLeft = 5;
1320
this.key = process.env.BROWSERSTACK_ACCESS_KEY;
14-
this.logfile = path.join(process.cwd(), 'local.log');
21+
this.logfile = this.sanitizePath(path.join(process.cwd(), 'local.log'));
1522
this.opcode = 'start';
1623
this.exitCallback;
1724

@@ -124,7 +131,7 @@ function Local(){
124131
case 'folder':
125132
if(value){
126133
this.folderFlag = '-f';
127-
this.folderPath = value;
134+
this.folderPath = this.sanitizePath(value);
128135
}
129136
break;
130137

@@ -157,7 +164,7 @@ function Local(){
157164
case 'logfile':
158165
case 'logFile':
159166
if(value)
160-
this.logfile = value;
167+
this.logfile = this.sanitizePath(value);
161168
break;
162169

163170
case 'parallelRuns':
@@ -167,7 +174,7 @@ function Local(){
167174

168175
case 'binarypath':
169176
if(value)
170-
this.binaryPath = value;
177+
this.binaryPath = this.sanitizePath(value);
171178
break;
172179

173180
default:

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "browserstack-local",
3-
"version": "1.3.8",
3+
"version": "1.4.23,
44
"description": "Nodejs bindings for BrowserStack Local",
55
"engine": "^0.10.44",
66
"main": "index.js",
7+
"types": "index.d.ts",
78
"scripts": {
89
"pretest": "./node_modules/.bin/eslint lib/* index.js",
910
"test": "./node_modules/.bin/mocha"
@@ -20,7 +21,6 @@
2021
"https-proxy-agent": "^2.2.3",
2122
"is-running": "^2.0.0",
2223
"ps-tree": "=1.1.1",
23-
"sinon": "^1.17.6",
2424
"temp-fs": "^0.9.9"
2525
},
2626
"devDependencies": {
@@ -29,7 +29,8 @@
2929
"mocha": "2.4.5",
3030
"mocks": "0.0.15",
3131
"proxy": "^0.2.4",
32-
"rimraf": "^2.5.4"
32+
"rimraf": "^2.5.4",
33+
"sinon": "^1.17.6"
3334
},
3435
"bugs": "https://github.com/browserstack/browserstack-local-nodejs/issues",
3536
"homepage": "https://github.com/browserstack/browserstack-local-nodejs",

0 commit comments

Comments
 (0)