Skip to content

Commit

Permalink
reverted Object.freeze because it broke some projects
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Nov 25, 2020
1 parent bd5b8ab commit a451b22
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 42 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.

| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.30.4 | 2020-11-25 | reverted Object.freeze because it broke some projects |
| 4.30.3 | 2020-11-25 | security update (prototype pollution prevention) Object.freeze |
| 4.30.2 | 2020-11-25 | security update (prototype pollution prevention) |
| 4.30.1 | 2020-11-12 | updated docs |
Expand Down
5 changes: 5 additions & 0 deletions docs/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ <h3>Full version history</h3>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.30.4</th>
<td>2020-11-25</td>
<td>reverted Object.freeze because it broke some projects</td>
</tr>
<tr>
<th scope="row">4.30.3</th>
<td>2020-11-25</td>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.30.3</span></div>
<div class="version">Current Version: <span id="version">4.30.4</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
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// Dependencies
// ----------------------------------------------------------------------------------

Object.freeze(String.prototype);
Object.freeze(Object.prototype);
// Object.freeze(String.prototype);
// Object.freeze(Object.prototype);

const lib_version = require('../package.json').version;
const util = require('./util');
Expand Down
79 changes: 42 additions & 37 deletions lib/internet.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,52 +52,57 @@ function inetChecksite(url, callback) {
status: 404,
ms: -1
};
if (urlSanitized && !util.isPrototypePolluted()) {
let t = Date.now();
if (_linux || _freebsd || _openbsd || _netbsd || _darwin || _sunos) {
let args = ' -I --connect-timeout 5 -m 5 ' + urlSanitized + ' 2>/dev/null | head -n 1 | cut -d " " -f2';
let cmd = 'curl';
exec(cmd + args, function (error, stdout) {
let statusCode = parseInt(stdout.toString());
result.status = statusCode || 404;
result.ok = !error && (statusCode === 200 || statusCode === 301 || statusCode === 302 || statusCode === 304);
result.ms = (result.ok ? Date.now() - t : -1);
if (callback) { callback(result); }
resolve(result);
});
}
if (_windows) { // if this is stable, this can be used for all OS types
const http = (urlSanitized.startsWith('https:') ? require('https') : require('http'));
try {
http.get(urlSanitized, (res) => {
const statusCode = res.statusCode;

try {
if (urlSanitized && !util.isPrototypePolluted()) {
let t = Date.now();
if (_linux || _freebsd || _openbsd || _netbsd || _darwin || _sunos) {
let args = ' -I --connect-timeout 5 -m 5 ' + urlSanitized + ' 2>/dev/null | head -n 1 | cut -d " " -f2';
let cmd = 'curl';
exec(cmd + args, function (error, stdout) {
let statusCode = parseInt(stdout.toString());
result.status = statusCode || 404;
result.ok = (statusCode === 200 || statusCode === 301 || statusCode === 302 || statusCode === 304);
result.ok = !error && (statusCode === 200 || statusCode === 301 || statusCode === 302 || statusCode === 304);
result.ms = (result.ok ? Date.now() - t : -1);
if (callback) { callback(result); }
resolve(result);
});
}
if (_windows) { // if this is stable, this can be used for all OS types
const http = (urlSanitized.startsWith('https:') ? require('https') : require('http'));
try {
http.get(urlSanitized, (res) => {
const statusCode = res.statusCode;

if (statusCode !== 200) {
res.resume();
result.ms = (result.ok ? Date.now() - t : -1);
if (callback) { callback(result); }
resolve(result);
} else {
res.on('data', () => { });
res.on('end', () => {
result.status = statusCode || 404;
result.ok = (statusCode === 200 || statusCode === 301 || statusCode === 302 || statusCode === 304);

if (statusCode !== 200) {
res.resume();
result.ms = (result.ok ? Date.now() - t : -1);
if (callback) { callback(result); }
resolve(result);
});
}
}).on('error', () => {
} else {
res.on('data', () => { });
res.on('end', () => {
result.ms = (result.ok ? Date.now() - t : -1);
if (callback) { callback(result); }
resolve(result);
});
}
}).on('error', () => {
if (callback) { callback(result); }
resolve(result);
});
} catch (err) {
if (callback) { callback(result); }
resolve(result);
});
} catch (err) {
if (callback) { callback(result); }
resolve(result);
}
}
} else {
if (callback) { callback(result); }
resolve(result);
}
} else {
} catch (err) {
if (callback) { callback(result); }
resolve(result);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ function isPrototypePolluted() {
const ms = Date.now();
if (typeof ms === 'number' && ms > 1600000000000) {
const l = ms % 100 + 15;
let c = 0;
for (let i = 0; i < l; i++) {
const r = Math.random() * 61.99999999 + 1;
const rs = parseInt(Math.floor(r).toString(), 10)
Expand Down Expand Up @@ -563,7 +562,7 @@ function isPrototypePolluted() {
notPolluted = notPolluted && (stl.length === l) && stl[l - 1] && !(stl[l])
for (let i = 0; i < l; i++) {
const s1 = st[i];
const s2 = stl[i];
const s2 = stl ? stl[i] : '';
const s1l = s1.toLowerCase();
notPolluted = notPolluted && s1l[0] === s2 && s1l[0] && !(s1l[1]);
}
Expand Down

0 comments on commit a451b22

Please sign in to comment.