code cleanup

This commit is contained in:
Sebastian Hildebrandt 2023-09-25 07:31:37 +02:00
parent 1db9ee5de3
commit 196ec95d30
10 changed files with 37 additions and 15 deletions

View File

@ -83,6 +83,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| Version | Date | Comment |
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
| 5.21.9 | 2023-09-25 | `general` code cleanup |
| 5.21.8 | 2023-09-20 | `battery()` fixed parsing (linux) |
| 5.21.7 | 2023-09-19 | `wifiConnections()` `wifiNetworks()` fixed security issue (linux) |
| 5.21.6 | 2023-09-18 | `baseboard()` improved parsing (windows) |

View File

@ -57,6 +57,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.21.9</th>
<td>2023-09-25</td>
<td><span class="code">general</span> code cleanup</td>
</tr>
<tr>
<th scope="row">5.21.8</th>
<td>2023-09-20</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png" alt="logo">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.21.8</span></div>
<div class="version">New Version: <span id="version">5.21.9</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">

View File

@ -53,7 +53,7 @@
<p><span class="bold">Affected versions:</span>
&lt; 5.21.07 (version 4 is not affected)<br>
<span class="bold">Date:</span> 2023-09-19<br>
<span class="bold">CVE indentifier</span> -
<span class="bold">CVE indentifier</span> CVE-2023-42810
</p>
<h4>Impact</h4>

View File

@ -462,7 +462,8 @@ function dockerContainerStats(containerIDs, callback) {
if (containerIDsSanitized !== '*') {
containerIDsSanitized = '';
const s = (util.isPrototypePolluted() ? '' : util.sanitizeShellString(containerIDs, true)).trim();
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const l = util.mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (s[i] !== undefined) {
s[i].__proto__.toLowerCase = util.stringToLower;
const sl = s[i].toLowerCase();

View File

@ -45,7 +45,8 @@ function inetChecksite(url, callback) {
}
let urlSanitized = '';
const s = util.sanitizeShellString(url, true);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const l = util.mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (s[i] !== undefined) {
s[i].__proto__.toLowerCase = util.stringToLower;
const sl = s[i].toLowerCase();
@ -143,7 +144,8 @@ function inetLatency(host, callback) {
}
let hostSanitized = '';
const s = (util.isPrototypePolluted() ? '8.8.8.8' : util.sanitizeShellString(host, true)).trim();
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const l = util.mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (!(s[i] === undefined)) {
s[i].__proto__.toLowerCase = util.stringToLower;
const sl = s[i].toLowerCase();

View File

@ -745,7 +745,8 @@ function networkInterfaces(callback, rescan, defaultString) {
let ifaceSanitized = '';
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(nic.iface);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const l = util.mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (s[i] !== undefined) {
ifaceSanitized = ifaceSanitized + s[i];
}
@ -840,7 +841,8 @@ function networkInterfaces(callback, rescan, defaultString) {
let iface = dev.split(':')[0].trim().toLowerCase();
let ifaceSanitized = '';
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const l = util.mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (s[i] !== undefined) {
ifaceSanitized = ifaceSanitized + s[i];
}
@ -973,7 +975,8 @@ function networkInterfaces(callback, rescan, defaultString) {
let ifaceSanitized = '';
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(dev);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const l = util.mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (s[i] !== undefined) {
ifaceSanitized = ifaceSanitized + s[i];
}
@ -1221,7 +1224,8 @@ function networkStatsSingle(iface) {
process.nextTick(() => {
let ifaceSanitized = '';
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const l = util.mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (s[i] !== undefined) {
ifaceSanitized = ifaceSanitized + s[i];
}

View File

@ -131,7 +131,8 @@ function services(srv, callback) {
srvString.__proto__.trim = util.stringTrim;
const s = util.sanitizeShellString(srv);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const l = util.mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (s[i] !== undefined) {
srvString = srvString + s[i];
}
@ -986,7 +987,9 @@ function processLoad(proc, callback) {
processesString.__proto__.trim = util.stringTrim;
const s = util.sanitizeShellString(proc);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const l = util.mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (s[i] !== undefined) {
processesString = processesString + s[i];
}

View File

@ -682,7 +682,8 @@ function sanitizeShellString(str, strict) {
if (typeof strict === 'undefined') { strict = false; }
const s = str || '';
let result = '';
for (let i = 0; i <= mathMin(s.length, 2000); i++) {
const l = mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (!(s[i] === undefined ||
s[i] === '>' ||
s[i] === '<' ||

View File

@ -403,7 +403,9 @@ function wifiNetworks(callback) {
if (iface) {
let ifaceSanitized = '';
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface, true);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const l = util.mathMin(s.length, 2000);
for (let i = 0; i <= l; i++) {
if (s[i] !== undefined) {
ifaceSanitized = ifaceSanitized + s[i];
}
@ -539,7 +541,9 @@ function wifiConnections(callback) {
ifaces.forEach(ifaceDetail => {
let ifaceSanitized = '';
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(ifaceDetail.iface, true);
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
const ll = util.mathMin(s.length, 2000);
for (let i = 0; i <= ll; i++) {
if (s[i] !== undefined) {
ifaceSanitized = ifaceSanitized + s[i];
}
@ -551,7 +555,8 @@ function wifiConnections(callback) {
const network = networkList.filter(nw => nw.ssid === ssid);
let ssidSanitized = '';
const t = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(ssid, true);
for (let i = 0; i <= util.mathMin(t.length, 2000); i++) {
const l = util.mathMin(t.length, 2000);
for (let i = 0; i <= l; i++) {
if (t[i] !== undefined) {
ssidSanitized = ssidSanitized + t[i];
}