Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Sep 25, 2023
1 parent 1db9ee5 commit 196ec95
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
5 changes: 5 additions & 0 deletions docs/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ <h3>Full version history</h3>
</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>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 1 addition & 1 deletion docs/security.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2>SSID Command Injection Vulnerability</h2>
<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>
Expand Down
3 changes: 2 additions & 1 deletion lib/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions lib/internet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 8 additions & 4 deletions lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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];
}
Expand Down
7 changes: 5 additions & 2 deletions lib/processes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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];
}
Expand Down
3 changes: 2 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] === '<' ||
Expand Down
11 changes: 8 additions & 3 deletions lib/wifi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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];
}
Expand All @@ -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];
}
Expand Down

0 comments on commit 196ec95

Please sign in to comment.