Cscott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/169773
Change subject: Avoid use of `child_process.exec`.
......................................................................
Avoid use of `child_process.exec`.
The `exec` function spawns a subshell, which is unnecessary here.
In general, one should always use `execFile` instead of `exec`, which
also avoids a possible security issue with quoted arguments (although
that issue is moot here). Also set the working directory, just to
be safe.
Change-Id: Icc1eb9be85a288a457973116dc8ded7aca3e97b8
---
M api/routes.js
1 file changed, 5 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/73/169773/1
diff --git a/api/routes.js b/api/routes.js
index 3214573..41b1874 100644
--- a/api/routes.js
+++ b/api/routes.js
@@ -7,7 +7,7 @@
fs = require('fs'),
url = require('url'),
util = require('util'),
- childProc = require('child_process'),
+ child_process = require('child_process'),
cluster = require('cluster'),
domino = require('domino'),
pkg = require('../package.json'),
@@ -440,9 +440,10 @@
version: pkg.version
};
Promise.promisify(
- childProc.exec, false, childProc
- )( 'git rev-parse HEAD' ).then(function( stdout ) {
- versionCache.sha = stdout.slice(0, -1);
+ child_process.execFile, ['stdout','stderr'], child_process
+ )( 'git', ['rev-parse','HEAD'], { cwd: path.join(__dirname,'..') } ).
+ then(function( out ) {
+ versionCache.sha = out.stdout.slice(0, -1);
}).finally(function() {
res.json( versionCache );
});
--
To view, visit https://gerrit.wikimedia.org/r/169773
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc1eb9be85a288a457973116dc8ded7aca3e97b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits