systeminformation 6.0.0-beta.21 → 6.0.0-beta.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.
@@ -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
  };
@@ -18,7 +18,7 @@ const disksIO = async () => {
18
18
  let wWaitTime = 0;
19
19
  let tWaitTime = 0;
20
20
  try {
21
- const disks = (await (0, promises_1.readdir)('/sys/block')).filter((dev) => !/^(loop|ram|dm-|md|sr|fd|nbd)/.test(dev) && (0, security_1.isSafePathSegment)(dev));
21
+ const disks = (await (0, promises_1.readdir)('/sys/block')).filter((dev) => !/^(loop|ram|zram|dm-|md|sr|fd|nbd|zd)/.test(dev) && (0, security_1.isSafePathSegment)(dev));
22
22
  const lines = await Promise.all(disks.map((dev) => (0, files_1.readSysfs)(`/sys/block/${dev}/stat`)));
23
23
  lines.forEach(function (line) {
24
24
  if (!line) {
@@ -17,8 +17,11 @@ const fsStats = async () => {
17
17
  let rx = 0;
18
18
  let wx = 0;
19
19
  try {
20
- ({ stdout } = await (0, exec_1.exec)('lsblk -r 2>/dev/null', const_1.execOptsLinux));
21
- const lines = stdout.toString().split('\n').filter((line) => line.indexOf('/') >= 0);
20
+ ({ stdout } = await (0, exec_1.exec)('lsblk -rno KNAME,FSTYPE,MOUNTPOINT 2>/dev/null', const_1.execOptsLinux));
21
+ const lines = stdout
22
+ .toString()
23
+ .split('\n')
24
+ .filter((line) => (line.indexOf('/') >= 0 || / zfs_member( |$)/.test(line)) && !/^zd\d/.test(line));
22
25
  const fs_filter = [];
23
26
  lines.forEach((line) => {
24
27
  if (line !== '') {
@@ -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.21",
3
+ "version": "6.0.0-beta.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)",