systeminformation 5.31.5 → 5.31.6

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/network.js CHANGED
@@ -16,6 +16,8 @@
16
16
  const os = require('os');
17
17
  const exec = require('child_process').exec;
18
18
  const execSync = require('child_process').execSync;
19
+ const execFileSync = require('child_process').execFileSync;
20
+
19
21
  const fs = require('fs');
20
22
  const util = require('./util');
21
23
 
@@ -416,15 +418,7 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) {
416
418
  try {
417
419
  const SSID = getWindowsWirelessIfaceSSID(iface);
418
420
  if (SSID !== 'Unknown') {
419
- let ifaceSanitized = '';
420
- const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(SSID);
421
- const l = util.mathMin(s.length, 32);
422
-
423
- for (let i = 0; i <= l; i++) {
424
- if (s[i] !== undefined) {
425
- ifaceSanitized = ifaceSanitized + s[i];
426
- }
427
- }
421
+ const ifaceSanitized = util.sanitizeString(SSID);
428
422
  const profiles = execSync(`netsh wlan show profiles "${ifaceSanitized}"`, util.execOptsWin).split('\r\n');
429
423
  i8021xState = (profiles.find((l) => l.indexOf('802.1X') >= 0) || '').trim();
430
424
  i8021xProtocol = (profiles.find((l) => l.indexOf('EAP') >= 0) || '').trim();
@@ -536,14 +530,16 @@ function getDarwinNics() {
536
530
  }
537
531
 
538
532
  function getLinuxIfaceConnectionName(interfaceName) {
539
- const cmd = `nmcli device status 2>/dev/null | grep ${interfaceName}`;
540
-
541
533
  try {
542
- const result = execSync(cmd, util.execOptsLinux).toString();
534
+ const output = execFileSync('nmcli', ['device', 'status'], { ...util.execOptsLinux, stdio: ['ignore', 'pipe', 'ignore'] }).toString();
535
+ const result = util.grep(output, interfaceName);
536
+
543
537
  const resultFormat = result.replace(/\s+/g, ' ').trim();
544
538
  const connectionNameLines = resultFormat.split(' ').slice(3);
545
539
  const connectionName = connectionNameLines.join(' ');
546
- return connectionName !== '--' ? connectionName : '';
540
+ const connectionNameSanitized = util.sanitizeString(connectionName, false);
541
+
542
+ return connectionNameSanitized !== '--' ? connectionNameSanitized : '';
547
543
  } catch {
548
544
  return '';
549
545
  }
@@ -617,9 +613,9 @@ function parseLinuxDHCPNics(sections) {
617
613
  function getLinuxIfaceDHCPstatus(iface, connectionName, DHCPNics) {
618
614
  let result = false;
619
615
  if (connectionName) {
620
- const cmd = `nmcli connection show "${connectionName}" 2>/dev/null | grep ipv4.method;`;
621
616
  try {
622
- const lines = execSync(cmd, util.execOptsLinux).toString();
617
+ const output = execFileSync('nmcli', ['connection', 'show', connectionName], { ...util.execOptsLinux, stdio: ['ignore', 'pipe', 'ignore'] }).toString();
618
+ const lines = util.grep(output, 'ipv4.method');
623
619
  const resultFormat = lines.replace(/\s+/g, ' ').trim();
624
620
 
625
621
  const dhcStatus = resultFormat.split(' ').slice(1).toString();
@@ -643,9 +639,10 @@ function getLinuxIfaceDHCPstatus(iface, connectionName, DHCPNics) {
643
639
 
644
640
  function getDarwinIfaceDHCPstatus(iface) {
645
641
  let result = false;
646
- const cmd = `ipconfig getpacket "${iface}" 2>/dev/null | grep lease_time;`;
642
+
647
643
  try {
648
- const lines = execSync(cmd).toString().split('\n');
644
+ const output = execFileSync('ipconfig', ['getpacket', iface], { ...util.execOptsLinux, stdio: ['ignore', 'pipe', 'ignore'] }).toString();
645
+ const lines = util.grep(output, 'lease_time');
649
646
  if (lines.length && lines[0].startsWith('lease_time')) {
650
647
  result = true;
651
648
  }
@@ -657,9 +654,9 @@ function getDarwinIfaceDHCPstatus(iface) {
657
654
 
658
655
  function getLinuxIfaceDNSsuffix(connectionName) {
659
656
  if (connectionName) {
660
- const cmd = `nmcli connection show "${connectionName}" 2>/dev/null | grep ipv4.dns-search;`;
661
657
  try {
662
- const result = execSync(cmd, util.execOptsLinux).toString();
658
+ const output = execFileSync('nmcli', ['connection', 'show', connectionName], { ...util.execOptsLinux, stdio: ['ignore', 'pipe', 'ignore'] }).toString();
659
+ const result = util.grep(output, 'ipv4.dns-search');
663
660
  const resultFormat = result.replace(/\s+/g, ' ').trim();
664
661
  const dnsSuffix = resultFormat.split(' ').slice(1).toString();
665
662
  return dnsSuffix === '--' ? 'Not defined' : dnsSuffix;
@@ -673,9 +670,9 @@ function getLinuxIfaceDNSsuffix(connectionName) {
673
670
 
674
671
  function getLinuxIfaceIEEE8021xAuth(connectionName) {
675
672
  if (connectionName) {
676
- const cmd = `nmcli connection show "${connectionName}" 2>/dev/null | grep 802-1x.eap;`;
677
673
  try {
678
- const result = execSync(cmd, util.execOptsLinux).toString();
674
+ const output = execFileSync('nmcli', ['connection', 'show', connectionName], { ...util.execOptsLinux, stdio: ['ignore', 'pipe', 'ignore'] }).toString();
675
+ const result = util.grep(output, '802-1x.eap');
679
676
  const resultFormat = result.replace(/\s+/g, ' ').trim();
680
677
  const authenticationProtocol = resultFormat.split(' ').slice(1).toString();
681
678
 
@@ -825,14 +822,7 @@ function networkInterfaces(callback, rescan, defaultString) {
825
822
  nic.ip6subnet = ip6linksubnet;
826
823
  }
827
824
 
828
- let ifaceSanitized = '';
829
- const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(nic.iface);
830
- const l = util.mathMin(s.length, 2000);
831
- for (let i = 0; i <= l; i++) {
832
- if (s[i] !== undefined) {
833
- ifaceSanitized = ifaceSanitized + s[i];
834
- }
835
- }
825
+ const ifaceSanitized = util.sanitizeString(nic.iface);
836
826
 
837
827
  result.push({
838
828
  iface: nic.iface,
@@ -948,14 +938,7 @@ function networkInterfaces(callback, rescan, defaultString) {
948
938
  ip6subnet = ip6linksubnet;
949
939
  }
950
940
  const iface = dev.split(':')[0].trim();
951
- let ifaceSanitized = '';
952
- const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
953
- const l = util.mathMin(s.length, 2000);
954
- for (let i = 0; i <= l; i++) {
955
- if (s[i] !== undefined) {
956
- ifaceSanitized = ifaceSanitized + s[i];
957
- }
958
- }
941
+ const ifaceSanitized = util.sanitizeString(iface);
959
942
  const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${ifaceSanitized}/addr_assign_type 2>/dev/null; echo;
960
943
  echo -n "address: "; cat /sys/class/net/${ifaceSanitized}/address 2>/dev/null; echo;
961
944
  echo -n "addr_len: "; cat /sys/class/net/${ifaceSanitized}/addr_len 2>/dev/null; echo;
@@ -1087,14 +1070,7 @@ function networkInterfaces(callback, rescan, defaultString) {
1087
1070
  nics8021xInfo = getWindowsWiredProfilesInformation();
1088
1071
  dnsSuffixes = getWindowsDNSsuffixes();
1089
1072
  for (let dev in ifaces) {
1090
- let ifaceSanitized = '';
1091
- const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(dev);
1092
- const l = util.mathMin(s.length, 2000);
1093
- for (let i = 0; i <= l; i++) {
1094
- if (s[i] !== undefined) {
1095
- ifaceSanitized = ifaceSanitized + s[i];
1096
- }
1097
- }
1073
+ const ifaceSanitized = util.sanitizeString(dev);
1098
1074
 
1099
1075
  let iface = dev;
1100
1076
  let ip4 = '';
@@ -1360,14 +1336,7 @@ function networkStatsSingle(iface) {
1360
1336
 
1361
1337
  return new Promise((resolve) => {
1362
1338
  process.nextTick(() => {
1363
- let ifaceSanitized = '';
1364
- const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
1365
- const l = util.mathMin(s.length, 2000);
1366
- for (let i = 0; i <= l; i++) {
1367
- if (s[i] !== undefined) {
1368
- ifaceSanitized = ifaceSanitized + s[i];
1369
- }
1370
- }
1339
+ const ifaceSanitized = util.sanitizeString(iface);
1371
1340
 
1372
1341
  let result = {
1373
1342
  iface: ifaceSanitized,
package/lib/osinfo.js CHANGED
@@ -18,6 +18,7 @@ const fs = require('fs');
18
18
  const util = require('./util');
19
19
  const exec = require('child_process').exec;
20
20
  const execSync = require('child_process').execSync;
21
+ const execFile = require('child_process').execFile;
21
22
 
22
23
  const _platform = process.platform;
23
24
 
@@ -820,11 +821,17 @@ function versions(apps, callback) {
820
821
  if (!error) {
821
822
  const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
822
823
  appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
824
+ if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
825
+ appsObj.versions.postgresql = postgresql[postgresql.length - 2];
826
+ }
823
827
  } else {
824
828
  exec('pg_config --version', (error, stdout) => {
825
829
  if (!error) {
826
830
  const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
827
831
  appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
832
+ if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
833
+ appsObj.versions.postgresql = postgresql[postgresql.length - 2];
834
+ }
828
835
  }
829
836
  });
830
837
  }
package/lib/util.js CHANGED
@@ -830,6 +830,22 @@ function isPrototypePolluted() {
830
830
  return !notPolluted;
831
831
  }
832
832
 
833
+ function sanitizeString(str, strict) {
834
+ if (typeof strict === 'undefined') {
835
+ strict = false;
836
+ }
837
+ let result = '';
838
+ const s = isPrototypePolluted() ? '---' : sanitizeShellString(str, strict);
839
+ const l = mathMin(s.length, 2000);
840
+
841
+ for (let i = 0; i <= l; i++) {
842
+ if (s[i] !== undefined) {
843
+ result = result + s[i];
844
+ }
845
+ }
846
+ return result;
847
+ }
848
+
833
849
  function hex2bin(hex) {
834
850
  return ('00000000' + parseInt(hex, 16).toString(2)).substr(-8);
835
851
  }
@@ -2702,6 +2718,15 @@ function checkWebsite(url, timeout = 5000) {
2702
2718
  function cleanString(str) {
2703
2719
  return str.replace(/To Be Filled By O.E.M./g, '');
2704
2720
  }
2721
+
2722
+ function grep(str, pattern) {
2723
+ const result = str
2724
+ .split('\n')
2725
+ .filter((line) => line.includes(pattern))
2726
+ .join('\n');
2727
+ return result;
2728
+ }
2729
+
2705
2730
  function noop() {}
2706
2731
 
2707
2732
  exports.toInt = toInt;
@@ -2733,6 +2758,7 @@ exports.isRaspberry = isRaspberry;
2733
2758
  exports.isRaspbian = isRaspbian;
2734
2759
  exports.sanitizeShellString = sanitizeShellString;
2735
2760
  exports.isPrototypePolluted = isPrototypePolluted;
2761
+ exports.sanitizeString = sanitizeString;
2736
2762
  exports.decodePiCpuinfo = decodePiCpuinfo;
2737
2763
  exports.getRpiGpu = getRpiGpu;
2738
2764
  exports.promiseAll = promiseAll;
@@ -2757,4 +2783,5 @@ exports.semverCompare = semverCompare;
2757
2783
  exports.getAppleModel = getAppleModel;
2758
2784
  exports.checkWebsite = checkWebsite;
2759
2785
  exports.cleanString = cleanString;
2786
+ exports.grep = grep;
2760
2787
  exports.getPowershell = getPowershell;
package/lib/wifi.js CHANGED
@@ -424,15 +424,7 @@ function wifiNetworks(callback) {
424
424
  }
425
425
  });
426
426
  if (iface) {
427
- let ifaceSanitized = '';
428
- const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface, true);
429
- const l = util.mathMin(s.length, 2000);
430
-
431
- for (let i = 0; i <= l; i++) {
432
- if (s[i] !== undefined) {
433
- ifaceSanitized = ifaceSanitized + s[i];
434
- }
435
- }
427
+ const ifaceSanitized = util.sanitizeString(iface, true);
436
428
 
437
429
  const res = getWifiNetworkListIw(ifaceSanitized);
438
430
  if (res === -1) {
@@ -585,28 +577,13 @@ function wifiConnections(callback) {
585
577
  const ifaces = ifaceListLinux();
586
578
  const networkList = getWifiNetworkListNmi();
587
579
  ifaces.forEach((ifaceDetail) => {
588
- let ifaceSanitized = '';
589
- const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(ifaceDetail.iface, true);
590
- const ll = util.mathMin(s.length, 2000);
591
-
592
- for (let i = 0; i <= ll; i++) {
593
- if (s[i] !== undefined) {
594
- ifaceSanitized = ifaceSanitized + s[i];
595
- }
596
- }
580
+ const ifaceSanitized = util.sanitizeString(ifaceDetail.iface, true);
597
581
 
598
582
  const nmiDetails = nmiDeviceLinux(ifaceSanitized);
599
583
  const wpaDetails = wpaConnectionLinux(ifaceSanitized);
600
584
  const ssid = nmiDetails.ssid || wpaDetails.ssid;
601
585
  const network = networkList.filter((nw) => nw.ssid === ssid);
602
- let ssidSanitized = '';
603
- const t = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(ssid, true);
604
- const l = util.mathMin(t.length, 32);
605
- for (let i = 0; i <= l; i++) {
606
- if (t[i] !== undefined) {
607
- ssidSanitized = ssidSanitized + t[i];
608
- }
609
- }
586
+ const ssidSanitized = util.sanitizeString(ssid, true);
610
587
 
611
588
  const nmiConnection = nmiConnectionLinux(ssidSanitized);
612
589
  const channel = network && network.length && network[0].channel ? network[0].channel : wpaDetails.channel ? wpaDetails.channel : null;
@@ -760,7 +737,9 @@ function wifiInterfaces(callback) {
760
737
  if (_linux) {
761
738
  const ifaces = ifaceListLinux();
762
739
  ifaces.forEach((ifaceDetail) => {
763
- const nmiDetails = nmiDeviceLinux(ifaceDetail.iface);
740
+ const ifaceSanitized = util.sanitizeString(ifaceDetail.iface, true);
741
+
742
+ const nmiDetails = nmiDeviceLinux(ifaceSanitized);
764
743
  result.push({
765
744
  id: ifaceDetail.id,
766
745
  iface: ifaceDetail.iface,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.31.5",
3
+ "version": "5.31.6",
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)",