Skip to content

Commit 4fec455

Browse files
committed
fix security vuln
1 parent e71fbe1 commit 4fec455

File tree

2 files changed

+46
-55
lines changed

2 files changed

+46
-55
lines changed

package.json

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pullit",
3-
"version": "1.3.0",
3+
"version": "1.4.0",
44
"description": "Display and pull branches from GitHub pull requests",
55
"main": "src/index.js",
66
"preferGlobal": true,
@@ -12,13 +12,7 @@
1212
"type": "git",
1313
"url": "git+https://github.com/jkup/pullit.git"
1414
},
15-
"keywords": [
16-
"github",
17-
"pull",
18-
"request",
19-
"pr",
20-
"cli"
21-
],
15+
"keywords": ["github", "pull", "request", "pr", "cli"],
2216
"author": "Jon Kuperman",
2317
"license": "MIT",
2418
"bin": {
@@ -38,15 +32,9 @@
3832
"terminal-menu": "^2.1.1"
3933
},
4034
"jest": {
41-
"collectCoverageFrom": [
42-
"src/**/*.js"
43-
],
35+
"collectCoverageFrom": ["src/**/*.js"],
4436
"testEnvironment": "node",
45-
"modulePathIgnorePatterns": [
46-
"__tests__/fixtures/"
47-
],
48-
"testPathIgnorePatterns": [
49-
"__tests__/fixtures/"
50-
]
37+
"modulePathIgnorePatterns": ["__tests__/fixtures/"],
38+
"testPathIgnorePatterns": ["__tests__/fixtures/"]
5139
}
52-
}
40+
}

src/index.js

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
const GitHubApi = require('github');
2-
const Menu = require('terminal-menu');
3-
const {
4-
execSync
5-
} = require('child_process');
6-
const parse = require('parse-github-repo-url');
1+
const GitHubApi = require("github");
2+
const Menu = require("terminal-menu");
3+
const { execFileSync } = require("child_process");
4+
const parse = require("parse-github-repo-url");
75

86
class Pullit {
97
constructor() {
@@ -12,8 +10,8 @@ class Pullit {
1210
}
1311

1412
init() {
15-
const url = execSync(`git config --get remote.origin.url`, {
16-
encoding: 'utf8'
13+
const url = execFileSync("git", ["config", "--get", "remote.origin.url"], {
14+
encoding: "utf8"
1715
}).trim();
1816

1917
return this.parsedGithubUrl(url);
@@ -34,12 +32,11 @@ class Pullit {
3432
})
3533
.then(res => {
3634
const branch = res.data.head.ref;
37-
execSync(
38-
`git fetch origin pull/${id}/head:${branch} && git checkout ${branch}`
39-
);
35+
execFileSync("git", ["fetch", "origin", `pull/${id}/head:${branch}`]);
36+
execFileSync("git", ["checkout", branch]);
4037
})
4138
.catch(err => {
42-
console.log('Error: Could not find the specified pull request.');
39+
console.log("Error: Could not find the specified pull request.");
4340
});
4441
}
4542

@@ -51,36 +48,42 @@ class Pullit {
5148
}
5249

5350
display() {
54-
this.fetchRequests().then(results => {
55-
const menu = Menu({
56-
width: process.stdout.columns - 4,
57-
x: 0,
58-
y: 2
59-
});
60-
menu.reset();
61-
menu.write('Currently open pull requests:\n');
62-
menu.write('-------------------------\n');
51+
this.fetchRequests()
52+
.then(results => {
53+
const menu = Menu({
54+
width: process.stdout.columns - 4,
55+
x: 0,
56+
y: 2
57+
});
58+
menu.reset();
59+
menu.write("Currently open pull requests:\n");
60+
menu.write("-------------------------\n");
6361

64-
results.data.forEach(element => {
65-
menu.add(`${element.number} - ${element.title} - ${element.head.user.login}`);
66-
});
62+
results.data.forEach(element => {
63+
menu.add(
64+
`${element.number} - ${element.title} - ${element.head.user.login}`
65+
);
66+
});
6767

68-
menu.add(`Exit`);
68+
menu.add(`Exit`);
6969

70-
menu.on('select', label => {
71-
menu.close();
72-
this.fetch(label.split(' ')[0]);
73-
});
74-
process.stdin.pipe(menu.createStream()).pipe(process.stdout);
70+
menu.on("select", label => {
71+
menu.close();
72+
this.fetch(label.split(" ")[0]);
73+
});
74+
process.stdin.pipe(menu.createStream()).pipe(process.stdout);
7575

76-
process.stdin.setRawMode(true);
77-
menu.on('close', () => {
78-
process.stdin.setRawMode(false);
79-
process.stdin.end();
76+
process.stdin.setRawMode(true);
77+
menu.on("close", () => {
78+
process.stdin.setRawMode(false);
79+
process.stdin.end();
80+
});
81+
})
82+
.catch(err => {
83+
console.log(
84+
"Error: could not display pull requests. Please make sure this is a valid repository."
85+
);
8086
});
81-
}).catch(err => {
82-
console.log('Error: could not display pull requests. Please make sure this is a valid repository.')
83-
});
8487
}
8588
}
8689

0 commit comments

Comments
 (0)