Skip to content

Commit 5a1c787

Browse files
committed
🥅 handle ajax errors
1 parent 7e17990 commit 5a1c787

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

‎security/1.2.7-sec/main.js‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ function log(txt){
44
document.querySelector('#log').append(p);
55
}
66

7+
function error(txt){
8+
const p = document.createElement("p");
9+
p.append(txt);
10+
p.classList.add('error');
11+
document.querySelector('#log').append(p);
12+
}
13+
714
window.onerror = function(message, source, lineno, colno, error) {
8-
log(message);
9-
log(error.stack);
15+
error(message, true);
16+
error(error.stack);
1017
};
1118

1219
const windowAlert = window.alert;
@@ -16,6 +23,13 @@ window.alert = function(...args) {
1623
// windowAlert(...args);
1724
};
1825

26+
$(document).ajaxError(function(...args) {
27+
error(`AJAX ERROR! CAN'T TEST FOR CVE! IS SERVER DOWN?`);
28+
for (let i = 0; i < args.length; i++) {
29+
error(JSON.stringify(args[i]));
30+
}
31+
});
32+
1933
function CVE_2012_6708() {
2034
log('called CVE_2012_6708');
2135
$("#yee").html(
@@ -29,8 +43,8 @@ function CVE_2015_9251() {
2943
// since we are relying on an external resource for this test, guard against regression
3044
const expectedContentFound = content === "alert(document.domain);";
3145
if(!expectedContentFound) {
32-
log(`unexpected content found: '${content}'`);
33-
log('CVE-2015-9251 CANNOT BE VERIFIED!');
46+
error(`unexpected content found: '${content}'`);
47+
error('CVE-2015-9251 CANNOT BE VERIFIED!');
3448
}
3549
});
3650
log('CVE-2015-9251 is not reproducible in 1.2.6, so ignore this test');

‎security/1.2.7-sec/styles.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ button {
2121
#yee {
2222
display: none;
2323
}
24+
25+
.error {
26+
color: red;
27+
}

‎security/1.6.5-sec/main.js‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ function log(txt){
44
document.querySelector('#log').append(p);
55
}
66

7+
function error(txt){
8+
const p = document.createElement("p");
9+
p.append(txt);
10+
p.classList.add('error');
11+
document.querySelector('#log').append(p);
12+
}
13+
714
window.onerror = function(message, source, lineno, colno, error) {
8-
log(message);
9-
log(error.stack);
15+
error(message, true);
16+
error(error.stack);
1017
};
1118

1219
const windowAlert = window.alert;
@@ -16,6 +23,13 @@ window.alert = function(...args) {
1623
// windowAlert(...args);
1724
};
1825

26+
$(document).ajaxError(function(...args) {
27+
error(`AJAX ERROR! CAN'T TEST FOR CVE! IS SERVER DOWN?`);
28+
for (let i = 0; i < args.length; i++) {
29+
error(JSON.stringify(args[i]));
30+
}
31+
});
32+
1933
function CVE_2012_6708() {
2034
log('called CVE_2012_6708');
2135
$("#yee").html(
@@ -29,8 +43,8 @@ function CVE_2015_9251() {
2943
// since we are relying on an external resource for this test, guard against regression
3044
const expectedContentFound = content === "alert(document.domain);";
3145
if(!expectedContentFound) {
32-
log(`unexpected content found: '${content}'`);
33-
log('CVE-2015-9251 CANNOT BE VERIFIED!');
46+
error(`unexpected content found: '${content}'`);
47+
error('CVE-2015-9251 CANNOT BE VERIFIED!');
3448
}
3549
});
3650
}

‎security/1.6.5-sec/styles.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ button {
2121
#yee {
2222
display: none;
2323
}
24+
25+
.error {
26+
color: red;
27+
}

0 commit comments

Comments
 (0)