systeminformation 5.31.17 → 5.33.0

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/osinfo.js CHANGED
@@ -190,7 +190,7 @@ function getWindowsRelease(build) {
190
190
  // FQDN
191
191
 
192
192
  function getFQDN() {
193
- let fqdn = os.hostname;
193
+ let fqdn = os.hostname();
194
194
  if (_linux || _darwin) {
195
195
  try {
196
196
  const stdout = execSync('hostname -f 2>/dev/null', util.execOptsLinux);
@@ -292,7 +292,7 @@ function osInfo(callback) {
292
292
  const distro = util.getValue(lines, 'kern.ostype');
293
293
  const logofile = getLogoFile(distro);
294
294
  const release = util.getValue(lines, 'kern.osrelease').split('-')[0];
295
- const serial = util.getValue(lines, 'kern.uuid');
295
+ const serial = util.getValue(lines, 'kern.hostuuid');
296
296
  const bootmethod = util.getValue(lines, 'machdep.bootmethod');
297
297
  const uefiConf = stdout.toString().indexOf('<type>efi</type>') >= 0;
298
298
  const uefi = bootmethod ? bootmethod.toLowerCase().indexOf('uefi') >= 0 : uefiConf ? uefiConf : null;
@@ -547,6 +547,13 @@ function versions(apps, callback) {
547
547
  const appsObj = checkVersionParam(apps);
548
548
  let totalFunctions = appsObj.counter;
549
549
 
550
+ if (totalFunctions <= 0) {
551
+ if (callback) {
552
+ callback(appsObj.versions);
553
+ }
554
+ return resolve(appsObj.versions);
555
+ }
556
+
550
557
  let functionProcessed = (() => {
551
558
  return () => {
552
559
  if (--totalFunctions === 0) {
@@ -824,6 +831,7 @@ function versions(apps, callback) {
824
831
  if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
825
832
  appsObj.versions.postgresql = postgresql[postgresql.length - 2];
826
833
  }
834
+ functionProcessed();
827
835
  } else {
828
836
  exec('pg_config --version', (error, stdout) => {
829
837
  if (!error) {
@@ -833,9 +841,9 @@ function versions(apps, callback) {
833
841
  appsObj.versions.postgresql = postgresql[postgresql.length - 2];
834
842
  }
835
843
  }
844
+ functionProcessed();
836
845
  });
837
846
  }
838
- functionProcessed();
839
847
  });
840
848
  }
841
849
  }
@@ -1151,7 +1159,6 @@ function shell(callback) {
1151
1159
  process.nextTick(() => {
1152
1160
  if (_windows) {
1153
1161
  try {
1154
- const result = 'CMD';
1155
1162
  util.powerShell(`Get-CimInstance -className win32_process | where-object {$_.ProcessId -eq ${process.ppid} } | select Name`).then((stdout) => {
1156
1163
  let result = 'CMD';
1157
1164
  if (stdout) {
@@ -1166,9 +1173,9 @@ function shell(callback) {
1166
1173
  });
1167
1174
  } catch {
1168
1175
  if (callback) {
1169
- callback(result);
1176
+ callback('CMD');
1170
1177
  }
1171
- resolve(result);
1178
+ resolve('CMD');
1172
1179
  }
1173
1180
  } else {
1174
1181
  let result = '';
@@ -1258,9 +1265,13 @@ echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`;
1258
1265
  result.os = util.getValue(lines, 'os').toLowerCase();
1259
1266
  result.hardware = util.getValue(lines, 'hardware').toLowerCase();
1260
1267
  if (!result.hardware) {
1261
- const lines = fs.readFileSync('/proc/cpuinfo', { encoding: 'utf8' }).toString().split('\n');
1262
- const serial = util.getValue(lines, 'serial');
1263
- result.hardware = serial || '';
1268
+ try {
1269
+ const lines = fs.readFileSync('/proc/cpuinfo', { encoding: 'utf8' }).toString().split('\n');
1270
+ const serial = util.getValue(lines, 'serial');
1271
+ result.hardware = serial || '';
1272
+ } catch {
1273
+ result.hardware = '';
1274
+ }
1264
1275
  }
1265
1276
  if (callback) {
1266
1277
  callback(result);
package/lib/printer.js CHANGED
@@ -121,7 +121,7 @@ function printer(callback) {
121
121
  // printers.conf
122
122
  if (!error) {
123
123
  const parts = stdout.toString().split('<Printer ');
124
- const printerHeader = parseLinuxCupsHeader(parts[0]);
124
+ const printerHeader = parseLinuxCupsHeader(parts[0].split('\n'));
125
125
  for (let i = 1; i < parts.length; i++) {
126
126
  const printers = parseLinuxCupsPrinter(parts[i].split('\n'));
127
127
  if (printers.name) {
@@ -141,11 +141,11 @@ function printer(callback) {
141
141
  const printers = parseLinuxLpstatPrinter(parts[i].split('\n'), i);
142
142
  result.push(printers);
143
143
  }
144
+ if (callback) {
145
+ callback(result);
146
+ }
147
+ resolve(result);
144
148
  });
145
- if (callback) {
146
- callback(result);
147
- }
148
- resolve(result);
149
149
  } else {
150
150
  if (callback) {
151
151
  callback(result);
package/lib/processes.js CHANGED
@@ -207,7 +207,7 @@ function services(srv, callback) {
207
207
  if (callback) {
208
208
  callback(result);
209
209
  }
210
- resolve(result);
210
+ return resolve(result);
211
211
  }
212
212
  let args = _darwin ? ['-caxo', 'pcpu,pmem,pid,command'] : ['-axo', 'pcpu,pmem,pid,command'];
213
213
  if (srvString !== '' && srvs.length > 0) {
@@ -307,7 +307,7 @@ function services(srv, callback) {
307
307
  // store old values
308
308
  _services_cpu.all = all;
309
309
  _services_cpu.list = Object.assign({}, list_new);
310
- _services_cpu.ms = Date.now() - _services_cpu.ms;
310
+ _services_cpu.ms = Date.now();
311
311
  _services_cpu.result = Object.assign({}, result);
312
312
  if (callback) {
313
313
  callback(result);
@@ -365,8 +365,7 @@ function services(srv, callback) {
365
365
  }
366
366
  resolve(result);
367
367
  }
368
- }
369
- if (_windows) {
368
+ } else if (_windows) {
370
369
  try {
371
370
  let wincommand = 'Get-CimInstance Win32_Service';
372
371
  if (srvs[0] !== '*') {
@@ -442,6 +441,11 @@ function services(srv, callback) {
442
441
  }
443
442
  resolve(result);
444
443
  }
444
+ } else {
445
+ if (callback) {
446
+ callback(result);
447
+ }
448
+ resolve(result);
445
449
  }
446
450
  } else {
447
451
  if (callback) {
@@ -568,6 +572,9 @@ function processes(callback) {
568
572
  }
569
573
 
570
574
  function parseLine(line) {
575
+ if (parsedhead.length < 13) {
576
+ return null;
577
+ }
571
578
  let offset = 0;
572
579
  let offset2 = 0;
573
580
 
@@ -709,7 +716,10 @@ function processes(callback) {
709
716
  lines.shift();
710
717
  lines.forEach((line) => {
711
718
  if (line.trim() !== '') {
712
- result.push(parseLine(line));
719
+ const parsed = parseLine(line);
720
+ if (parsed) {
721
+ result.push(parsed);
722
+ }
713
723
  }
714
724
  });
715
725
  }
@@ -737,7 +747,15 @@ function processes(callback) {
737
747
  started = formatDateTime(new Date(Date.now() - (elapsed_parts[0] * 60 + elapsed_parts[1] * 1) * 60 * 1000));
738
748
  } else if (etime.indexOf(':') >= 0) {
739
749
  const elapsed_parts = etime.split(':');
740
- started = formatDateTime(new Date(Date.now() - (elapsed_parts.length > 1 ? (elapsed_parts[0] * 60 + elapsed_parts[1]) * 1000 : elapsed_parts[0] * 1000)));
750
+ let seconds = 0;
751
+ if (elapsed_parts.length === 3) {
752
+ seconds = elapsed_parts[0] * 3600 + elapsed_parts[1] * 60 + elapsed_parts[2] * 1;
753
+ } else if (elapsed_parts.length === 2) {
754
+ seconds = elapsed_parts[0] * 60 + elapsed_parts[1] * 1;
755
+ } else {
756
+ seconds = elapsed_parts[0] * 1;
757
+ }
758
+ started = formatDateTime(new Date(Date.now() - seconds * 1000));
741
759
  }
742
760
  return started;
743
761
  }
@@ -877,7 +895,7 @@ function processes(callback) {
877
895
  // store old values
878
896
  _processes_cpu.all = all;
879
897
  _processes_cpu.list = Object.assign({}, list_new);
880
- _processes_cpu.ms = Date.now() - _processes_cpu.ms;
898
+ _processes_cpu.ms = Date.now();
881
899
  _processes_cpu.result = Object.assign({}, result);
882
900
  if (callback) {
883
901
  callback(result);
@@ -948,6 +966,9 @@ function processes(callback) {
948
966
  try {
949
967
  stdout = stdout.trim().replace(/^\uFEFF/, '');
950
968
  processArray = JSON.parse(stdout);
969
+ if (!Array.isArray(processArray)) {
970
+ processArray = [processArray];
971
+ }
951
972
  } catch {}
952
973
  processArray.forEach((element) => {
953
974
  const pid = element.ProcessId;
@@ -989,7 +1010,7 @@ function processes(callback) {
989
1010
  cpuu: 0,
990
1011
  cpus: 0,
991
1012
  mem: (memw / os.totalmem()) * 100,
992
- priority: element.Priority | null,
1013
+ priority: element.Priority || null,
993
1014
  memVsz: element.PageFileUsage || null,
994
1015
  memRss: Math.floor((element.WorkingSetSize || 0) / 1024),
995
1016
  nice: 0,
@@ -1030,7 +1051,7 @@ function processes(callback) {
1030
1051
  _processes_cpu.all_utime = allcpuu;
1031
1052
  _processes_cpu.all_stime = allcpus;
1032
1053
  _processes_cpu.list = Object.assign({}, list_new);
1033
- _processes_cpu.ms = Date.now() - _processes_cpu.ms;
1054
+ _processes_cpu.ms = Date.now();
1034
1055
  _processes_cpu.result = Object.assign({}, result);
1035
1056
  }
1036
1057
  if (callback) {
@@ -1139,6 +1160,9 @@ function processLoad(proc, callback) {
1139
1160
  try {
1140
1161
  stdout = stdout.trim().replace(/^\uFEFF/, '');
1141
1162
  processArray = JSON.parse(stdout);
1163
+ if (!Array.isArray(processArray)) {
1164
+ processArray = [processArray];
1165
+ }
1142
1166
  } catch {}
1143
1167
 
1144
1168
  // go through all processes
@@ -1233,7 +1257,7 @@ function processLoad(proc, callback) {
1233
1257
  _process_cpu.all_utime = allcpuu;
1234
1258
  _process_cpu.all_stime = allcpus;
1235
1259
  _process_cpu.list = Object.assign({}, list_new);
1236
- _process_cpu.ms = Date.now() - _process_cpu.ms;
1260
+ _process_cpu.ms = Date.now();
1237
1261
  _process_cpu.result = JSON.parse(JSON.stringify(result));
1238
1262
  if (callback) {
1239
1263
  callback(result);
@@ -1247,9 +1271,7 @@ function processLoad(proc, callback) {
1247
1271
  }
1248
1272
  resolve(result);
1249
1273
  }
1250
- }
1251
-
1252
- if (_darwin || _linux || _freebsd || _openbsd || _netbsd) {
1274
+ } else if (_darwin || _linux || _freebsd || _openbsd || _netbsd) {
1253
1275
  const params = ['-axo', 'pid,ppid,pcpu,pmem,comm'];
1254
1276
  util.execSafe('ps', params).then((stdout) => {
1255
1277
  if (stdout) {
@@ -1270,7 +1292,9 @@ function processLoad(proc, callback) {
1270
1292
  });
1271
1293
  return found;
1272
1294
  });
1273
- lines.shift();
1295
+ if (processesString === '*') {
1296
+ lines.shift();
1297
+ }
1274
1298
  lines.forEach((line) => {
1275
1299
  const data = line.trim().replace(/ +/g, ' ').split(' ');
1276
1300
  if (data.length > 4) {
@@ -1396,7 +1420,7 @@ function processLoad(proc, callback) {
1396
1420
 
1397
1421
  _process_cpu.all = all;
1398
1422
  _process_cpu.list = Object.assign({}, list_new);
1399
- _process_cpu.ms = Date.now() - _process_cpu.ms;
1423
+ _process_cpu.ms = Date.now();
1400
1424
  _process_cpu.result = Object.assign({}, result);
1401
1425
  if (callback) {
1402
1426
  callback(result);
@@ -1416,7 +1440,17 @@ function processLoad(proc, callback) {
1416
1440
  resolve(result);
1417
1441
  }
1418
1442
  });
1443
+ } else {
1444
+ if (callback) {
1445
+ callback(result);
1446
+ }
1447
+ resolve(result);
1448
+ }
1449
+ } else {
1450
+ if (callback) {
1451
+ callback(result);
1419
1452
  }
1453
+ resolve(result);
1420
1454
  }
1421
1455
  });
1422
1456
  });
package/lib/system.js CHANGED
@@ -16,7 +16,6 @@
16
16
  const fs = require('fs');
17
17
  const os = require('os');
18
18
  const util = require('./util');
19
- const { uuid } = require('./osinfo');
20
19
  const exec = require('child_process').exec;
21
20
  const execSync = require('child_process').execSync;
22
21
  const execPromise = util.promisify(require('child_process').exec);
@@ -123,7 +122,7 @@ function system(callback) {
123
122
  }
124
123
  if (!result.virtual) {
125
124
  try {
126
- const disksById = execSync('ls -1 /dev/disk/by-id/ 2>/dev/null; pciconf -lv 2>/dev/null', util.execOptsLinux).toString();
125
+ const disksById = execSync('ls -1 /dev/disk/by-id/ 2>/dev/null; pciconf -lv 2>/dev/null || true', util.execOptsLinux).toString();
127
126
  if (disksById.indexOf('_QEMU_') >= 0 || disksById.indexOf('QEMU ') >= 0) {
128
127
  result.virtual = true;
129
128
  result.virtualHost = 'QEMU';
@@ -781,7 +780,7 @@ function chassis(callback) {
781
780
  let lines = stdout.toString().split('\n');
782
781
  result.manufacturer = cleanDefaults(util.getValue(lines, 'chassis_vendor'));
783
782
  const ctype = parseInt(util.getValue(lines, 'chassis_type').replace(/\D/g, ''));
784
- result.type = cleanDefaults(ctype && !isNaN(ctype) && ctype < chassisTypes.length ? chassisTypes[ctype - 1] : '');
783
+ result.type = cleanDefaults(ctype && !isNaN(ctype) && ctype <= chassisTypes.length ? chassisTypes[ctype - 1] : '');
785
784
  result.version = cleanDefaults(util.getValue(lines, 'chassis_version'));
786
785
  result.serial = cleanDefaults(util.getValue(lines, 'chassis_serial'));
787
786
  result.assetTag = cleanDefaults(util.getValue(lines, 'chassis_asset_tag'));
@@ -827,7 +826,7 @@ function chassis(callback) {
827
826
  result.manufacturer = cleanDefaults(util.getValue(lines, 'manufacturer', ':'));
828
827
  result.model = cleanDefaults(util.getValue(lines, 'model', ':'));
829
828
  const ctype = parseInt(util.getValue(lines, 'ChassisTypes', ':').replace(/\D/g, ''));
830
- result.type = ctype && !isNaN(ctype) && ctype < chassisTypes.length ? chassisTypes[ctype - 1] : '';
829
+ result.type = ctype && !isNaN(ctype) && ctype <= chassisTypes.length ? chassisTypes[ctype - 1] : '';
831
830
  result.version = cleanDefaults(util.getValue(lines, 'version', ':'));
832
831
  result.serial = cleanDefaults(util.getValue(lines, 'serialnumber', ':'));
833
832
  result.assetTag = cleanDefaults(util.getValue(lines, 'partnumber', ':'));
package/lib/usb.js CHANGED
@@ -275,10 +275,6 @@ function usb(callback) {
275
275
  result.push(usb);
276
276
  }
277
277
  }
278
- if (callback) {
279
- callback(result);
280
- }
281
- resolve(result);
282
278
  }
283
279
  if (callback) {
284
280
  callback(result);
package/lib/util.js CHANGED
@@ -201,14 +201,8 @@ function parseTime(t, pmDesignator) {
201
201
  if (parts[2]) {
202
202
  parts[1] += parts[2];
203
203
  }
204
- let isPM =
205
- (parts[1] && parts[1].toLowerCase().indexOf('pm') > -1) ||
206
- parts[1].toLowerCase().indexOf('p.m.') > -1 ||
207
- parts[1].toLowerCase().indexOf('p. m.') > -1 ||
208
- parts[1].toLowerCase().indexOf('n') > -1 ||
209
- parts[1].toLowerCase().indexOf('ch') > -1 ||
210
- parts[1].toLowerCase().indexOf('ös') > -1 ||
211
- (pmDesignator && parts[1].toLowerCase().indexOf(pmDesignator) > -1);
204
+ const p1 = (parts[1] || '').toLowerCase();
205
+ let isPM = p1.indexOf('pm') > -1 || p1.indexOf('p.m.') > -1 || p1.indexOf('p. m.') > -1 || p1.indexOf('n') > -1 || p1.indexOf('ch') > -1 || p1.indexOf('ös') > -1 || (pmDesignator && p1.indexOf(pmDesignator) > -1);
212
206
  hour = parseInt(parts[0], 10);
213
207
  min = parseInt(parts[1], 10);
214
208
  hour = isPM && hour < 12 ? hour + 12 : hour;
@@ -364,7 +358,8 @@ function getPowershell() {
364
358
  }
365
359
 
366
360
  function getVboxmanage() {
367
- return _windows ? `"${process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH}\\VBoxManage.exe"` : 'vboxmanage';
361
+ const vboxPath = (process.env.VBOX_INSTALL_PATH || process.env.VBOX_MSI_INSTALL_PATH || '').replace(/["%!^&|<>`$;\r\n]/g, '');
362
+ return _windows ? `"${vboxPath}\\VBoxManage.exe"` : 'vboxmanage';
368
363
  }
369
364
 
370
365
  function powerShellProceedResults(data) {
@@ -621,7 +616,7 @@ function smartMonToolsInstalled() {
621
616
  const pathArray = execSync('which smartctl 2>/dev/null', execOptsLinux).toString().split('\r\n');
622
617
  _smartMonToolsInstalled = pathArray.length > 0;
623
618
  } catch {
624
- util.noop();
619
+ noop();
625
620
  }
626
621
  }
627
622
  return _smartMonToolsInstalled;
@@ -734,6 +729,9 @@ function sanitizeShellString(str, strict) {
734
729
  s[i] === '&' ||
735
730
  s[i] === ']' ||
736
731
  s[i] === '#' ||
732
+ s[i] === '%' ||
733
+ s[i] === '!' ||
734
+ s[i] === '^' ||
737
735
  s[i] === '\\' ||
738
736
  s[i] === '\t' ||
739
737
  s[i] === '\n' ||
@@ -757,6 +755,20 @@ function sanitizeShellString(str, strict) {
757
755
  return result;
758
756
  }
759
757
 
758
+ function sanitizeContainerID(str) {
759
+ const s = String(str || '')
760
+ .substring(0, 2000)
761
+ .replace(/[^a-zA-Z0-9_.,*-]/g, '');
762
+ return s.indexOf('..') === -1 ? s : '';
763
+ }
764
+
765
+ function sanitizeImageID(str) {
766
+ const s = String(str || '')
767
+ .substring(0, 2000)
768
+ .replace(/[^a-zA-Z0-9_.,:@/-]/g, '');
769
+ return s.indexOf('..') === -1 ? s : '';
770
+ }
771
+
760
772
  function isPrototypePolluted() {
761
773
  const s = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
762
774
  let notPolluted = true;
@@ -1285,7 +1297,7 @@ function plistParser(xmlStr) {
1285
1297
  if (depth > 1 && metaData[depth - 2].tagStart === 'array') {
1286
1298
  metaData[depth - 2].data.push(metaData[depth - 1].data);
1287
1299
  }
1288
- if (depth > 1 && metaData[depth - 2].tagStart === 'dict') {
1300
+ if (depth > 1 && metaData[depth - 2].tagStart === 'dict' && !isProtoKey(metaData[depth - 1].key)) {
1289
1301
  metaData[depth - 2].data[metaData[depth - 1].key] = metaData[depth - 1].data;
1290
1302
  }
1291
1303
  depth--;
@@ -1315,7 +1327,7 @@ function plistParser(xmlStr) {
1315
1327
  if (depth > 0 && metaData[depth - 1].tagStart === 'array') {
1316
1328
  metaData[depth - 1].data.push(metaData[depth].data);
1317
1329
  }
1318
- if (depth > 0 && metaData[depth - 1].tagStart === 'dict') {
1330
+ if (depth > 0 && metaData[depth - 1].tagStart === 'dict' && !isProtoKey(metaData[depth].key)) {
1319
1331
  metaData[depth - 1].data[metaData[depth].key] = metaData[depth].data;
1320
1332
  }
1321
1333
  }
@@ -1389,8 +1401,8 @@ function plistReader(output) {
1389
1401
 
1390
1402
  function semverCompare(v1, v2) {
1391
1403
  let res = 0;
1392
- const parts1 = v1.split('.');
1393
- const parts2 = v2.split('.');
1404
+ const parts1 = v1.split('.').map((p) => parseInt(p, 10) || 0);
1405
+ const parts2 = v2.split('.').map((p) => parseInt(p, 10) || 0);
1394
1406
  if (parts1[0] < parts2[0]) {
1395
1407
  res = 1;
1396
1408
  } else if (parts1[0] > parts2[0]) {
@@ -2745,6 +2757,10 @@ function grep(str, pattern) {
2745
2757
 
2746
2758
  function noop() {}
2747
2759
 
2760
+ function isProtoKey(key) {
2761
+ return key === '__proto__' || key === 'constructor' || key === 'prototype';
2762
+ }
2763
+
2748
2764
  exports.toInt = toInt;
2749
2765
  exports.splitByNumber = splitByNumber;
2750
2766
  exports.execOptsWin = execOptsWin;
@@ -2773,6 +2789,8 @@ exports.noop = noop;
2773
2789
  exports.isRaspberry = isRaspberry;
2774
2790
  exports.isRaspbian = isRaspbian;
2775
2791
  exports.sanitizeShellString = sanitizeShellString;
2792
+ exports.sanitizeContainerID = sanitizeContainerID;
2793
+ exports.sanitizeImageID = sanitizeImageID;
2776
2794
  exports.isPrototypePolluted = isPrototypePolluted;
2777
2795
  exports.sanitizeString = sanitizeString;
2778
2796
  exports.decodePiCpuinfo = decodePiCpuinfo;
package/lib/virtualbox.js CHANGED
@@ -35,8 +35,11 @@ function vboxInfo(callback) {
35
35
  try {
36
36
  if (running) {
37
37
  const sinceDateObj = new Date(runningSinceString);
38
- const offset = sinceDateObj.getTimezoneOffset();
39
- runningSince = Math.round((Date.now() - Date.parse(sinceDateObj)) / 1000) + offset * 60;
38
+ const parsed = Date.parse(sinceDateObj);
39
+ if (!isNaN(parsed)) {
40
+ const offset = sinceDateObj.getTimezoneOffset();
41
+ runningSince = Math.round((Date.now() - parsed) / 1000) + offset * 60;
42
+ }
40
43
  }
41
44
  } catch {
42
45
  util.noop();
@@ -46,8 +49,11 @@ function vboxInfo(callback) {
46
49
  try {
47
50
  if (!running) {
48
51
  const sinceDateObj = new Date(stoppedSinceString);
49
- const offset = sinceDateObj.getTimezoneOffset();
50
- stoppedSince = Math.round((Date.now() - Date.parse(sinceDateObj)) / 1000) + offset * 60;
52
+ const parsed = Date.parse(sinceDateObj);
53
+ if (!isNaN(parsed)) {
54
+ const offset = sinceDateObj.getTimezoneOffset();
55
+ stoppedSince = Math.round((Date.now() - parsed) / 1000) + offset * 60;
56
+ }
51
57
  }
52
58
  } catch {
53
59
  util.noop();
package/lib/wifi.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use strict';
1
2
  // @ts-check
2
3
  // ==================================================================================
3
4
  // wifi.js
@@ -25,6 +26,9 @@ const _windows = _platform === 'win32';
25
26
 
26
27
  function wifiDBFromQuality(quality) {
27
28
  const qual = parseFloat(quality);
29
+ if (isNaN(qual)) {
30
+ return null;
31
+ }
28
32
  if (qual < 0) {
29
33
  return 0;
30
34
  }
@@ -35,7 +39,11 @@ function wifiDBFromQuality(quality) {
35
39
  }
36
40
 
37
41
  function wifiQualityFromDB(db) {
38
- const result = 2 * (parseFloat(db) + 100);
42
+ const dbValue = parseFloat(db);
43
+ if (isNaN(dbValue)) {
44
+ return null;
45
+ }
46
+ const result = 2 * (dbValue + 100);
39
47
  return result <= 100 ? result : 100;
40
48
  }
41
49
 
@@ -116,13 +124,13 @@ const _wifi_frequencies = {
116
124
  };
117
125
 
118
126
  function wifiFrequencyFromChannel(channel) {
119
- return Object.hasOwn(_wifi_frequencies, channel) ? _wifi_frequencies[channel] : null;
127
+ return {}.hasOwnProperty.call(_wifi_frequencies, channel) ? _wifi_frequencies[channel] : null;
120
128
  }
121
129
 
122
130
  function wifiChannelFromFrequencs(frequency) {
123
131
  let channel = 0;
124
132
  for (const key in _wifi_frequencies) {
125
- if (Object.hasOwn(_wifi_frequencies, key)) {
133
+ if ({}.hasOwnProperty.call(_wifi_frequencies, key)) {
126
134
  if (_wifi_frequencies[key] === frequency) {
127
135
  channel = util.toInt(key);
128
136
  }
@@ -332,11 +340,11 @@ function getWifiNetworkListIw(iface) {
332
340
  if (l.indexOf('pairwise cipher') >= 0) {
333
341
  const parts = l.split(':');
334
342
  if (parts.length > 1) {
335
- if (parts[1].indexOf('tkip')) {
343
+ if (parts[1].indexOf('tkip') >= 0) {
336
344
  wpaFlag = wpaFlag ? 'TKIP/' + wpaFlag : 'TKIP';
337
- } else if (parts[1].indexOf('ccmp')) {
345
+ } else if (parts[1].indexOf('ccmp') >= 0) {
338
346
  wpaFlag = wpaFlag ? 'CCMP/' + wpaFlag : 'CCMP';
339
- } else if (parts[1].indexOf('proprietary')) {
347
+ } else if (parts[1].indexOf('proprietary') >= 0) {
340
348
  wpaFlag = wpaFlag ? 'PROP/' + wpaFlag : 'PROP';
341
349
  }
342
350
  }
@@ -344,9 +352,9 @@ function getWifiNetworkListIw(iface) {
344
352
  if (l.indexOf('authentication suites') >= 0) {
345
353
  const parts = l.split(':');
346
354
  if (parts.length > 1) {
347
- if (parts[1].indexOf('802.1x')) {
355
+ if (parts[1].indexOf('802.1x') >= 0) {
348
356
  wpaFlag = wpaFlag ? '802.1x/' + wpaFlag : '802.1x';
349
- } else if (parts[1].indexOf('psk')) {
357
+ } else if (parts[1].indexOf('psk') >= 0) {
350
358
  wpaFlag = wpaFlag ? 'PSK/' + wpaFlag : 'PSK';
351
359
  }
352
360
  }
@@ -495,6 +503,9 @@ function wifiNetworks(callback) {
495
503
 
496
504
  bssidsParts.forEach((bssidPart) => {
497
505
  const bssidLines = bssidPart.split(os.EOL);
506
+ if (bssidLines.length < 4) {
507
+ return;
508
+ }
498
509
  const bssidLine = bssidLines[0].split(':');
499
510
  bssidLine.shift();
500
511
  const bssid = bssidLine.join(':').trim().toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.31.17",
3
+ "version": "5.33.0",
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)",
@@ -13,7 +13,8 @@
13
13
  "types": "./lib/index.d.ts",
14
14
  "scripts": {
15
15
  "test": "node ./test/test.js",
16
- "testDeno": "deno run -A ./test/test.js"
16
+ "testDeno": "deno run -A ./test/test.js",
17
+ "testAll": "node ./test/testAll.js"
17
18
  },
18
19
  "files": [
19
20
  "lib/"
@@ -96,6 +97,6 @@
96
97
  "android"
97
98
  ],
98
99
  "engines": {
99
- "node": ">=8.0.0"
100
+ "node": ">=10.0.0"
100
101
  }
101
102
  }