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

Fixed code execution bug on count-git-tags #1

Merged
merged 2 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ import isGit from 'is-git-repository';
import { platform } from 'os';
import makepath from 'path';
import pathIsAbsolute from 'path-is-absolute';
import shellescape from 'shell-escape';

const cwd = process.cwd();

// escape bad arguments
var escapeShell = function(cmd) {
if(cmd !== undefined){
var arg = cmd.toString().split(" ");
return shellescape(arg);
}
}

const countGitTags = ({ path, local } = {}) => {
let countOfTags = 0;

let thisPath = path || cwd;
thisPath = pathIsAbsolute(thisPath) ? thisPath : makepath.join(cwd, thisPath);
const thisLocal = local === undefined ? true : local;

thisPath = escapeShell(thisPath);
thisLocal = escapeShell(thisLocal);

if (!isGit(thisPath)) {
return 0;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"execa": "^0.6.1",
"fs-extra": "^3.0.1",
"is-git-repository": "^1.1.1",
"path-is-absolute": "^1.0.1"
"path-is-absolute": "^1.0.1",
"shell-escape": "^0.2.0"
},
"devDependencies": {
"ava": "^0.18.2",
Expand Down