systeminformation 6.0.0-beta.22 → 6.0.0-beta.24

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.
@@ -9,12 +9,14 @@ export declare const SUNOS: boolean;
9
9
  export declare const WINDOWS: boolean;
10
10
  export declare const ANDROID: boolean;
11
11
  export declare const WINDIR: string;
12
+ export declare const WIN_CWD: string | undefined;
12
13
  export declare const execOptsWin: {
13
14
  windowsHide: boolean;
14
15
  maxBuffer: number;
15
16
  env: NodeJS.ProcessEnv & {
16
17
  LANG: string;
17
18
  };
19
+ cwd: string | undefined;
18
20
  };
19
21
  export declare const execOptsLinux: {
20
22
  maxBuffer: number;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VBOXMANAGE = exports.UNKNOWN = exports.MAX_BUFFER_SIZE = exports.execOptsLinux = exports.execOptsWin = exports.WINDIR = exports.ANDROID = exports.WINDOWS = exports.SUNOS = exports.NETBSD = exports.OPENBSD = exports.LINUX = exports.FREEBSD = exports.DARWIN = exports.AIX = exports.PLATFORM = void 0;
3
+ exports.VBOXMANAGE = exports.UNKNOWN = exports.MAX_BUFFER_SIZE = exports.execOptsLinux = exports.execOptsWin = exports.WIN_CWD = exports.WINDIR = exports.ANDROID = exports.WINDOWS = exports.SUNOS = exports.NETBSD = exports.OPENBSD = exports.LINUX = exports.FREEBSD = exports.DARWIN = exports.AIX = exports.PLATFORM = void 0;
4
+ const node_fs_1 = require("node:fs");
4
5
  exports.PLATFORM = process.platform;
5
6
  exports.AIX = exports.PLATFORM === 'aix';
6
7
  exports.DARWIN = exports.PLATFORM === 'darwin';
@@ -12,10 +13,13 @@ exports.SUNOS = exports.PLATFORM === 'sunos';
12
13
  exports.WINDOWS = exports.PLATFORM === 'win32';
13
14
  exports.ANDROID = exports.PLATFORM === 'android';
14
15
  exports.WINDIR = process.env.WINDIR || 'C:\\Windows';
16
+ const WIN_SYSDIR = `${exports.WINDIR}\\system32`;
17
+ exports.WIN_CWD = exports.WINDOWS && (0, node_fs_1.existsSync)(WIN_SYSDIR) ? WIN_SYSDIR : undefined;
15
18
  exports.execOptsWin = {
16
19
  windowsHide: true,
17
20
  maxBuffer: 1024 * 102400,
18
- env: Object.assign({}, process.env, { LANG: 'en_US.UTF-8' })
21
+ env: Object.assign({}, process.env, { LANG: 'en_US.UTF-8' }),
22
+ cwd: exports.WIN_CWD
19
23
  };
20
24
  exports.execOptsLinux = {
21
25
  maxBuffer: 1024 * 102400,
@@ -23,4 +27,5 @@ exports.execOptsLinux = {
23
27
  };
24
28
  exports.MAX_BUFFER_SIZE = 1024 * 102400;
25
29
  exports.UNKNOWN = 'unknown';
26
- exports.VBOXMANAGE = exports.WINDOWS ? `"${(process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH || '').replace(/["%!^&|<>`$;\r\n]/g, '')}\\VBoxManage.exe"` : 'vboxmanage';
30
+ const VBOX_PATH = (process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH || '').replace(/["%!^&|<>`$;\r\n]/g, '');
31
+ exports.VBOXMANAGE = exports.WINDOWS ? (VBOX_PATH ? `"${VBOX_PATH}\\VBoxManage.exe"` : 'VBoxManage.exe') : 'vboxmanage';
@@ -1,6 +1,8 @@
1
1
  import { execFile as execFileFunction, exec as execFunction } from 'node:child_process';
2
- export declare const exec: typeof execFunction.__promisify__;
3
- export declare const execFile: typeof execFileFunction.__promisify__;
2
+ declare const _exec: typeof execFunction.__promisify__;
3
+ declare const _execFile: typeof execFileFunction.__promisify__;
4
+ export declare const exec: typeof _exec;
5
+ export declare const execFile: typeof _execFile;
4
6
  export declare const shareInflight: <T>(key: string, fn: () => Promise<T>) => Promise<T>;
5
7
  export declare const execSecure: (cmd: string, args: any, options?: any) => Promise<string>;
6
8
  export declare const timeout: (ms: number) => Promise<unknown>;
@@ -8,3 +10,4 @@ export declare const execSave: (cmd: string, options?: any) => Promise<{
8
10
  stdout: string;
9
11
  stderr: string;
10
12
  }>;
13
+ export {};
@@ -4,8 +4,11 @@ exports.execSave = exports.timeout = exports.execSecure = exports.shareInflight
4
4
  const node_child_process_1 = require("node:child_process");
5
5
  const node_util_1 = require("node:util");
6
6
  const const_1 = require("./const");
7
- exports.exec = (0, node_util_1.promisify)(node_child_process_1.exec);
8
- exports.execFile = (0, node_util_1.promisify)(node_child_process_1.execFile);
7
+ const withWinCwd = (options) => (const_1.WIN_CWD && !options?.cwd ? { ...options, cwd: const_1.WIN_CWD } : options);
8
+ const _exec = (0, node_util_1.promisify)(node_child_process_1.exec);
9
+ const _execFile = (0, node_util_1.promisify)(node_child_process_1.execFile);
10
+ exports.exec = ((cmd, options) => _exec(cmd, withWinCwd(options)));
11
+ exports.execFile = ((file, args, options) => _execFile(file, args, withWinCwd(options)));
9
12
  const _inflight = new Map();
10
13
  const shareInflight = (key, fn) => {
11
14
  if (!_inflight.has(key)) {
@@ -30,7 +33,7 @@ const execSecure = (cmd, args, options) => {
30
33
  resolve(result);
31
34
  };
32
35
  try {
33
- const child = (0, node_child_process_1.spawn)(cmd, args, { stdio: ['pipe', 'pipe', 'ignore'], ...spawnOptions });
36
+ const child = (0, node_child_process_1.spawn)(cmd, args, withWinCwd({ stdio: ['pipe', 'pipe', 'ignore'], ...spawnOptions }));
34
37
  if (child?.pid) {
35
38
  if (timeoutMs) {
36
39
  timer = setTimeout(() => {
@@ -23,9 +23,13 @@ const getFQDN = async () => {
23
23
  }
24
24
  catch { }
25
25
  break;
26
- case const_1.WINDOWS:
27
- ({ stdout } = await (0, exec_1.exec)('echo %COMPUTERNAME%.%USERDNSDOMAIN%'));
28
- return stdout.toString().replace('.%USERDNSDOMAIN%', '').split(node_os_1.EOL)[0];
26
+ case const_1.WINDOWS: {
27
+ const name = process.env.COMPUTERNAME;
28
+ if (name) {
29
+ return process.env.USERDNSDOMAIN ? `${name}.${process.env.USERDNSDOMAIN}` : name;
30
+ }
31
+ break;
32
+ }
29
33
  default:
30
34
  return (0, node_os_1.hostname)();
31
35
  }
@@ -28,6 +28,6 @@ export declare const sanitizeContainerID: (str: string) => string;
28
28
  export declare const sanitizeImageID: (str: string) => string;
29
29
  export declare const isPrototypePolluted: () => boolean;
30
30
  export declare const sanitizeUrl: (url: string) => string;
31
- export declare const sanitizeServiceString: (str: string) => any;
31
+ export declare const sanitizeServiceString: (str: string) => string[];
32
32
  export declare const sanitizeInterfacesString: (interfaces: string) => string;
33
33
  export declare const sanitizeString: (str: string, strict?: any) => string;
@@ -201,7 +201,7 @@ const sanitizeServiceString = (str) => {
201
201
  if ((0, exports.isPrototypePolluted)() && srvString !== '*') {
202
202
  srvString = '------';
203
203
  }
204
- return srvString.split('|');
204
+ return Reflect.apply(exports.stringSplit, srvString, ['|']);
205
205
  }
206
206
  return ['*'];
207
207
  };
@@ -5,14 +5,13 @@ const node_child_process_1 = require("node:child_process");
5
5
  const exec_1 = require("./exec");
6
6
  const files_1 = require("../common/files");
7
7
  const const_1 = require("./const");
8
- const WINDIR = process.env.WINDIR || String.raw `C:\Windows`;
9
8
  const JOB_TIMEOUT_MS = 60000;
10
9
  let _powerShell = '';
11
10
  const pickPowerShellExecutable = async () => {
12
11
  if (!const_1.WINDOWS)
13
12
  return '';
14
13
  if (!_powerShell) {
15
- const defaultPath = String.raw `${WINDIR}\system32\WindowsPowerShell\v1.0\powershell.exe`;
14
+ const defaultPath = String.raw `${const_1.WINDIR}\system32\WindowsPowerShell\v1.0\powershell.exe`;
16
15
  if (await (0, files_1.fileExists)(defaultPath)) {
17
16
  _powerShell = defaultPath;
18
17
  }
@@ -65,6 +64,7 @@ class PowerShellWorker {
65
64
  this.child = (0, node_child_process_1.spawn)(this.exe, args, {
66
65
  stdio: 'pipe',
67
66
  windowsHide: true,
67
+ cwd: const_1.WIN_CWD,
68
68
  env: { ...process.env, ...this.env }
69
69
  });
70
70
  this.child.stdout.setEncoding('utf8');
@@ -1,23 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.osInfo = void 0;
4
+ const promises_1 = require("node:fs/promises");
4
5
  const common_1 = require("../common");
5
6
  const codepage_1 = require("../common/codepage");
7
+ const const_1 = require("../common/const");
6
8
  const defaults_1 = require("../common/defaults");
7
- const exec_1 = require("../common/exec");
8
9
  const mappings_1 = require("../common/mappings");
9
10
  const windows_1 = require("../common/windows");
10
11
  const windowsIsUefi = async () => {
11
12
  try {
12
- const { stdout } = await (0, exec_1.exec)('findstr /C:"Detected boot environment" "%windir%\\Panther\\setupact.log"');
13
- const line = stdout.split('\n\r')[0];
14
- return line.toLowerCase().indexOf('efi') >= 0;
15
- }
16
- catch {
17
- const { stdout } = await (0, exec_1.exec)('echo %firmware_type%');
18
- const line = stdout.toString() || '';
19
- return line.toLowerCase().indexOf('efi') >= 0;
13
+ const logFile = `${const_1.WINDIR}\\Panther\\setupact.log`;
14
+ if ((await (0, promises_1.stat)(logFile)).size > 50 * 1024 * 1024) {
15
+ throw new Error('setupact.log too large');
16
+ }
17
+ const content = await (0, promises_1.readFile)(logFile, 'latin1');
18
+ const line = content
19
+ .split('\n')
20
+ .filter((l) => l.includes('Detected boot environment'))
21
+ .join('\n');
22
+ if (line) {
23
+ return line.toLowerCase().includes('efi');
24
+ }
20
25
  }
26
+ catch { }
27
+ return (process.env.firmware_type || '').toLowerCase().includes('efi');
21
28
  };
22
29
  const osInfo = async () => {
23
30
  await (0, common_1.nextTick)();
@@ -4,6 +4,17 @@ exports.services = void 0;
4
4
  const common_1 = require("../common");
5
5
  const security_1 = require("../common/security");
6
6
  const windows_1 = require("../common/windows");
7
+ const psServiceName = (srv) => {
8
+ const s = String(srv);
9
+ let name = '';
10
+ for (let i = 0; i < s.length; i++) {
11
+ const c = s[i] || '';
12
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c === ' ' || c === '_' || c === '.' || c === '-' || c === '@') {
13
+ name += c;
14
+ }
15
+ }
16
+ return name;
17
+ };
7
18
  const services = async (srv) => {
8
19
  await (0, common_1.nextTick)();
9
20
  const result = [];
@@ -15,7 +26,7 @@ const services = async (srv) => {
15
26
  if (srvs[0] !== '*') {
16
27
  wincommand += ' -Filter "';
17
28
  srvs.forEach((srv) => {
18
- wincommand += `Name='${srv.replace(/[^a-zA-Z0-9 _.\-@]/g, '')}' or `;
29
+ wincommand += `Name='${psServiceName(srv)}' or `;
19
30
  });
20
31
  wincommand = `${wincommand.slice(0, -4)}"`;
21
32
  }
@@ -10,14 +10,11 @@ const uuid = async () => {
10
10
  await (0, common_1.nextTick)();
11
11
  const result = (0, common_1.cloneObj)(defaults_1.initUUID);
12
12
  try {
13
- let sysdir = '%windir%\\System32';
14
- if (process.arch === 'ia32' && Object.prototype.hasOwnProperty.call(process.env, 'PROCESSOR_ARCHITEW6432')) {
15
- sysdir = '%windir%\\sysnative\\cmd.exe /c %windir%\\System32';
16
- }
13
+ const sysdir = process.arch === 'ia32' && Object.prototype.hasOwnProperty.call(process.env, 'PROCESSOR_ARCHITEW6432') ? 'Sysnative' : 'System32';
17
14
  const psOut = await windows_1.ps.exec('Get-CimInstance Win32_ComputerSystemProduct | select UUID | fl');
18
15
  const lines = psOut.toString().split('\r\n');
19
16
  result.hardware = (0, common_1.getValue)(lines, 'uuid', ':').toLowerCase();
20
- const { stdout } = await (0, exec_1.exec)(`${sysdir}\\reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid`, const_1.execOptsWin);
17
+ const { stdout } = await (0, exec_1.execFile)(`${const_1.WINDIR}\\${sysdir}\\reg.exe`, ['query', 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography', '/v', 'MachineGuid'], const_1.execOptsWin);
21
18
  const parts = stdout.toString().split('\n\r')[0].split('REG_SZ');
22
19
  result.os = parts.length > 1 ? parts[1].replace(/\r+|\n+|\s+/gi, '').toLowerCase() : '';
23
20
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "6.0.0-beta.22",
3
+ "version": "6.0.0-beta.24",
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)",