Skip to content

Commit

Permalink
swap exec for execFile in fetchGitData
Browse files Browse the repository at this point in the history
Credit: Adar Zandberg from the CxSCA AppSec team at Checkmarx.

* devDependency updates from Dependabot alerts
* bump version
  • Loading branch information
nickmerwin committed Jun 29, 2021
1 parent 79c97ba commit 565da5f
Show file tree
Hide file tree
Showing 3 changed files with 7,145 additions and 42 deletions.
10 changes: 5 additions & 5 deletions lib/fetchGitData.js
@@ -1,6 +1,6 @@
'use strict';

const { exec } = require('child_process');
const { execFile } = require('child_process');
require('./logger')();

function fetchGitData(git, cb) {
Expand Down Expand Up @@ -40,7 +40,7 @@ function fetchGitData(git, cb) {
}

//-- Use git?
exec(`git rev-parse --verify ${git.head.id}`, err => {
execFile('git', ['rev-parse', '--verify', git.head.id], err => {
if (err) {
// git is not available...
git.head.author_name = git.head.author_name || 'Unknown Author';
Expand All @@ -56,7 +56,7 @@ function fetchGitData(git, cb) {
}

function fetchBranch(git, cb) {
exec('git branch', (err, branches) => {
execFile('git', ['branch'], (err, branches) => {
if (err) {
return cb(err);
}
Expand All @@ -69,7 +69,7 @@ function fetchBranch(git, cb) {
const REGEX_COMMIT_DETAILS = /\nauthor (.+?) <([^>]*)>.+\ncommitter (.+?) <([^>]*)>.+[\S\s]*?\n\n(.*)/m;

function fetchHeadDetails(git, cb) {
exec(`git cat-file -p ${git.head.id}`, (err, response) => {
execFile('git', ['cat-file', '-p', git.head.id], (err, response) => {
if (err) {
return cb(err);
}
Expand All @@ -89,7 +89,7 @@ function fetchHeadDetails(git, cb) {
}

function fetchRemotes(git, cb) {
exec('git remote -v', (err, remotes) => {
execFile('git', ['remote', '-v'], (err, remotes) => {
if (err) {
return cb(err);
}
Expand Down

0 comments on commit 565da5f

Please sign in to comment.