systeminformation 5.17.3 → 5.17.4

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.
Files changed (2) hide show
  1. package/lib/network.js +56 -32
  2. package/package.json +1 -1
package/lib/network.js CHANGED
@@ -743,6 +743,14 @@ function networkInterfaces(callback, rescan, defaultString) {
743
743
  });
744
744
  }
745
745
 
746
+ let ifaceSanitized = '';
747
+ const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(nic.iface);
748
+ for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
749
+ if (s[i] !== undefined) {
750
+ ifaceSanitized = ifaceSanitized + s[i];
751
+ }
752
+ }
753
+
746
754
  result.push({
747
755
  iface: nic.iface,
748
756
  ifaceName: nic.iface,
@@ -759,7 +767,7 @@ function networkInterfaces(callback, rescan, defaultString) {
759
767
  duplex: nic.duplex,
760
768
  mtu: nic.mtu,
761
769
  speed: nic.speed,
762
- dhcp: getDarwinIfaceDHCPstatus(nic.iface),
770
+ dhcp: getDarwinIfaceDHCPstatus(ifaceSanitized),
763
771
  dnsSuffix: '',
764
772
  ieee8021xAuth: '',
765
773
  ieee8021xState: '',
@@ -830,37 +838,44 @@ function networkInterfaces(callback, rescan, defaultString) {
830
838
  }
831
839
  });
832
840
  let iface = dev.split(':')[0].trim().toLowerCase();
833
- const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${iface}/addr_assign_type 2>/dev/null; echo;
834
- echo -n "address: "; cat /sys/class/net/${iface}/address 2>/dev/null; echo;
835
- echo -n "addr_len: "; cat /sys/class/net/${iface}/addr_len 2>/dev/null; echo;
836
- echo -n "broadcast: "; cat /sys/class/net/${iface}/broadcast 2>/dev/null; echo;
837
- echo -n "carrier: "; cat /sys/class/net/${iface}/carrier 2>/dev/null; echo;
838
- echo -n "carrier_changes: "; cat /sys/class/net/${iface}/carrier_changes 2>/dev/null; echo;
839
- echo -n "dev_id: "; cat /sys/class/net/${iface}/dev_id 2>/dev/null; echo;
840
- echo -n "dev_port: "; cat /sys/class/net/${iface}/dev_port 2>/dev/null; echo;
841
- echo -n "dormant: "; cat /sys/class/net/${iface}/dormant 2>/dev/null; echo;
842
- echo -n "duplex: "; cat /sys/class/net/${iface}/duplex 2>/dev/null; echo;
843
- echo -n "flags: "; cat /sys/class/net/${iface}/flags 2>/dev/null; echo;
844
- echo -n "gro_flush_timeout: "; cat /sys/class/net/${iface}/gro_flush_timeout 2>/dev/null; echo;
845
- echo -n "ifalias: "; cat /sys/class/net/${iface}/ifalias 2>/dev/null; echo;
846
- echo -n "ifindex: "; cat /sys/class/net/${iface}/ifindex 2>/dev/null; echo;
847
- echo -n "iflink: "; cat /sys/class/net/${iface}/iflink 2>/dev/null; echo;
848
- echo -n "link_mode: "; cat /sys/class/net/${iface}/link_mode 2>/dev/null; echo;
849
- echo -n "mtu: "; cat /sys/class/net/${iface}/mtu 2>/dev/null; echo;
850
- echo -n "netdev_group: "; cat /sys/class/net/${iface}/netdev_group 2>/dev/null; echo;
851
- echo -n "operstate: "; cat /sys/class/net/${iface}/operstate 2>/dev/null; echo;
852
- echo -n "proto_down: "; cat /sys/class/net/${iface}/proto_down 2>/dev/null; echo;
853
- echo -n "speed: "; cat /sys/class/net/${iface}/speed 2>/dev/null; echo;
854
- echo -n "tx_queue_len: "; cat /sys/class/net/${iface}/tx_queue_len 2>/dev/null; echo;
855
- echo -n "type: "; cat /sys/class/net/${iface}/type 2>/dev/null; echo;
856
- echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null | grep ${iface}; echo;
857
- echo -n "wirelessspeed: "; iw dev ${iface} link 2>&1 | grep bitrate; echo;`;
841
+ let ifaceSanitized = '';
842
+ const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
843
+ for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
844
+ if (s[i] !== undefined) {
845
+ ifaceSanitized = ifaceSanitized + s[i];
846
+ }
847
+ }
848
+ const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${ifaceSanitized}/addr_assign_type 2>/dev/null; echo;
849
+ echo -n "address: "; cat /sys/class/net/${ifaceSanitized}/address 2>/dev/null; echo;
850
+ echo -n "addr_len: "; cat /sys/class/net/${ifaceSanitized}/addr_len 2>/dev/null; echo;
851
+ echo -n "broadcast: "; cat /sys/class/net/${ifaceSanitized}/broadcast 2>/dev/null; echo;
852
+ echo -n "carrier: "; cat /sys/class/net/${ifaceSanitized}/carrier 2>/dev/null; echo;
853
+ echo -n "carrier_changes: "; cat /sys/class/net/${ifaceSanitized}/carrier_changes 2>/dev/null; echo;
854
+ echo -n "dev_id: "; cat /sys/class/net/${ifaceSanitized}/dev_id 2>/dev/null; echo;
855
+ echo -n "dev_port: "; cat /sys/class/net/${ifaceSanitized}/dev_port 2>/dev/null; echo;
856
+ echo -n "dormant: "; cat /sys/class/net/${ifaceSanitized}/dormant 2>/dev/null; echo;
857
+ echo -n "duplex: "; cat /sys/class/net/${ifaceSanitized}/duplex 2>/dev/null; echo;
858
+ echo -n "flags: "; cat /sys/class/net/${ifaceSanitized}/flags 2>/dev/null; echo;
859
+ echo -n "gro_flush_timeout: "; cat /sys/class/net/${ifaceSanitized}/gro_flush_timeout 2>/dev/null; echo;
860
+ echo -n "ifalias: "; cat /sys/class/net/${ifaceSanitized}/ifalias 2>/dev/null; echo;
861
+ echo -n "ifindex: "; cat /sys/class/net/${ifaceSanitized}/ifindex 2>/dev/null; echo;
862
+ echo -n "iflink: "; cat /sys/class/net/${ifaceSanitized}/iflink 2>/dev/null; echo;
863
+ echo -n "link_mode: "; cat /sys/class/net/${ifaceSanitized}/link_mode 2>/dev/null; echo;
864
+ echo -n "mtu: "; cat /sys/class/net/${ifaceSanitized}/mtu 2>/dev/null; echo;
865
+ echo -n "netdev_group: "; cat /sys/class/net/${ifaceSanitized}/netdev_group 2>/dev/null; echo;
866
+ echo -n "operstate: "; cat /sys/class/net/${ifaceSanitized}/operstate 2>/dev/null; echo;
867
+ echo -n "proto_down: "; cat /sys/class/net/${ifaceSanitized}/proto_down 2>/dev/null; echo;
868
+ echo -n "speed: "; cat /sys/class/net/${ifaceSanitized}/speed 2>/dev/null; echo;
869
+ echo -n "tx_queue_len: "; cat /sys/class/net/${ifaceSanitized}/tx_queue_len 2>/dev/null; echo;
870
+ echo -n "type: "; cat /sys/class/net/${ifaceSanitized}/type 2>/dev/null; echo;
871
+ echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null | grep ${ifaceSanitized}; echo;
872
+ echo -n "wirelessspeed: "; iw dev ${ifaceSanitized} link 2>&1 | grep bitrate; echo;`;
858
873
 
859
874
  let lines = [];
860
875
  try {
861
876
  lines = execSync(cmd).toString().split('\n');
862
- const connectionName = getLinuxIfaceConnectionName(iface);
863
- dhcp = getLinuxIfaceDHCPstatus(iface, connectionName, _dhcpNics);
877
+ const connectionName = getLinuxIfaceConnectionName(ifaceSanitized);
878
+ dhcp = getLinuxIfaceDHCPstatus(ifaceSanitized, connectionName, _dhcpNics);
864
879
  dnsSuffix = getLinuxIfaceDNSsuffix(connectionName);
865
880
  ieee8021xAuth = getLinuxIfaceIEEE8021xAuth(connectionName);
866
881
  ieee8021xState = getLinuxIfaceIEEE8021xState(ieee8021xAuth);
@@ -880,7 +895,7 @@ function networkInterfaces(callback, rescan, defaultString) {
880
895
  carrierChanges = parseInt(util.getValue(lines, 'carrier_changes'), 10);
881
896
  const operstate = util.getValue(lines, 'operstate');
882
897
  type = operstate === 'up' ? (util.getValue(lines, 'wireless').trim() ? 'wireless' : 'wired') : 'unknown';
883
- if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
898
+ if (ifaceSanitized === 'lo' || ifaceSanitized.startsWith('bond')) { type = 'virtual'; }
884
899
 
885
900
  let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
886
901
  if (dev.toLowerCase().indexOf('loopback') > -1 || ifaceName.toLowerCase().indexOf('loopback') > -1) {
@@ -888,7 +903,7 @@ function networkInterfaces(callback, rescan, defaultString) {
888
903
  }
889
904
  const virtual = internal ? false : testVirtualNic(dev, ifaceName, mac);
890
905
  result.push({
891
- iface,
906
+ iface: ifaceSanitized,
892
907
  ifaceName,
893
908
  default: iface === defaultInterface,
894
909
  ip4,
@@ -955,6 +970,15 @@ function networkInterfaces(callback, rescan, defaultString) {
955
970
  nics8021xInfo = getWindowsWiredProfilesInformation();
956
971
  dnsSuffixes = getWindowsDNSsuffixes();
957
972
  for (let dev in ifaces) {
973
+
974
+ let ifaceSanitized = '';
975
+ const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(dev);
976
+ for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
977
+ if (s[i] !== undefined) {
978
+ ifaceSanitized = ifaceSanitized + s[i];
979
+ }
980
+ }
981
+
958
982
  let iface = dev;
959
983
  let ip4 = '';
960
984
  let ip4subnet = '';
@@ -998,7 +1022,7 @@ function networkInterfaces(callback, rescan, defaultString) {
998
1022
 
999
1023
 
1000
1024
 
1001
- dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev);
1025
+ dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, ifaceSanitized);
1002
1026
  let foundFirst = false;
1003
1027
  nics.forEach(detail => {
1004
1028
  if (detail.mac === mac && !foundFirst) {
@@ -1016,7 +1040,7 @@ function networkInterfaces(callback, rescan, defaultString) {
1016
1040
  type = 'wireless';
1017
1041
  }
1018
1042
 
1019
- const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo);
1043
+ const IEEE8021x = getWindowsIEEE8021x(type, ifaceSanitized, nics8021xInfo);
1020
1044
  ieee8021xAuth = IEEE8021x.protocol;
1021
1045
  ieee8021xState = IEEE8021x.state;
1022
1046
  let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.17.3",
3
+ "version": "5.17.4",
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)",