systeminformation 5.33.3 → 5.33.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.
package/README.md CHANGED
@@ -92,7 +92,7 @@ npm run ci # for the whole test run
92
92
  npm run test # for testing individual functions
93
93
  ```
94
94
 
95
- Thynk you for testing and reporting! Please report any issue with the prefix "v6.beta.0: "
95
+ Thank you for testing and reporting! Please report any issue with the prefix "v6.beta.0: "
96
96
 
97
97
  ## Current Version 5.0
98
98
 
package/lib/filesystem.js CHANGED
@@ -1729,12 +1729,29 @@ function diskLayout(callback) {
1729
1729
  util.noop();
1730
1730
  }
1731
1731
  }
1732
+ function hasControlCharacters(str) {
1733
+ return /\p{Cc}/u.test(str);
1734
+ }
1732
1735
  util.promiseAll(workload).then((data) => {
1733
1736
  let devices = data.results[0].toString().split(/\n\s*\n/);
1734
1737
  devices.forEach((device) => {
1735
1738
  const lines = device.split('\r\n');
1736
1739
  const size = util.getValue(lines, 'Size', ':').trim();
1737
1740
  const status = util.getValue(lines, 'Status', ':').trim().toLowerCase();
1741
+ let serialNum = util.getValue(lines, 'SerialNumber', ':').trim();
1742
+ if (hasControlCharacters(serialNum)) {
1743
+ const instanceId = util.getValue(lines, 'PNPDeviceId', ':').trim().split('\\')[2];
1744
+ if (instanceId) {
1745
+ const parts = instanceId.split('&');
1746
+ // instanceId can contain device serial number or be generated by PnP manager
1747
+ // in first case it will be "<serial number>&0"
1748
+ // in second case it will be opaque generated value that looks like this: "5&<8-symbol hex code>&0&000000"
1749
+ // https://learn.microsoft.com/en-us/windows-hardware/drivers/install/instance-ids
1750
+ if (parts.length == 2 && parts[1] === '0') {
1751
+ serialNum = parts[0]
1752
+ }
1753
+ }
1754
+ }
1738
1755
  if (size) {
1739
1756
  result.push({
1740
1757
  device: util.getValue(lines, 'DeviceId', ':'), // changed from PNPDeviceId to DeviceID (be be able to match devices)
@@ -1750,7 +1767,7 @@ function diskLayout(callback) {
1750
1767
  tracksPerCylinder: parseInt(util.getValue(lines, 'TracksPerCylinder', ':'), 10),
1751
1768
  sectorsPerTrack: parseInt(util.getValue(lines, 'SectorsPerTrack', ':'), 10),
1752
1769
  firmwareRevision: util.getValue(lines, 'FirmwareRevision', ':').trim(),
1753
- serialNum: util.getValue(lines, 'SerialNumber', ':').trim(),
1770
+ serialNum,
1754
1771
  interfaceType: util.getValue(lines, 'InterfaceType', ':').trim(),
1755
1772
  smartStatus: status === 'ok' ? 'Ok' : status === 'degraded' ? 'Degraded' : status === 'pred fail' ? 'Predicted Failure' : 'Unknown',
1756
1773
  temperature: null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.33.3",
3
+ "version": "5.33.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)",