systeminformation 5.33.22 → 5.33.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/filesystem.js +1 -1
- package/lib/osinfo.js +1 -1
- package/lib/util.js +30 -6
- package/lib/virtualbox.js +1 -1
- package/package.json +1 -1
package/lib/filesystem.js
CHANGED
|
@@ -1808,7 +1808,7 @@ function diskLayout(callback) {
|
|
|
1808
1808
|
workload.push(util.powerShell('Get-PhysicalDisk | select BusType,MediaType,FriendlyName,Model,SerialNumber,Size | fl'));
|
|
1809
1809
|
if (util.smartMonToolsInstalled()) {
|
|
1810
1810
|
try {
|
|
1811
|
-
const smartDev = JSON.parse(execSync('smartctl --scan -j').toString());
|
|
1811
|
+
const smartDev = JSON.parse(execSync('smartctl --scan -j', util.execOptsWin).toString());
|
|
1812
1812
|
if (smartDev && smartDev.devices && smartDev.devices.length > 0) {
|
|
1813
1813
|
smartDev.devices.forEach((dev) => {
|
|
1814
1814
|
// device names come from smartctl output - never let anything but a plain path reach the shell
|
package/lib/osinfo.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
const os = require('os');
|
|
17
17
|
const fs = require('fs');
|
|
18
18
|
const util = require('./util');
|
|
19
|
-
const exec =
|
|
19
|
+
const exec = util.execCwd;
|
|
20
20
|
const execSync = require('child_process').execSync;
|
|
21
21
|
const execFile = require('child_process').execFile;
|
|
22
22
|
|
package/lib/util.js
CHANGED
|
@@ -48,13 +48,33 @@ const _psError = '--ERROR--';
|
|
|
48
48
|
const _psCmdSeperator = '--###ENDCMD###--';
|
|
49
49
|
const _psIdSeperator = '--##ID##--';
|
|
50
50
|
|
|
51
|
+
// cmd.exe and libuv search cwd before PATH: run from system32 so bare names never resolve to files in the caller's cwd (CWE-427)
|
|
52
|
+
const _winSysDir = WINDIR + '\\system32';
|
|
53
|
+
|
|
51
54
|
const execOptsWin = {
|
|
52
55
|
windowsHide: true,
|
|
53
56
|
maxBuffer: 1024 * 102400,
|
|
54
57
|
encoding: 'UTF-8',
|
|
55
|
-
env: Object.assign({}, process.env, { LANG: 'en_US.UTF-8' })
|
|
58
|
+
env: Object.assign({}, process.env, { LANG: 'en_US.UTF-8' }),
|
|
59
|
+
cwd: _windows && fs.existsSync(_winSysDir) ? _winSysDir : undefined
|
|
56
60
|
};
|
|
57
61
|
|
|
62
|
+
function winCwd(options) {
|
|
63
|
+
if (!execOptsWin.cwd || (options && options.cwd)) {
|
|
64
|
+
return options;
|
|
65
|
+
}
|
|
66
|
+
return Object.assign({}, options, { cwd: execOptsWin.cwd });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// child_process.exec with system32 as default cwd on Windows (CWE-427)
|
|
70
|
+
function execCwd(cmd, opts, callback) {
|
|
71
|
+
if (typeof opts === 'function') {
|
|
72
|
+
callback = opts;
|
|
73
|
+
opts = undefined;
|
|
74
|
+
}
|
|
75
|
+
return exec(cmd, winCwd(opts), callback);
|
|
76
|
+
}
|
|
77
|
+
|
|
58
78
|
const execOptsLinux = {
|
|
59
79
|
maxBuffer: 1024 * 102400,
|
|
60
80
|
encoding: 'UTF-8',
|
|
@@ -366,7 +386,8 @@ function getPowershell() {
|
|
|
366
386
|
|
|
367
387
|
function getVboxmanage() {
|
|
368
388
|
const vboxPath = (process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH || '').replace(/["%!^&|<>`$;\r\n]/g, '');
|
|
369
|
-
|
|
389
|
+
// empty path would give "\VBoxManage.exe" = root of the current drive
|
|
390
|
+
return _windows ? (vboxPath ? `"${vboxPath}\\VBoxManage.exe"` : 'VBoxManage.exe') : 'vboxmanage';
|
|
370
391
|
}
|
|
371
392
|
|
|
372
393
|
function powerShellProceedResults(data) {
|
|
@@ -406,7 +427,8 @@ function powerShellStart() {
|
|
|
406
427
|
windowsHide: true,
|
|
407
428
|
maxBuffer: 1024 * 102400,
|
|
408
429
|
encoding: 'UTF-8',
|
|
409
|
-
env: Object.assign({}, process.env, { LANG: 'en_US.UTF-8' })
|
|
430
|
+
env: Object.assign({}, process.env, { LANG: 'en_US.UTF-8' }),
|
|
431
|
+
cwd: execOptsWin.cwd
|
|
410
432
|
});
|
|
411
433
|
if (_psChild && _psChild.pid) {
|
|
412
434
|
_psPersistent = true;
|
|
@@ -490,7 +512,8 @@ function powerShell(cmd) {
|
|
|
490
512
|
windowsHide: true,
|
|
491
513
|
maxBuffer: 1024 * 102400,
|
|
492
514
|
encoding: 'UTF-8',
|
|
493
|
-
env: Object.assign({}, process.env, { LANG: 'en_US.UTF-8' })
|
|
515
|
+
env: Object.assign({}, process.env, { LANG: 'en_US.UTF-8' }),
|
|
516
|
+
cwd: execOptsWin.cwd
|
|
494
517
|
});
|
|
495
518
|
|
|
496
519
|
if (child && !child.pid) {
|
|
@@ -538,7 +561,7 @@ function powerShell(cmd) {
|
|
|
538
561
|
|
|
539
562
|
function execSafe(cmd, args, options) {
|
|
540
563
|
let result = '';
|
|
541
|
-
options = options || {};
|
|
564
|
+
options = winCwd(options || {});
|
|
542
565
|
|
|
543
566
|
return new Promise((resolve) => {
|
|
544
567
|
process.nextTick(() => {
|
|
@@ -671,7 +694,7 @@ function execWin(cmd, opts, callback) {
|
|
|
671
694
|
opts = execOptsWin;
|
|
672
695
|
}
|
|
673
696
|
const newCmd = 'chcp 65001 > nul && cmd /C ' + cmd + ' && chcp ' + codepage + ' > nul';
|
|
674
|
-
exec(newCmd, opts, (error, stdout) => {
|
|
697
|
+
exec(newCmd, winCwd(opts), (error, stdout) => {
|
|
675
698
|
callback(error, stdout);
|
|
676
699
|
});
|
|
677
700
|
}
|
|
@@ -2828,6 +2851,7 @@ function isProtoKey(key) {
|
|
|
2828
2851
|
exports.toInt = toInt;
|
|
2829
2852
|
exports.splitByNumber = splitByNumber;
|
|
2830
2853
|
exports.execOptsWin = execOptsWin;
|
|
2854
|
+
exports.execCwd = execCwd;
|
|
2831
2855
|
exports.execOptsLinux = execOptsLinux;
|
|
2832
2856
|
exports.getCodepage = getCodepage;
|
|
2833
2857
|
exports.execWin = execWin;
|
package/lib/virtualbox.js
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
// ----------------------------------------------------------------------------------
|
|
15
15
|
|
|
16
16
|
const os = require('os');
|
|
17
|
-
const exec = require('child_process').exec;
|
|
18
17
|
const util = require('./util');
|
|
18
|
+
const exec = util.execCwd;
|
|
19
19
|
|
|
20
20
|
function vboxInfo(callback) {
|
|
21
21
|
callback = util.isFunction(callback) ? callback : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.33.
|
|
3
|
+
"version": "5.33.23",
|
|
4
4
|
"description": "Advanced, lightweight system and OS information library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|