Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 5214780

Browse files
authored
Merge pull request #1 from Asjidkalam/master
Fixed code execution bug on count-git-tags
2 parents 3709977 + 9aaa95e commit 5214780

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,27 @@ import isGit from 'is-git-repository';
33
import { platform } from 'os';
44
import makepath from 'path';
55
import pathIsAbsolute from 'path-is-absolute';
6+
import shellescape from 'shell-escape';
67

78
const cwd = process.cwd();
89

10+
// escape bad arguments
11+
var escapeShell = function(cmd) {
12+
if(cmd !== undefined){
13+
var arg = cmd.toString().split(" ");
14+
return shellescape(arg);
15+
}
16+
}
17+
918
const countGitTags = ({ path, local } = {}) => {
1019
let countOfTags = 0;
1120

1221
let thisPath = path || cwd;
1322
thisPath = pathIsAbsolute(thisPath) ? thisPath : makepath.join(cwd, thisPath);
1423
const thisLocal = local === undefined ? true : local;
24+
25+
thisPath = escapeShell(thisPath);
26+
thisLocal = escapeShell(thisLocal);
1527

1628
if (!isGit(thisPath)) {
1729
return 0;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"execa": "^0.6.1",
3737
"fs-extra": "^3.0.1",
3838
"is-git-repository": "^1.1.1",
39-
"path-is-absolute": "^1.0.1"
39+
"path-is-absolute": "^1.0.1",
40+
"shell-escape": "^0.2.0"
4041
},
4142
"devDependencies": {
4243
"ava": "^0.18.2",

0 commit comments

Comments
 (0)