systeminformation 5.33.11 → 5.33.12

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/filesystem.js CHANGED
@@ -294,8 +294,9 @@ function fsSize(drive, callback) {
294
294
  }
295
295
  if (_windows) {
296
296
  try {
297
- const driveSanitized = drive ? util.sanitizeString(drive, true) : '';
298
- const cmd = `Get-WmiObject Win32_logicaldisk | select Access,Caption,FileSystem,FreeSpace,Size ${driveSanitized ? '| where -property Caption -eq ' + driveSanitized : ''} | fl`;
297
+ // invalid drive input yields '' -> filter matches no drive instead of listing all
298
+ const driveSanitized = util.sanitizeDriveLetter(drive);
299
+ const cmd = `Get-WmiObject Win32_logicaldisk | select Access,Caption,FileSystem,FreeSpace,Size ${drive ? "| where -property Caption -eq '" + driveSanitized + "'" : ''} | fl`;
299
300
  util.powerShell(cmd).then((stdout, error) => {
300
301
  if (!error) {
301
302
  const devices = stdout.toString().split(/\n\s*\n/);
@@ -566,7 +567,9 @@ function raidMatchLinux(data) {
566
567
  try {
567
568
  data.forEach((element) => {
568
569
  if (element.type.startsWith('raid')) {
569
- const lines = execSync(`mdadm --export --detail /dev/${util.sanitizeString(element.name, true)}`, util.execOptsLinux).toString().split('\n');
570
+ const lines = execSync(`mdadm --export --detail /dev/${util.sanitizeString(element.name, true)}`, util.execOptsLinux)
571
+ .toString()
572
+ .split('\n');
570
573
  const mdData = decodeMdabmData(lines);
571
574
 
572
575
  element.label = mdData.label; // <- assign label info
@@ -1574,7 +1577,10 @@ function diskLayout(callback) {
1574
1577
  }
1575
1578
  // USB Drives (SPUSBDataType up to macOS 26, SPUSBHostDataType from macOS 27 on)
1576
1579
  try {
1577
- const devices = linesUSB.join('\n').replace(/Media:\n /g, 'Model:').split('\n\n Product ID:');
1580
+ const devices = linesUSB
1581
+ .join('\n')
1582
+ .replace(/Media:\n /g, 'Model:')
1583
+ .split('\n\n Product ID:');
1578
1584
  devices.shift();
1579
1585
  devices.forEach((device) => {
1580
1586
  const lines = device.split('\n');
@@ -1825,8 +1831,8 @@ function diskLayout(callback) {
1825
1831
  // in first case it will be "<serial number>&0"
1826
1832
  // in second case it will be opaque generated value that looks like this: "5&<8-symbol hex code>&0&000000"
1827
1833
  // https://learn.microsoft.com/en-us/windows-hardware/drivers/install/instance-ids
1828
- if (parts.length == 2 && parts[1] === '0') {
1829
- serialNum = parts[0]
1834
+ if (parts.length === 2 && parts[1] === '0') {
1835
+ serialNum = parts[0];
1830
1836
  }
1831
1837
  }
1832
1838
  }
package/lib/util.js CHANGED
@@ -772,6 +772,12 @@ function sanitizeContainerID(str) {
772
772
  return s.indexOf('..') === -1 ? s : '';
773
773
  }
774
774
 
775
+ // windows drive letter whitelist: only "<letter>:" survives, everything else is dropped
776
+ function sanitizeDriveLetter(str) {
777
+ const match = /^\s*([a-zA-Z]):?[\\/]?\s*$/.exec(String(str || ''));
778
+ return match ? match[1] + ':' : '';
779
+ }
780
+
775
781
  function sanitizeImageID(str) {
776
782
  const s = String(str || '')
777
783
  .substring(0, 2000)
@@ -2805,6 +2811,7 @@ exports.sanitizeContainerID = sanitizeContainerID;
2805
2811
  exports.sanitizeImageID = sanitizeImageID;
2806
2812
  exports.isPrototypePolluted = isPrototypePolluted;
2807
2813
  exports.sanitizeString = sanitizeString;
2814
+ exports.sanitizeDriveLetter = sanitizeDriveLetter;
2808
2815
  exports.decodePiCpuinfo = decodePiCpuinfo;
2809
2816
  exports.getRpiGpu = getRpiGpu;
2810
2817
  exports.promiseAll = promiseAll;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.33.11",
3
+ "version": "5.33.12",
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)",