Skip to content

Commit

Permalink
Merge pull request #59 from 418sec/master
Browse files Browse the repository at this point in the history
Security Fix for RCE on "gitlogplus" - huntr.dev
  • Loading branch information
hipstersmoothie committed Sep 14, 2020
2 parents 40571a5 + 41e7009 commit 7ab4f61
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/index.ts
@@ -1,4 +1,4 @@
import { exec, execSync, ExecSyncOptions, ExecException } from "child_process";
import { execFile, execFileSync, ExecSyncOptions, ExecException } from "child_process";
import { existsSync } from "fs";
import createDebugger from "debug";

Expand Down Expand Up @@ -323,9 +323,11 @@ function gitlog<Field extends CommitField = DefaultField>(
};
const execOptions = { cwd: userOptions.repo, ...userOptions.execOptions };
const command = createCommand(options);

command = command.split(' ');

if (!cb) {
const stdout = execSync(command, execOptions).toString();
const stdout = execFileSync(command[0], command.slice(1), execOptions).toString();
const commits = stdout.split("@begin@");

if (commits[0] === "") {
Expand All @@ -336,7 +338,7 @@ function gitlog<Field extends CommitField = DefaultField>(
return parseCommits(commits, options.fields, options.nameStatus);
}

exec(command, execOptions, (err, stdout, stderr) => {
execFile(command[0], command.slice(1), execOptions, (err, stdout, stderr) => {
debug("stdout", stdout);
const commits = stdout.split("@begin@");

Expand Down

0 comments on commit 7ab4f61

Please sign in to comment.