From ad8b3b81ce401bb3af55cced1b4e06ee307648ab Mon Sep 17 00:00:00 2001 From: Asjid Kalam Date: Sat, 25 Jul 2020 13:55:37 +0530 Subject: [PATCH 1/2] added the shell-escape module --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 6abb574..efee7f9 100644 --- a/package.json +++ b/package.json @@ -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", From 9aaa95e50e3ce9d3d89b7a8f65a3bf3101860e91 Mon Sep 17 00:00:00 2001 From: Asjid Kalam Date: Sat, 25 Jul 2020 14:00:11 +0530 Subject: [PATCH 2/2] fixed the code execution bug --- index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.js b/index.js index 67cb4a8..54375c5 100644 --- a/index.js +++ b/index.js @@ -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;