From 9a664f7b3b6a5315983317b0e47128b809bc5531 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sat, 29 Feb 2020 19:01:45 +0100 Subject: Refactored XSS filter into an asynchronous worker to better handle DOS attempts. --- src/lib/Timing.js | 4 ++-- src/lib/log.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/Timing.js b/src/lib/Timing.js index 997ebd3..dd4fa06 100644 --- a/src/lib/Timing.js +++ b/src/lib/Timing.js @@ -15,7 +15,7 @@ class Timing { } async pause() { - if (this.interrupted) throw new TimingException("Interrupted"); + if (this.interrupted) throw new TimingException("Timing: interrupted"); let now = Date.now(); this.calls++; let sinceLastCall = now - this.lastCall; @@ -28,7 +28,7 @@ class Timing { if (now - this.lastPause > this.workSlot || this.calls > this.maxCalls) { this.tooLong = this.elapsed >= this.longTime; if (this.tooLong && this.fatalTimeout) { - throw new TimingException(`Exceeded ${this.longTime}ms timeout`); + throw new TimingException(`Timing: exceeded ${this.longTime}ms timeout`); } this.calls = 0; await Timing.sleep(this.pauseTime); diff --git a/src/lib/log.js b/src/lib/log.js index f548c49..a30a5a6 100644 --- a/src/lib/log.js +++ b/src/lib/log.js @@ -1,6 +1,8 @@ { - let PREFIX = `[${browser.runtime.getManifest().name}]`; + let PREFIX = typeof browser === "object" + ? `[${browser.runtime.getManifest().name}]` : ''; + let debugCount = 0; function log(msg, ...rest) { -- cgit v1.2.3