Skip to content

Commit 1bd6061

Browse files
committed
[XSS] Make InjectionChecker's regular expressions easier to debug.
1 parent 61ddfea commit 1bd6061

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/nscl

src/xss/InjectionCheckWorker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ include("InjectionChecker.js");
4747
let ic = new (await XSS.InjectionChecker)();
4848

4949
if (debugging) {
50-
ic.logEnabled = true;
50+
ic.debugging = true;
5151
debug("[XSS] InjectionCheckWorker started in %s ms (%s).",
5252
Date.now() - xssReq.timestamp, destUrl);
5353
} else {
@@ -91,7 +91,7 @@ include("InjectionChecker.js");
9191
if (msg.handler in Handlers) try {
9292
await Handlers[msg.handler](msg);
9393
} catch (e) {
94-
postMessage({error: e.message});
94+
postMessage({error: `${e.message}\n${e.stack}`});
9595
}
9696
}
9797

src/xss/InjectionChecker.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ XSS.InjectionChecker = (async () => {
2222
await include([
2323
"/nscl/common/SyntaxChecker.js",
2424
"/nscl/common/Base64.js",
25+
"/nscl/common/DebuggableRegExp.js",
2526
"/nscl/common/Timing.js",
2627
"/xss/FlashIdiocy.js",
2728
"/xss/ASPIdiocy.js",
@@ -83,6 +84,18 @@ XSS.InjectionChecker = (async () => {
8384
this.log = v ? this._log : function() {};
8485
},
8586

87+
_debugging: false,
88+
get debugging() {
89+
return this._debugging;
90+
},
91+
set debugging(b) {
92+
this.logEnabled = b;
93+
for (const rx of ["_maybeJSRx", "_riskyOperatorsRx"]) {
94+
if (this[rx].originalRx) this[rx] = this[rx].originalRx;
95+
if (b) this[rx] = new DebuggableRegExp(this[rx]);
96+
}
97+
},
98+
8699
escalate: function(msg) {
87100
this.log(msg);
88101
log("[InjectionChecker] ", msg);

0 commit comments

Comments
 (0)