systeminformation 6.0.0-beta.1 → 6.0.0-beta.10
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 +37 -7
- package/dist/bsd/network-stats.js +2 -2
- package/dist/common/defaults.d.ts +2 -1
- package/dist/common/defaults.js +17 -5
- package/dist/common/exec.js +1 -1
- package/dist/common/files.d.ts +9 -0
- package/dist/common/files.js +67 -3
- package/dist/common/filesys.d.ts +10 -0
- package/dist/common/filesys.js +41 -10
- package/dist/common/network.js +4 -4
- package/dist/common/nvidia.d.ts +1 -1
- package/dist/common/nvidia.js +4 -5
- package/dist/common/parse.d.ts +4 -6
- package/dist/common/parse.js +24 -69
- package/dist/common/security.d.ts +1 -0
- package/dist/common/security.js +3 -1
- package/dist/common/types.d.ts +29 -5
- package/dist/cpu-current-load.js +28 -6
- package/dist/cpu-current-speed.js +5 -3
- package/dist/darwin/disk-layout.js +10 -6
- package/dist/darwin/disks-io.js +3 -3
- package/dist/darwin/displays.js +3 -1
- package/dist/darwin/fans.d.ts +2 -0
- package/dist/darwin/fans.js +28 -0
- package/dist/darwin/index.d.ts +2 -0
- package/dist/darwin/index.js +6 -2
- package/dist/darwin/network-interfaces.js +5 -10
- package/dist/darwin/network-stats.js +5 -5
- package/dist/darwin/serial-ports.d.ts +2 -0
- package/dist/darwin/serial-ports.js +94 -0
- package/dist/fans.d.ts +1 -0
- package/dist/fans.js +17 -0
- package/dist/get-data.d.ts +4 -0
- package/dist/get-data.js +6 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -2
- package/dist/linux/audio.js +59 -0
- package/dist/linux/baseboard.js +9 -20
- package/dist/linux/bios.js +6 -15
- package/dist/linux/camera.js +2 -1
- package/dist/linux/chassis.js +4 -10
- package/dist/linux/cpu-temperature.js +34 -19
- package/dist/linux/cpu.js +3 -1
- package/dist/linux/disk-layout.js +7 -10
- package/dist/linux/disks-io.js +9 -9
- package/dist/linux/displays.js +6 -1
- package/dist/linux/fans.d.ts +2 -0
- package/dist/linux/fans.js +92 -0
- package/dist/linux/fs-size.js +160 -34
- package/dist/linux/fs-stats.js +6 -9
- package/dist/linux/gpu.js +15 -15
- package/dist/linux/index.d.ts +2 -0
- package/dist/linux/index.js +6 -2
- package/dist/linux/mem-layout.js +2 -2
- package/dist/linux/network-interfaces.js +36 -39
- package/dist/linux/network-stats.js +8 -36
- package/dist/linux/npu.js +2 -1
- package/dist/linux/os-info.js +19 -4
- package/dist/linux/printer.js +4 -4
- package/dist/linux/process-load.js +9 -12
- package/dist/linux/processes.js +89 -80
- package/dist/linux/serial-ports.d.ts +2 -0
- package/dist/linux/serial-ports.js +102 -0
- package/dist/linux/services.js +179 -47
- package/dist/linux/system.js +1 -7
- package/dist/linux/uuid.js +4 -10
- package/dist/serial-ports.d.ts +1 -0
- package/dist/serial-ports.js +17 -0
- package/dist/versions.js +32 -77
- package/dist/windows/disk-layout.js +3 -0
- package/dist/windows/disks-io.js +3 -3
- package/dist/windows/displays.js +29 -12
- package/dist/windows/fans.d.ts +2 -0
- package/dist/windows/fans.js +71 -0
- package/dist/windows/index.d.ts +2 -0
- package/dist/windows/index.js +6 -2
- package/dist/windows/network-interfaces.js +20 -29
- package/dist/windows/network-stats.js +4 -2
- package/dist/windows/process-load.js +7 -5
- package/dist/windows/processes.js +17 -11
- package/dist/windows/serial-ports.d.ts +3 -0
- package/dist/windows/serial-ports.js +73 -0
- package/dist/windows/services.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,6 +49,8 @@ in a browser.
|
|
|
49
49
|
- `npu()` - detected NPUs / AI accelerators (experimental)
|
|
50
50
|
- `software()` - installed software / applications
|
|
51
51
|
- `npm()` - globally installed npm packages
|
|
52
|
+
- `fans()` - detected fans with rpm and pwm
|
|
53
|
+
- `serialPorts()` - detected serial / COM ports
|
|
52
54
|
|
|
53
55
|
### Extended Windows support
|
|
54
56
|
|
|
@@ -163,7 +165,7 @@ implementations can be tree-shaken away.
|
|
|
163
165
|
|
|
164
166
|
- complete rewrite in TypeScript with typed declarations for every function
|
|
165
167
|
- modular imports: load the whole library, a single operating system, or a single function
|
|
166
|
-
- new functions: `camera()`, `keyboard()`, `mouse()`, `thunderbolt()`, `pci()`, `npu()`, `software()`, `npm()`
|
|
168
|
+
- new functions: `camera()`, `keyboard()`, `mouse()`, `thunderbolt()`, `pci()`, `npu()`, `software()`, `npm()`, `fans()`, `serialPorts()`
|
|
167
169
|
- extended Windows support: `disksIO()`, `fsStats()`, `fsOpenFiles()`, `thunderbolt()`
|
|
168
170
|
- `time()` and `version()` are now asynchronous - all functions are async (async/await preferred, promises as alternative)
|
|
169
171
|
- callbacks are no longer supported
|
|
@@ -289,6 +291,12 @@ Full function reference with examples can be found at [https://systeminformation
|
|
|
289
291
|
| | max | X | X | X | X | | max temperature |
|
|
290
292
|
| | socket | X | | | | | array socket temperatures |
|
|
291
293
|
| | chipset | X | | | | | chipset temperature |
|
|
294
|
+
| si.fans() | [{...}] | X | | X* | X* | | detected fans |
|
|
295
|
+
| | [0].id | X | | X* | X* | | identifier, e.g. hwmon2/fan1 |
|
|
296
|
+
| | [0].label | X | | X* | X* | | label if the driver provides one |
|
|
297
|
+
| | [0].rpm | X | | X* | X* | | speed in rpm (or null) |
|
|
298
|
+
| | [0].pwm | X | | X* | X* | | duty cycle in % (or null) |
|
|
299
|
+
| | [0].source | X | | X* | X* | | chip / provider the value came from |
|
|
292
300
|
| si.npu() | [{...}] | X | | X | X | | detected NPUs / AI accelerators |
|
|
293
301
|
| | [0].vendor | X | | X | X | | vendor (Intel, AMD, Apple, ...) |
|
|
294
302
|
| | [0].name | X | | X | X | | name |
|
|
@@ -380,6 +388,7 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
380
388
|
| | [0].serial | | | X | X | | serial number |
|
|
381
389
|
| | [0].displayId | | | X | X | | display ID |
|
|
382
390
|
| | [0].main | X | | X | X | | true if main monitor |
|
|
391
|
+
| | [0].mirror | X | | X | X | | true if mirrored / duplicated |
|
|
383
392
|
| | [0].builtin | X | | X | | | true if built-in monitor |
|
|
384
393
|
| | [0].connection | X | | X | X | | e.g. DisplayPort or HDMI |
|
|
385
394
|
| | [0].sizeX | X | | | X | | size in mm horizontal |
|
|
@@ -392,6 +401,7 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
392
401
|
| | [0].positionX | X | | X | X | | display position X |
|
|
393
402
|
| | [0].positionY | X | | X | X | | display position Y |
|
|
394
403
|
| | [0].currentRefreshRate | X | | X | X | | current screen refresh rate |
|
|
404
|
+
| | [0].scale | | | | X | | DPI scaling factor, e.g. 1.5 |
|
|
395
405
|
|
|
396
406
|
#### 7. Operating System
|
|
397
407
|
|
|
@@ -453,6 +463,7 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
453
463
|
| | currentLoadSystem | X | | X | X | X | CPU load system in % |
|
|
454
464
|
| | currentLoadNice | X | | X | X | X | CPU load nice in % |
|
|
455
465
|
| | currentLoadIdle | X | | X | X | X | CPU load idle in % |
|
|
466
|
+
| | currentLoadIowait | X | | | | | CPU load waiting for IO in % (Linux only, 0 elsewhere) |
|
|
456
467
|
| | currentLoadIrq | X | | X | X | X | CPU load system in % |
|
|
457
468
|
| | rawCurrentLoad... | X | | X | X | X | CPU load raw values (ticks) |
|
|
458
469
|
| | cpus[] | X | | X | X | X | current loads per CPU in % + raw ticks |
|
|
@@ -470,6 +481,7 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
470
481
|
| | ...[0].cpu | X | X | X | X | X | process % CPU usage |
|
|
471
482
|
| | ...[0].cpuu | X | X | | X | | process % CPU usage (user) |
|
|
472
483
|
| | ...[0].cpus | X | X | | X | | process % CPU usage (system) |
|
|
484
|
+
| | ...[0].cpuTime | X | X | X | X | X | process cpu time in seconds (own, without reaped children); null if not available |
|
|
473
485
|
| | ...[0].mem | X | X | X | X | X | process memory % |
|
|
474
486
|
| | ...[0].priority | X | X | X | X | X | process priority |
|
|
475
487
|
| | ...[0].memVsz | X | X | X | X | X | process virtual memory size |
|
|
@@ -542,12 +554,12 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
542
554
|
| | rIO | X | | X | X | | read IOs on all mounted drives |
|
|
543
555
|
| | wIO | X | | X | X | | write IOs on all mounted drives |
|
|
544
556
|
| | tIO | X | | X | X | | write IOs on all mounted drives |
|
|
545
|
-
| | rIO_sec | X | | X | X | | read IO per sec (* see notes)
|
|
546
|
-
| | wIO_sec | X | | X | X | | write IO per sec (* see notes)
|
|
547
|
-
| | tIO_sec | X | | X | X | | total IO per sec (* see notes)
|
|
548
|
-
| | rWaitTime | X | | | | | read IO request time (*
|
|
549
|
-
| | wWaitTime | X | | | | | write IO request time (*
|
|
550
|
-
| | tWaitTime | X | | | | | total IO request time (*
|
|
557
|
+
| | rIO_sec | X | | X | X | | read IO operations per sec, not bytes (* see notes) |
|
|
558
|
+
| | wIO_sec | X | | X | X | | write IO operations per sec, not bytes (* see notes) |
|
|
559
|
+
| | tIO_sec | X | | X | X | | total IO operations per sec, not bytes (* see notes) |
|
|
560
|
+
| | rWaitTime | X | | | | | read IO request time in ms during interval, null on 1st call (* notes) |
|
|
561
|
+
| | wWaitTime | X | | | | | write IO request time in ms during interval, null on 1st call (* notes) |
|
|
562
|
+
| | tWaitTime | X | | | | | total IO request time in ms during interval, null on 1st call (* notes) |
|
|
551
563
|
| | rWaitPercent | X | | | | | read IO request time percent (* see notes) |
|
|
552
564
|
| | wWaitPercent | X | | | | | write IO request time percent (* see notes) |
|
|
553
565
|
| | tWaitPercent | X | | | | | total IO request time percent (* see notes) |
|
|
@@ -608,6 +620,15 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
|
|
|
608
620
|
| | [0].maxPower | X | | | | | max power |
|
|
609
621
|
| | [0].default | X | | X | X | | is default printer |
|
|
610
622
|
| | [0].serialNumber | | | X | | | serial number |
|
|
623
|
+
| si.serialPorts() | [{...}] | X | | X | X | | detected serial / COM ports |
|
|
624
|
+
| | [0].device | X | | X | X | | device path (COMx on Windows) |
|
|
625
|
+
| | [0].name | X | | X | X | | product / friendly name |
|
|
626
|
+
| | [0].manufacturer | X | | X | X | | manufacturer |
|
|
627
|
+
| | [0].serialNumber | X | | X | X | | serial number (USB only) |
|
|
628
|
+
| | [0].vendorId | X | | X | X | | vendor id (hex) |
|
|
629
|
+
| | [0].productId | X | | X | X | | product id (hex) |
|
|
630
|
+
| | [0].pnpId | X | | | X | | stable id (by-id / DeviceID) |
|
|
631
|
+
| | [0].type | X | | X | X | | usb, onboard, pci, bluetooth |
|
|
611
632
|
|
|
612
633
|
#### 11. Devices
|
|
613
634
|
|
|
@@ -1003,6 +1024,15 @@ $ npm install macos-temperature-sensor --save
|
|
|
1003
1024
|
|
|
1004
1025
|
`systeminformation` will then detect this additional library and return the temperature when calling systeminformations standard function `cpuTemperature()`.
|
|
1005
1026
|
On Apple Silicon machines `macos-temperature-sensor` also enables the GPU temperature (`temperatureGpu`) in `gpu()`
|
|
1027
|
+
and - as soon as the package exposes them - the fan speeds in `fans()`.
|
|
1028
|
+
|
|
1029
|
+
#### Windows - Fan Speed
|
|
1030
|
+
|
|
1031
|
+
Windows itself does not expose actual fan speeds: `Win32_Fan` only reports that a fan exists, its `DesiredSpeed` is the *requested* speed and is left empty by virtually every mainboard. Real values are read from a running [LibreHardwareMonitor](https://github.com/LibreHardwareMonitor/LibreHardwareMonitor) or OpenHardwareMonitor, which publish their sensors in an own WMI namespace. Without one of these tools running, `fans()` returns an empty array or entries without `rpm`.
|
|
1032
|
+
|
|
1033
|
+
#### Serial Ports
|
|
1034
|
+
|
|
1035
|
+
`serialPorts()` only *enumerates* ports - opening one (baud rate, termios, RTS toggling) needs a native binding and is out of scope for this zero-dependency library. Two things worth knowing: on Linux a port shows up in the list even when your user is not in the `dialout` / `uucp` group, so listing can succeed while opening fails; on Windows the `COMx` number is reassigned per USB port, so `pnpId` is the only stable key. RS-232 and RS-485 cannot be told apart by enumeration - an RS-485 transceiver looks like an ordinary UART to the operating system - so no such information is reported.
|
|
1006
1036
|
|
|
1007
1037
|
#### Windows Temperature, Battery, ...
|
|
1008
1038
|
|
|
@@ -9,7 +9,7 @@ const darwin_1 = require("../darwin");
|
|
|
9
9
|
const network_1 = require("../common/network");
|
|
10
10
|
const _network = {};
|
|
11
11
|
const networkStatsSingle = async (iface) => {
|
|
12
|
-
const defaults = defaults_1.initNetworkSpeed;
|
|
12
|
+
const defaults = { ...defaults_1.initNetworkSpeed, iface };
|
|
13
13
|
if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
|
|
14
14
|
let operstate = 'unknown';
|
|
15
15
|
let rx_bytes = 0;
|
|
@@ -18,7 +18,7 @@ const networkStatsSingle = async (iface) => {
|
|
|
18
18
|
let rx_errors = 0;
|
|
19
19
|
let tx_dropped = 0;
|
|
20
20
|
let tx_errors = 0;
|
|
21
|
-
const
|
|
21
|
+
const stdout = await (0, exec_1.execSecure)('netstat', ['-ibndI', iface]);
|
|
22
22
|
if (stdout) {
|
|
23
23
|
const lines = stdout.split('\n');
|
|
24
24
|
for (let i = 1; i < lines.length; i++) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { AudioData, BaseboardData, BatteryObject, BiosData, ChassisData, CpuCacheData, CpuObject, CpuTemperatureObject, DisksIoData, DisplayData, FsBlockDevicesData, FsOpenFilesData, FsStatsData, InetChecksiteData, MemData, NetworkInterfacesData, NetworkStatsData, NpuData, OsData, PciData, ProcessesData, SystemData, UsbData, UuidData } from './types';
|
|
1
|
+
import type { AudioData, BaseboardData, BatteryObject, BiosData, ChassisData, CpuCacheData, CpuObject, CpuTemperatureObject, DisksIoData, DisplayData, FsBlockDevicesData, FsOpenFilesData, FsStatsData, InetChecksiteData, MemData, NetworkInterfacesData, NetworkStatsData, NpuData, OsData, PciData, ProcessesData, SerialPortData, SystemData, UsbData, UuidData } from './types';
|
|
2
2
|
export declare const initBatteryResult: BatteryObject;
|
|
3
3
|
export declare const initAudioResult: AudioData;
|
|
4
|
+
export declare const initSerialPortResult: SerialPortData;
|
|
4
5
|
export declare const initUsbResult: UsbData;
|
|
5
6
|
export declare const initCpuResult: CpuObject;
|
|
6
7
|
export declare const initCpuCacheResult: CpuCacheData;
|
package/dist/common/defaults.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initNetworkSpeed = exports.initPciData = exports.initNpuData = exports.initNetworkInterface = exports.initProcesses = exports.initDisplay = exports.initDiskIo = exports.initFsStats = exports.initFsBlockDevice = exports.initFsOpenFiles = exports.initSystem = exports.initBios = exports.initBaseboard = exports.initChassis = exports.initUUID = exports.initOsInfo = exports.initMemData = exports.initCheckSite = exports.initCpuTemperature = exports.initCpuCacheResult = exports.initCpuResult = exports.initUsbResult = exports.initAudioResult = exports.initBatteryResult = void 0;
|
|
3
|
+
exports.initNetworkSpeed = exports.initPciData = exports.initNpuData = exports.initNetworkInterface = exports.initProcesses = exports.initDisplay = exports.initDiskIo = exports.initFsStats = exports.initFsBlockDevice = exports.initFsOpenFiles = exports.initSystem = exports.initBios = exports.initBaseboard = exports.initChassis = exports.initUUID = exports.initOsInfo = exports.initMemData = exports.initCheckSite = exports.initCpuTemperature = exports.initCpuCacheResult = exports.initCpuResult = exports.initUsbResult = exports.initSerialPortResult = exports.initAudioResult = exports.initBatteryResult = void 0;
|
|
4
4
|
const node_os_1 = require("node:os");
|
|
5
5
|
const acceleration_1 = require("./acceleration");
|
|
6
6
|
const const_1 = require("./const");
|
|
@@ -34,6 +34,16 @@ exports.initAudioResult = {
|
|
|
34
34
|
out: null,
|
|
35
35
|
status: ''
|
|
36
36
|
};
|
|
37
|
+
exports.initSerialPortResult = {
|
|
38
|
+
device: '',
|
|
39
|
+
name: null,
|
|
40
|
+
manufacturer: null,
|
|
41
|
+
serialNumber: null,
|
|
42
|
+
vendorId: null,
|
|
43
|
+
productId: null,
|
|
44
|
+
pnpId: null,
|
|
45
|
+
type: 'unknown'
|
|
46
|
+
};
|
|
37
47
|
exports.initUsbResult = {
|
|
38
48
|
id: null,
|
|
39
49
|
bus: null,
|
|
@@ -207,9 +217,9 @@ exports.initDiskIo = {
|
|
|
207
217
|
rIO_sec: null,
|
|
208
218
|
wIO_sec: null,
|
|
209
219
|
tIO_sec: null,
|
|
210
|
-
rWaitTime:
|
|
211
|
-
wWaitTime:
|
|
212
|
-
tWaitTime:
|
|
220
|
+
rWaitTime: null,
|
|
221
|
+
wWaitTime: null,
|
|
222
|
+
tWaitTime: null,
|
|
213
223
|
rWaitPercent: null,
|
|
214
224
|
wWaitPercent: null,
|
|
215
225
|
tWaitPercent: null,
|
|
@@ -224,6 +234,7 @@ exports.initDisplay = {
|
|
|
224
234
|
deviceName: '',
|
|
225
235
|
displayId: null,
|
|
226
236
|
main: false,
|
|
237
|
+
mirror: false,
|
|
227
238
|
builtin: false,
|
|
228
239
|
connection: '',
|
|
229
240
|
sizeX: null,
|
|
@@ -235,7 +246,8 @@ exports.initDisplay = {
|
|
|
235
246
|
currentResY: null,
|
|
236
247
|
positionX: 0,
|
|
237
248
|
positionY: 0,
|
|
238
|
-
currentRefreshRate: null
|
|
249
|
+
currentRefreshRate: null,
|
|
250
|
+
scale: null
|
|
239
251
|
};
|
|
240
252
|
exports.initProcesses = {
|
|
241
253
|
all: 0,
|
package/dist/common/exec.js
CHANGED
|
@@ -63,7 +63,7 @@ const execSave = async (cmd, options = {}) => {
|
|
|
63
63
|
return { stdout: stdout.toString(), stderr: stderr.toString() };
|
|
64
64
|
}
|
|
65
65
|
catch (e) {
|
|
66
|
-
return { stdout: e.stdout, stderr: e.stderr };
|
|
66
|
+
return { stdout: String(e.stdout ?? ''), stderr: String(e.stderr ?? '') };
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
exports.execSave = execSave;
|
package/dist/common/files.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
export declare const getFilesInPath: (source: string) => Promise<string[]>;
|
|
2
2
|
export declare const fileExists: (file: string) => Promise<boolean>;
|
|
3
|
+
export declare const readSysfs: (file: string) => Promise<string>;
|
|
4
|
+
export declare const readFileLines: (file: string) => Promise<string[]>;
|
|
5
|
+
export declare const readSysfsMany: (dir: string, names: string[]) => Promise<string[]>;
|
|
6
|
+
export declare const readProcStats: (pids: any[]) => Promise<{
|
|
7
|
+
all: string;
|
|
8
|
+
procs: string[];
|
|
9
|
+
}>;
|
|
10
|
+
export declare const readFileMax: (file: string, maxBytes?: number) => Promise<string>;
|
|
11
|
+
export declare const DMI_PATH = "/sys/devices/virtual/dmi/id";
|
package/dist/common/files.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fileExists = exports.getFilesInPath = void 0;
|
|
3
|
+
exports.DMI_PATH = exports.readFileMax = exports.readProcStats = exports.readSysfsMany = exports.readFileLines = exports.readSysfs = exports.fileExists = exports.getFilesInPath = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const promises_1 = require("fs/promises");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
+
const security_1 = require("./security");
|
|
7
8
|
const getFilesInPath = async (source) => {
|
|
8
9
|
const fetchedFiles = [];
|
|
9
10
|
try {
|
|
10
|
-
const files = await (0, promises_1.readdir)(source);
|
|
11
|
+
const files = (await (0, promises_1.readdir)(source)).filter(security_1.isSafePathSegment);
|
|
11
12
|
for (const file of files) {
|
|
12
13
|
try {
|
|
13
14
|
const filepath = (0, path_1.join)(source, file);
|
|
@@ -17,7 +18,7 @@ const getFilesInPath = async (source) => {
|
|
|
17
18
|
}
|
|
18
19
|
if (stats.isDirectory()) {
|
|
19
20
|
const childFiles = await (0, promises_1.readdir)(filepath);
|
|
20
|
-
files.push(...childFiles.map((f) => (0, path_1.join)(file, f)));
|
|
21
|
+
files.push(...childFiles.filter(security_1.isSafePathSegment).map((f) => (0, path_1.join)(file, f)));
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
catch { }
|
|
@@ -37,3 +38,66 @@ const fileExists = async (file) => {
|
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
40
|
exports.fileExists = fileExists;
|
|
41
|
+
const readSysfs = async (file) => {
|
|
42
|
+
try {
|
|
43
|
+
return (await (0, promises_1.readFile)(file, 'utf8')).trim();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.readSysfs = readSysfs;
|
|
50
|
+
const readFileLines = async (file) => {
|
|
51
|
+
try {
|
|
52
|
+
return (await (0, promises_1.readFile)(file, 'utf8')).split('\n');
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.readFileLines = readFileLines;
|
|
59
|
+
const readSysfsMany = async (dir, names) => {
|
|
60
|
+
return Promise.all(names.map(async (name) => `${name}: ${await (0, exports.readSysfs)((0, path_1.join)(dir, name))}`));
|
|
61
|
+
};
|
|
62
|
+
exports.readSysfsMany = readSysfsMany;
|
|
63
|
+
const PROC_READ_BATCH = 64;
|
|
64
|
+
const readProcStats = async (pids) => {
|
|
65
|
+
const paths = [];
|
|
66
|
+
for (const pid of pids) {
|
|
67
|
+
const id = String(pid);
|
|
68
|
+
if (/^\d+$/.test(id)) {
|
|
69
|
+
paths.push(`/proc/${id}/stat`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const statLines = await (0, exports.readFileLines)('/proc/stat');
|
|
73
|
+
const procs = [];
|
|
74
|
+
for (let i = 0; i < paths.length; i += PROC_READ_BATCH) {
|
|
75
|
+
procs.push(...(await Promise.all(paths.slice(i, i + PROC_READ_BATCH).map((path) => (0, exports.readSysfs)(path)))));
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
all: statLines.find((line) => line.startsWith('cpu ')) || '',
|
|
79
|
+
procs: procs.filter((line) => line)
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
exports.readProcStats = readProcStats;
|
|
83
|
+
const readFileMax = async (file, maxBytes = 1024 * 1024) => {
|
|
84
|
+
let handle;
|
|
85
|
+
try {
|
|
86
|
+
handle = await (0, promises_1.open)(file, 'r');
|
|
87
|
+
const { size } = await handle.stat();
|
|
88
|
+
const buffer = Buffer.alloc(Math.min(size || maxBytes, maxBytes));
|
|
89
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
90
|
+
return buffer.toString('utf8', 0, bytesRead).trim();
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return '';
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
try {
|
|
97
|
+
await handle?.close();
|
|
98
|
+
}
|
|
99
|
+
catch { }
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.readFileMax = readFileMax;
|
|
103
|
+
exports.DMI_PATH = '/sys/devices/virtual/dmi/id';
|
package/dist/common/filesys.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type { FsBlockDevicesData } from './types';
|
|
2
|
+
export declare const zfsDatasets: () => Promise<{
|
|
3
|
+
byMount: Map<string, {
|
|
4
|
+
used: number;
|
|
5
|
+
available: number;
|
|
6
|
+
}>;
|
|
7
|
+
byName: Map<string, {
|
|
8
|
+
used: number;
|
|
9
|
+
available: number;
|
|
10
|
+
}>;
|
|
11
|
+
}>;
|
|
2
12
|
export declare const smartMonToolsInstalled: () => Promise<boolean>;
|
|
3
13
|
export declare const _fs_speed: any;
|
|
4
14
|
export declare const calcFsSpeed: (rx: number, wx: number) => any;
|
package/dist/common/filesys.js
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matchDevicesWin = exports.matchDevicesLinux = exports.raidMatchLinux = exports.parseLinuxBlk = exports.blkStdoutToObject = exports.calcDiskIO = exports._disk_io = exports.calcFsSpeed = exports._fs_speed = exports.smartMonToolsInstalled = void 0;
|
|
3
|
+
exports.matchDevicesWin = exports.matchDevicesLinux = exports.raidMatchLinux = exports.parseLinuxBlk = exports.blkStdoutToObject = exports.calcDiskIO = exports._disk_io = exports.calcFsSpeed = exports._fs_speed = exports.smartMonToolsInstalled = exports.zfsDatasets = void 0;
|
|
4
4
|
const index_1 = require("./index");
|
|
5
5
|
const const_1 = require("./const");
|
|
6
6
|
const defaults_1 = require("./defaults");
|
|
7
7
|
const exec_1 = require("./exec");
|
|
8
8
|
let _smartMonToolsInstalled = null;
|
|
9
|
+
const zfsDatasets = async () => {
|
|
10
|
+
const byMount = new Map();
|
|
11
|
+
const byName = new Map();
|
|
12
|
+
let stdout = '';
|
|
13
|
+
try {
|
|
14
|
+
({ stdout } = await (0, exec_1.exec)('zfs list -H -p -o name,used,avail,mountpoint', { ...const_1.execOptsLinux, timeout: 5000 }));
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return { byMount, byName };
|
|
18
|
+
}
|
|
19
|
+
for (const line of stdout.toString().split('\n')) {
|
|
20
|
+
const parts = line.split('\t');
|
|
21
|
+
if (parts.length < 4) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const entry = { used: (0, index_1.toInt)(parts[1]), available: (0, index_1.toInt)(parts[2]) };
|
|
25
|
+
const mount = parts[3].trim();
|
|
26
|
+
byName.set(parts[0], entry);
|
|
27
|
+
if (mount.startsWith('/') && !byMount.has(mount)) {
|
|
28
|
+
byMount.set(mount, entry);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return { byMount, byName };
|
|
32
|
+
};
|
|
33
|
+
exports.zfsDatasets = zfsDatasets;
|
|
9
34
|
const smartMonToolsInstalled = async () => {
|
|
10
35
|
if (_smartMonToolsInstalled !== null) {
|
|
11
36
|
return _smartMonToolsInstalled;
|
|
@@ -84,12 +109,12 @@ const calcDiskIO = (rIO, wIO, rWaitTime, wWaitTime, tWaitTime) => {
|
|
|
84
109
|
result.rIO_sec = (result.rIO - exports._disk_io.rIO) / (result.ms / 1000);
|
|
85
110
|
result.wIO_sec = (result.wIO - exports._disk_io.wIO) / (result.ms / 1000);
|
|
86
111
|
result.tIO_sec = result.rIO_sec + result.wIO_sec;
|
|
87
|
-
result.rWaitTime = rWaitTime;
|
|
88
|
-
result.wWaitTime = wWaitTime;
|
|
89
|
-
result.tWaitTime = tWaitTime;
|
|
90
|
-
result.rWaitPercent = (
|
|
91
|
-
result.wWaitPercent = (
|
|
92
|
-
result.tWaitPercent = (
|
|
112
|
+
result.rWaitTime = rWaitTime - exports._disk_io.rWaitTime;
|
|
113
|
+
result.wWaitTime = wWaitTime - exports._disk_io.wWaitTime;
|
|
114
|
+
result.tWaitTime = tWaitTime - exports._disk_io.tWaitTime;
|
|
115
|
+
result.rWaitPercent = (result.rWaitTime * 100) / result.ms;
|
|
116
|
+
result.wWaitPercent = (result.wWaitTime * 100) / result.ms;
|
|
117
|
+
result.tWaitPercent = (result.tWaitTime * 100) / result.ms;
|
|
93
118
|
exports._disk_io.rIO = rIO;
|
|
94
119
|
exports._disk_io.wIO = wIO;
|
|
95
120
|
exports._disk_io.rIO_sec = result.rIO_sec;
|
|
@@ -98,6 +123,9 @@ const calcDiskIO = (rIO, wIO, rWaitTime, wWaitTime, tWaitTime) => {
|
|
|
98
123
|
exports._disk_io.rWaitTime = rWaitTime;
|
|
99
124
|
exports._disk_io.wWaitTime = wWaitTime;
|
|
100
125
|
exports._disk_io.tWaitTime = tWaitTime;
|
|
126
|
+
exports._disk_io.rWaitTimeDelta = result.rWaitTime;
|
|
127
|
+
exports._disk_io.wWaitTimeDelta = result.wWaitTime;
|
|
128
|
+
exports._disk_io.tWaitTimeDelta = result.tWaitTime;
|
|
101
129
|
exports._disk_io.rWaitPercent = result.rWaitPercent;
|
|
102
130
|
exports._disk_io.wWaitPercent = result.wWaitPercent;
|
|
103
131
|
exports._disk_io.tWaitPercent = result.tWaitPercent;
|
|
@@ -108,9 +136,9 @@ const calcDiskIO = (rIO, wIO, rWaitTime, wWaitTime, tWaitTime) => {
|
|
|
108
136
|
result.rIO = rIO;
|
|
109
137
|
result.wIO = wIO;
|
|
110
138
|
result.tIO = rIO + wIO;
|
|
111
|
-
result.rWaitTime =
|
|
112
|
-
result.wWaitTime =
|
|
113
|
-
result.tWaitTime =
|
|
139
|
+
result.rWaitTime = null;
|
|
140
|
+
result.wWaitTime = null;
|
|
141
|
+
result.tWaitTime = null;
|
|
114
142
|
exports._disk_io.rIO = rIO;
|
|
115
143
|
exports._disk_io.wIO = wIO;
|
|
116
144
|
exports._disk_io.rIO_sec = null;
|
|
@@ -119,6 +147,9 @@ const calcDiskIO = (rIO, wIO, rWaitTime, wWaitTime, tWaitTime) => {
|
|
|
119
147
|
exports._disk_io.rWaitTime = rWaitTime;
|
|
120
148
|
exports._disk_io.wWaitTime = wWaitTime;
|
|
121
149
|
exports._disk_io.tWaitTime = tWaitTime;
|
|
150
|
+
exports._disk_io.rWaitTimeDelta = null;
|
|
151
|
+
exports._disk_io.wWaitTimeDelta = null;
|
|
152
|
+
exports._disk_io.tWaitTimeDelta = null;
|
|
122
153
|
exports._disk_io.rWaitPercent = null;
|
|
123
154
|
exports._disk_io.wWaitPercent = null;
|
|
124
155
|
exports._disk_io.tWaitPercent = null;
|
package/dist/common/network.js
CHANGED
|
@@ -137,10 +137,10 @@ const calcNetworkSpeed = (iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_d
|
|
|
137
137
|
_network[iface].tx_bytes = tx_bytes;
|
|
138
138
|
_network[iface].rx_sec = null;
|
|
139
139
|
_network[iface].tx_sec = null;
|
|
140
|
-
_network[iface].rx_dropped =
|
|
141
|
-
_network[iface].rx_errors =
|
|
142
|
-
_network[iface].tx_dropped =
|
|
143
|
-
_network[iface].tx_errors =
|
|
140
|
+
_network[iface].rx_dropped = rx_dropped;
|
|
141
|
+
_network[iface].rx_errors = rx_errors;
|
|
142
|
+
_network[iface].tx_dropped = tx_dropped;
|
|
143
|
+
_network[iface].tx_errors = tx_errors;
|
|
144
144
|
_network[iface].ms = Date.now();
|
|
145
145
|
_network[iface].last_ms = 0;
|
|
146
146
|
_network[iface].operstate = operstate;
|
package/dist/common/nvidia.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GpuData, GpuNvidiaData } from './types';
|
|
2
|
-
export declare const getNvidiaSmi: () => Promise<string
|
|
2
|
+
export declare const getNvidiaSmi: () => Promise<string>;
|
|
3
3
|
export declare const nvidiaSmi: () => Promise<string>;
|
|
4
4
|
export declare const nvidiaDevices: () => Promise<({
|
|
5
5
|
driverVersion: string | undefined;
|
package/dist/common/nvidia.js
CHANGED
|
@@ -22,7 +22,7 @@ const getNvidiaSmi = async () => {
|
|
|
22
22
|
const basePath = String.raw `${const_1.WINDIR}\System32\DriverStore\FileRepository`;
|
|
23
23
|
let lastMod = 0;
|
|
24
24
|
for (const dir of await (0, promises_1.readdir)(basePath)) {
|
|
25
|
-
if (!dir.toLowerCase().startsWith('nv')) {
|
|
25
|
+
if (!dir.toLowerCase().startsWith('nv') || !(0, security_1.isSafePathSegment)(dir)) {
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
28
|
const smiPath = [basePath, dir, 'nvidia-smi.exe'].join('\\');
|
|
@@ -41,6 +41,7 @@ const getNvidiaSmi = async () => {
|
|
|
41
41
|
else if (const_1.LINUX) {
|
|
42
42
|
_nvidiaSmiPath = 'nvidia-smi';
|
|
43
43
|
}
|
|
44
|
+
_nvidiaSmiPath = _nvidiaSmiPath || '';
|
|
44
45
|
return _nvidiaSmiPath;
|
|
45
46
|
};
|
|
46
47
|
exports.getNvidiaSmi = getNvidiaSmi;
|
|
@@ -48,11 +49,9 @@ const nvidiaSmi = async () => {
|
|
|
48
49
|
const nvidiaSmiExe = await (0, exports.getNvidiaSmi)();
|
|
49
50
|
if (nvidiaSmiExe) {
|
|
50
51
|
const nvidiaSmiOpts = '--query-gpu=driver_version,pci.sub_device_id,name,pci.bus_id,fan.speed,memory.total,memory.used,memory.free,utilization.gpu,utilization.memory,temperature.gpu,temperature.memory,power.draw,power.limit,clocks.gr,clocks.mem --format=csv,noheader,nounits';
|
|
51
|
-
const cmd = `${nvidiaSmiExe} ${nvidiaSmiOpts}`;
|
|
52
52
|
try {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
return stdout;
|
|
53
|
+
const { stdout } = await (0, exec_1.execFile)(nvidiaSmiExe, nvidiaSmiOpts.split(' '), const_1.execOptsWin);
|
|
54
|
+
return String(stdout);
|
|
56
55
|
}
|
|
57
56
|
catch { }
|
|
58
57
|
}
|
package/dist/common/parse.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { CpuData, ProcStatData } from './types';
|
|
2
|
-
export type headerType = {
|
|
3
|
-
from: number;
|
|
4
|
-
to: number;
|
|
5
|
-
cap: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const parseHead: (head: string, rights: number) => headerType[];
|
|
8
2
|
export declare const parseProcStat: (line: string) => number;
|
|
3
|
+
export declare const clampCpuPair: (cpuu: number, cpus: number) => {
|
|
4
|
+
cpuu: number;
|
|
5
|
+
cpus: number;
|
|
6
|
+
};
|
|
9
7
|
export declare const calcProcStatLinux: (line: string, all: number, _cpu_old: CpuData) => ProcStatData;
|
|
10
8
|
export declare const parseJsonArray: (data: string) => any[];
|
|
11
9
|
export declare const cleanDefaults: (str: string) => string;
|
package/dist/common/parse.js
CHANGED
|
@@ -1,63 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.splitByNumber = exports.kFactor = exports.cleanDefaults = exports.parseJsonArray = exports.calcProcStatLinux = exports.
|
|
3
|
+
exports.splitByNumber = exports.kFactor = exports.cleanDefaults = exports.parseJsonArray = exports.calcProcStatLinux = exports.clampCpuPair = exports.parseProcStat = void 0;
|
|
4
4
|
const index_1 = require("./index");
|
|
5
|
-
const parseHead = (head, rights) => {
|
|
6
|
-
let space = rights > 0;
|
|
7
|
-
let count = 1;
|
|
8
|
-
let from = 0;
|
|
9
|
-
let to = 0;
|
|
10
|
-
const result = [];
|
|
11
|
-
for (let i = 0; i < head.length; i++) {
|
|
12
|
-
if (count <= rights) {
|
|
13
|
-
if (/\s/.test(head[i]) && !space) {
|
|
14
|
-
to = i - 1;
|
|
15
|
-
result.push({
|
|
16
|
-
from: from,
|
|
17
|
-
to: to + 1,
|
|
18
|
-
cap: head.substring(from, to + 1)
|
|
19
|
-
});
|
|
20
|
-
from = to + 2;
|
|
21
|
-
count++;
|
|
22
|
-
}
|
|
23
|
-
space = head[i] === ' ';
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
if (!/\s/.test(head[i]) && space) {
|
|
27
|
-
to = i - 1;
|
|
28
|
-
if (from < to) {
|
|
29
|
-
result.push({
|
|
30
|
-
from: from,
|
|
31
|
-
to: to,
|
|
32
|
-
cap: head.substring(from, to)
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
from = to + 1;
|
|
36
|
-
count++;
|
|
37
|
-
}
|
|
38
|
-
space = head[i] === ' ';
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
to = 5000;
|
|
42
|
-
result.push({
|
|
43
|
-
from: from,
|
|
44
|
-
to: to,
|
|
45
|
-
cap: head.substring(from, to)
|
|
46
|
-
});
|
|
47
|
-
let len = result.length;
|
|
48
|
-
for (let i = 0; i < len; i++) {
|
|
49
|
-
if (result[i].cap.replace(/\s/g, '').length === 0) {
|
|
50
|
-
if (i + 1 < len) {
|
|
51
|
-
result[i].to = result[i + 1].to;
|
|
52
|
-
result[i].cap = result[i].cap + result[i + 1].cap;
|
|
53
|
-
result.splice(i + 1, 1);
|
|
54
|
-
len = len - 1;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
};
|
|
60
|
-
exports.parseHead = parseHead;
|
|
61
5
|
const parseProcStat = (line) => {
|
|
62
6
|
const parts = line.replace(/ +/g, ' ').split(' ');
|
|
63
7
|
const user = parts.length >= 2 ? (0, index_1.toInt)(parts[1]) : 0;
|
|
@@ -73,6 +17,21 @@ const parseProcStat = (line) => {
|
|
|
73
17
|
return user + nice + system + idle + iowait + irq + softirq + steal + guest + guest_nice;
|
|
74
18
|
};
|
|
75
19
|
exports.parseProcStat = parseProcStat;
|
|
20
|
+
const clampCpuPair = (cpuu, cpus) => {
|
|
21
|
+
if (!Number.isFinite(cpuu) || cpuu < 0) {
|
|
22
|
+
cpuu = 0;
|
|
23
|
+
}
|
|
24
|
+
if (!Number.isFinite(cpus) || cpus < 0) {
|
|
25
|
+
cpus = 0;
|
|
26
|
+
}
|
|
27
|
+
const total = cpuu + cpus;
|
|
28
|
+
if (total > 100) {
|
|
29
|
+
cpuu = (cpuu / total) * 100;
|
|
30
|
+
cpus = (cpus / total) * 100;
|
|
31
|
+
}
|
|
32
|
+
return { cpuu, cpus };
|
|
33
|
+
};
|
|
34
|
+
exports.clampCpuPair = clampCpuPair;
|
|
76
35
|
const calcProcStatLinux = (line, all, _cpu_old) => {
|
|
77
36
|
const statparts = line.replace(/ +/g, ' ').split(')');
|
|
78
37
|
if (statparts.length >= 2) {
|
|
@@ -81,27 +40,25 @@ const calcProcStatLinux = (line, all, _cpu_old) => {
|
|
|
81
40
|
const pid = (0, index_1.toInt)(statparts[0].split(' ')[0]);
|
|
82
41
|
const utime = (0, index_1.toInt)(parts[12]);
|
|
83
42
|
const stime = (0, index_1.toInt)(parts[13]);
|
|
84
|
-
const cutime = (0, index_1.toInt)(parts[14]);
|
|
85
|
-
const cstime = (0, index_1.toInt)(parts[15]);
|
|
86
43
|
let cpuu = 0;
|
|
87
44
|
let cpus = 0;
|
|
88
45
|
if (_cpu_old.all > 0 && _cpu_old.list[pid]) {
|
|
89
|
-
|
|
90
|
-
|
|
46
|
+
const delta = all - _cpu_old.all;
|
|
47
|
+
cpuu = delta > 0 ? ((utime - _cpu_old.list[pid].utime) / delta) * 100 : 0;
|
|
48
|
+
cpus = delta > 0 ? ((stime - _cpu_old.list[pid].stime) / delta) * 100 : 0;
|
|
91
49
|
}
|
|
92
50
|
else {
|
|
93
|
-
cpuu = (
|
|
94
|
-
cpus = (
|
|
51
|
+
cpuu = all > 0 ? (utime / all) * 100 : 0;
|
|
52
|
+
cpus = all > 0 ? (stime / all) * 100 : 0;
|
|
95
53
|
}
|
|
54
|
+
const clamped = (0, exports.clampCpuPair)(cpuu, cpus);
|
|
96
55
|
return {
|
|
97
56
|
pid: pid,
|
|
98
57
|
name: '',
|
|
99
58
|
utime: utime,
|
|
100
59
|
stime: stime,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
cpuu: cpuu,
|
|
104
|
-
cpus: cpus
|
|
60
|
+
cpuu: clamped.cpuu,
|
|
61
|
+
cpus: clamped.cpus
|
|
105
62
|
};
|
|
106
63
|
}
|
|
107
64
|
}
|
|
@@ -110,8 +67,6 @@ const calcProcStatLinux = (line, all, _cpu_old) => {
|
|
|
110
67
|
name: '',
|
|
111
68
|
utime: 0,
|
|
112
69
|
stime: 0,
|
|
113
|
-
cutime: 0,
|
|
114
|
-
cstime: 0,
|
|
115
70
|
cpuu: 0,
|
|
116
71
|
cpus: 0
|
|
117
72
|
};
|
|
@@ -22,6 +22,7 @@ export declare const stringSplit: {
|
|
|
22
22
|
export declare const stringStartWith: (searchString: string, position?: number) => boolean;
|
|
23
23
|
export declare const mathMin: (...values: number[]) => number;
|
|
24
24
|
export declare const sanitizeShellString: (str: string, strict?: any) => string;
|
|
25
|
+
export declare const isSafePathSegment: (segment: string) => boolean;
|
|
25
26
|
export declare const sanitizeContainerID: (str: string) => string;
|
|
26
27
|
export declare const sanitizeImageID: (str: string) => string;
|
|
27
28
|
export declare const isPrototypePolluted: () => boolean;
|
package/dist/common/security.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sanitizeString = exports.sanitizeInterfacesString = exports.sanitizeServiceString = exports.sanitizeUrl = exports.isPrototypePolluted = exports.sanitizeImageID = exports.sanitizeContainerID = exports.sanitizeShellString = exports.mathMin = exports.stringStartWith = exports.stringSplit = exports.stringTrim = exports.stringSubstring = exports.stringSubstr = exports.stringToString = exports.stringToLower = exports.stringReplace = void 0;
|
|
3
|
+
exports.sanitizeString = exports.sanitizeInterfacesString = exports.sanitizeServiceString = exports.sanitizeUrl = exports.isPrototypePolluted = exports.sanitizeImageID = exports.sanitizeContainerID = exports.isSafePathSegment = exports.sanitizeShellString = exports.mathMin = exports.stringStartWith = exports.stringSplit = exports.stringTrim = exports.stringSubstring = exports.stringSubstr = exports.stringToString = exports.stringToLower = exports.stringReplace = void 0;
|
|
4
4
|
exports.stringReplace = new String().replace;
|
|
5
5
|
exports.stringToLower = new String().toLowerCase;
|
|
6
6
|
exports.stringToString = new String().toString;
|
|
@@ -56,6 +56,8 @@ const sanitizeShellString = (str, strict) => {
|
|
|
56
56
|
return result;
|
|
57
57
|
};
|
|
58
58
|
exports.sanitizeShellString = sanitizeShellString;
|
|
59
|
+
const isSafePathSegment = (segment) => !!segment && segment.indexOf('/') === -1 && segment.indexOf('\0') === -1 && segment !== '.' && segment !== '..';
|
|
60
|
+
exports.isSafePathSegment = isSafePathSegment;
|
|
59
61
|
const sanitizeContainerID = (str) => {
|
|
60
62
|
const s = String(str || '')
|
|
61
63
|
.substring(0, 2000)
|