Reduce cosole spam on non-debugging instances.
This commit is contained in:
parent
c1ef558694
commit
9219c4ae23
6
build.sh
6
build.sh
|
@ -110,11 +110,13 @@ fi
|
||||||
|
|
||||||
if [ "$1" != "debug" ]; then
|
if [ "$1" != "debug" ]; then
|
||||||
DBG=""
|
DBG=""
|
||||||
for file in "$SRC"/content/*.js; do
|
pushd "$SRC"
|
||||||
|
for file in **/*.js nscl/**/*.js; do
|
||||||
if grep -P '\/\/\s(REL|DEV)_ONLY' "$file" >/dev/null; then
|
if grep -P '\/\/\s(REL|DEV)_ONLY' "$file" >/dev/null; then
|
||||||
sed -re 's/\s*\/\/\s*(\S.*)\s*\/\/\s*REL_ONLY.*/\1/' -e 's/.*\/\/\s*DEV_ONLY.*//' "$file" > "$BUILD/content/$(basename "$file")"
|
sed -re 's/\s*\/\/\s*(\S.*)\s*\/\/\s*REL_ONLY.*/\1/' -e 's/.*\/\/\s*DEV_ONLY.*//' "$file" > "$BUILD/$file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
popd
|
||||||
else
|
else
|
||||||
DBG="-dbg"
|
DBG="-dbg"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -208,7 +208,7 @@ var RequestGuard = (() => {
|
||||||
for (let thing of seen) {
|
for (let thing of seen) {
|
||||||
let {request, allowed} = thing;
|
let {request, allowed} = thing;
|
||||||
request.tabId = tabId;
|
request.tabId = tabId;
|
||||||
debug(`Recording`, request);
|
debug(`Recording`, request); // DEV_ONLY
|
||||||
TabStatus._record(request, allowed ? "allowed" : "blocked");
|
TabStatus._record(request, allowed ? "allowed" : "blocked");
|
||||||
if (request.key === "noscript-probe" && request.type === "main_frame" ) {
|
if (request.key === "noscript-probe" && request.type === "main_frame" ) {
|
||||||
request.frameId = 0;
|
request.frameId = 0;
|
||||||
|
@ -260,7 +260,7 @@ var RequestGuard = (() => {
|
||||||
url, type, tabId, frameId, documentUrl: sender.url
|
url, type, tabId, frameId, documentUrl: sender.url
|
||||||
};
|
};
|
||||||
Content.reportTo(r, false, policyTypesMap[type]);
|
Content.reportTo(r, false, policyTypesMap[type]);
|
||||||
debug("Violation", type, url, tabId, frameId);
|
debug("Violation", type, url, tabId, frameId); // DEV_ONLY
|
||||||
if (type === "script" && url === sender.url) {
|
if (type === "script" && url === sender.url) {
|
||||||
TabStatus.record(r, "noscriptFrame", true);
|
TabStatus.record(r, "noscriptFrame", true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -287,7 +287,7 @@ var RequestGuard = (() => {
|
||||||
title: _("BlockedObjects"),
|
title: _("BlockedObjects"),
|
||||||
message: _("allowLocal", TAG),
|
message: _("allowLocal", TAG),
|
||||||
options});
|
options});
|
||||||
debug(`Prompt returned`, ret, sender);
|
debug(`Prompt returned`, ret, sender); // DEV_ONLY
|
||||||
if (ret.button !== 0) return;
|
if (ret.button !== 0) return;
|
||||||
if (ret.option === 2) {
|
if (ret.option === 2) {
|
||||||
return {collapse: "all"};
|
return {collapse: "all"};
|
||||||
|
@ -460,7 +460,7 @@ var RequestGuard = (() => {
|
||||||
},
|
},
|
||||||
_gc(now) {
|
_gc(now) {
|
||||||
if (!now && this._pendingGC) return;
|
if (!now && this._pendingGC) return;
|
||||||
debug("Recent requests garbage collection.");
|
debug("Recent requests garbage collection."); // DEV_ONLY
|
||||||
let request = {timeStamp: Date.now()};
|
let request = {timeStamp: Date.now()};
|
||||||
for (let last of this._byUrl.values()) {
|
for (let last of this._byUrl.values()) {
|
||||||
this.find(request, last);
|
this.find(request, last);
|
||||||
|
@ -524,7 +524,7 @@ var RequestGuard = (() => {
|
||||||
if (type in policyTypesMap) {
|
if (type in policyTypesMap) {
|
||||||
let previous = recent.find(request);
|
let previous = recent.find(request);
|
||||||
if (previous) {
|
if (previous) {
|
||||||
debug("Rapid fire request", previous);
|
debug("Rapid fire request", previous); // DEV_ONLY
|
||||||
return previous.return;
|
return previous.return;
|
||||||
}
|
}
|
||||||
(previous = request).return = ALLOW;
|
(previous = request).return = ALLOW;
|
||||||
|
@ -619,20 +619,20 @@ var RequestGuard = (() => {
|
||||||
if (pending) {
|
if (pending) {
|
||||||
if (pending.headersProcessed) {
|
if (pending.headersProcessed) {
|
||||||
if (!request.fromCache) {
|
if (!request.fromCache) {
|
||||||
debug("Headers already processed, skipping ", request);
|
debug("Headers already processed, skipping ", request); // DEV_ONLY
|
||||||
return ALLOW;
|
return ALLOW;
|
||||||
}
|
}
|
||||||
debug("Reprocessing headers for cached request ", request);
|
debug("Reprocessing headers for cached request ", request); // DEV_ONLY
|
||||||
} else {
|
} else {
|
||||||
debug("onHeadersReceived", request);
|
debug("onHeadersReceived", request); // DEV_ONLY
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug("[WARNING] no pending information for ", request);
|
debug("[WARNING] no pending information for ", request); // DEV_ONLY
|
||||||
initPendingRequest(request);
|
initPendingRequest(request);
|
||||||
pending = pendingRequests.get(request.requestId);
|
pending = pendingRequests.get(request.requestId);
|
||||||
}
|
}
|
||||||
if (request.fromCache && listeners.onHeadersReceived.resetCSP && !pending.resetCachedCSP) {
|
if (request.fromCache && listeners.onHeadersReceived.resetCSP && !pending.resetCachedCSP) {
|
||||||
debug("Resetting CSP Headers");
|
debug("Resetting CSP Headers"); // DEV_ONLY
|
||||||
pending.resetCachedCSP = true;
|
pending.resetCachedCSP = true;
|
||||||
let {responseHeaders} = request;
|
let {responseHeaders} = request;
|
||||||
let headersCount = responseHeaders.length;
|
let headersCount = responseHeaders.length;
|
||||||
|
@ -643,7 +643,7 @@ var RequestGuard = (() => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (headersCount > responseHeaders.length) {
|
if (headersCount > responseHeaders.length) {
|
||||||
debug("Resetting cached NoScript CSP header(s)", request);
|
debug("Resetting cached NoScript CSP header(s)", request); // DEV_ONLY
|
||||||
return {responseHeaders};
|
return {responseHeaders};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -670,7 +670,7 @@ var RequestGuard = (() => {
|
||||||
}
|
}
|
||||||
} // else unrestricted, either globally or per-tab
|
} // else unrestricted, either globally or per-tab
|
||||||
if (isMainFrame && !TabStatus.map.has(tabId)) {
|
if (isMainFrame && !TabStatus.map.has(tabId)) {
|
||||||
debug("No TabStatus data yet for noscriptFrame", tabId);
|
debug("No TabStatus data yet for noscriptFrame", tabId); // DEV_ONLY
|
||||||
TabStatus.record(request, "noscriptFrame",
|
TabStatus.record(request, "noscriptFrame",
|
||||||
capabilities && !capabilities.has("script"));
|
capabilities && !capabilities.has("script"));
|
||||||
}
|
}
|
||||||
|
@ -682,12 +682,12 @@ var RequestGuard = (() => {
|
||||||
*/
|
*/
|
||||||
if (header) {
|
if (header) {
|
||||||
pending.cspHeader = header;
|
pending.cspHeader = header;
|
||||||
debug(`CSP blocker on %s:`, url, header.value);
|
debug(`CSP blocker on %s:`, url, header.value); // DEV_ONLY
|
||||||
headersModified = true;
|
headersModified = true;
|
||||||
}
|
}
|
||||||
if (headersModified) {
|
if (headersModified) {
|
||||||
result = {responseHeaders};
|
result = {responseHeaders};
|
||||||
debug("Headers changed ", request);
|
debug("Headers changed ", request); // DEV_ONLY
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error(e, "Error in onHeadersReceived", request);
|
error(e, "Error in onHeadersReceived", request);
|
||||||
|
@ -702,7 +702,7 @@ var RequestGuard = (() => {
|
||||||
},
|
},
|
||||||
onResponseStarted(request) {
|
onResponseStarted(request) {
|
||||||
normalizeRequest(request);
|
normalizeRequest(request);
|
||||||
debug("onResponseStarted", request);
|
debug("onResponseStarted", request); // DEV_ONLY
|
||||||
let {requestId, url, tabId, frameId, type} = request;
|
let {requestId, url, tabId, frameId, type} = request;
|
||||||
if (type === "main_frame") {
|
if (type === "main_frame") {
|
||||||
TabStatus.initTab(tabId);
|
TabStatus.initTab(tabId);
|
||||||
|
@ -711,7 +711,7 @@ var RequestGuard = (() => {
|
||||||
let scriptBlocked = request.responseHeaders.some(
|
let scriptBlocked = request.responseHeaders.some(
|
||||||
h => csp.isMine(h) && csp.blocks(h.value, "script")
|
h => csp.isMine(h) && csp.blocks(h.value, "script")
|
||||||
);
|
);
|
||||||
debug("%s scriptBlocked=%s setting noscriptFrame on ", url, scriptBlocked, tabId, frameId);
|
debug("%s scriptBlocked=%s setting noscriptFrame on ", url, scriptBlocked, tabId, frameId); // DEV_ONLY
|
||||||
TabStatus.record(request, "noscriptFrame", scriptBlocked);
|
TabStatus.record(request, "noscriptFrame", scriptBlocked);
|
||||||
let pending = pendingRequests.get(requestId);
|
let pending = pendingRequests.get(requestId);
|
||||||
if (pending) {
|
if (pending) {
|
||||||
|
@ -764,7 +764,7 @@ var RequestGuard = (() => {
|
||||||
if (text.includes(`"inline"`)) return ABORT;
|
if (text.includes(`"inline"`)) return ABORT;
|
||||||
let report = JSON.parse(text)["csp-report"];
|
let report = JSON.parse(text)["csp-report"];
|
||||||
let originalPolicy = report["original-policy"]
|
let originalPolicy = report["original-policy"]
|
||||||
debug("CSP report", report);
|
debug("CSP report", report); // DEV_ONLY
|
||||||
let blockedURI = report['blocked-uri'];
|
let blockedURI = report['blocked-uri'];
|
||||||
if (blockedURI && blockedURI !== 'self') {
|
if (blockedURI && blockedURI !== 'self') {
|
||||||
let r = fakeRequestFromCSP(report, request);
|
let r = fakeRequestFromCSP(report, request);
|
||||||
|
|
|
@ -418,7 +418,7 @@
|
||||||
async collectSeen(tabId) {
|
async collectSeen(tabId) {
|
||||||
try {
|
try {
|
||||||
let seen = Array.from(await Messages.send("collect", {uuid: ns.local.uuid}, {tabId, frameId: 0}));
|
let seen = Array.from(await Messages.send("collect", {uuid: ns.local.uuid}, {tabId, frameId: 0}));
|
||||||
debug("Collected seen", seen);
|
debug("Collected seen", seen); // DEV_ONLY
|
||||||
return seen;
|
return seen;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await include("/nscl/common/restricted.js");
|
await include("/nscl/common/restricted.js");
|
||||||
|
|
2
src/nscl
2
src/nscl
|
@ -1 +1 @@
|
||||||
Subproject commit 674f49549c79eb0bc948231bdd4da2cdcb6bc280
|
Subproject commit 7fe7a2becdeac1b95099e3043e1aa0e027eacb7c
|
|
@ -42,7 +42,7 @@ XSS.Exceptions = (() => {
|
||||||
function logEx(...args) {
|
function logEx(...args) {
|
||||||
debug("[XSS preprocessing] Ignoring %o", xssReq, ...args);
|
debug("[XSS preprocessing] Ignoring %o", xssReq, ...args);
|
||||||
}
|
}
|
||||||
log(`Processing exceptions for `, xssReq);
|
debug(`Processing exceptions for `, xssReq); // DEV_ONLY
|
||||||
let {
|
let {
|
||||||
isCrossSite,
|
isCrossSite,
|
||||||
srcObj,
|
srcObj,
|
||||||
|
@ -68,7 +68,7 @@ XSS.Exceptions = (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/^(?:chrome|resource|moz-extension|about):/.test(srcOrigin)) {
|
if (/^(?:chrome|resource|moz-extension|about):/.test(srcOrigin)) {
|
||||||
debug("Privileged origin", srcOrigin);
|
debug("Privileged origin", srcOrigin); // DEV_ONLY
|
||||||
}
|
}
|
||||||
|
|
||||||
// destination or @source matching legacy regexp
|
// destination or @source matching legacy regexp
|
||||||
|
|
Loading…
Reference in New Issue