Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/csp.js

Issue 29705719: Issue 6402 - Split filter hit / request logging out into own API (Closed)
Patch Set: Another try at uploading the rebase diff Created May 9, 2018, 2:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include.preload.js ('k') | lib/cssInjection.js » ('j') | lib/hitLogger.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/csp.js
diff --git a/lib/csp.js b/lib/csp.js
index 38e6c3d501bbad8d1ce5818c8bc55fddab4c6647..eaef6cc439e459393f89fffbf722eb274caecea8 100644
--- a/lib/csp.js
+++ b/lib/csp.js
@@ -23,7 +23,7 @@ const {RegExpFilter, WhitelistFilter} =
const {extractHostFromFrame, isThirdParty} = require("./url");
const {checkWhitelisted} = require("./whitelisting");
const {FilterNotifier} = require("filterNotifier");
-const devtools = require("./devtools");
+const {logRequest} = require("./hitLogger");
const {typeMap} = RegExpFilter;
@@ -31,10 +31,10 @@ browser.webRequest.onHeadersReceived.addListener(details =>
{
let url = new URL(details.url);
let parentFrame = ext.getFrame(details.tabId, details.parentFrameId);
- let hostname = extractHostFromFrame(parentFrame) || url.hostname;
- let thirdParty = isThirdParty(url, hostname);
+ let docDomain = extractHostFromFrame(parentFrame) || url.hostname;
Manish Jethani 2018/05/09 15:11:11 This should remain hostname?
kzar 2018/05/09 17:58:41 Done.
+ let thirdParty = isThirdParty(url, docDomain);
- let cspMatch = defaultMatcher.matchesAny(details.url, typeMap.CSP, hostname,
+ let cspMatch = defaultMatcher.matchesAny(details.url, typeMap.CSP, docDomain,
thirdParty, null, false);
if (cspMatch)
{
@@ -52,14 +52,17 @@ browser.webRequest.onHeadersReceived.addListener(details =>
typeMap.GENERICBLOCK);
if (specificOnly)
{
- cspMatch = defaultMatcher.matchesAny(details.url, typeMap.CSP, hostname,
+ cspMatch = defaultMatcher.matchesAny(details.url, typeMap.CSP, docDomain,
thirdParty, null, specificOnly);
if (!cspMatch)
return;
}
- devtools.logRequest([details.tabId], details.url, "CSP", hostname,
- thirdParty, null, specificOnly, cspMatch);
+ logRequest(
+ [details.tabId],
+ {url: details.url, type: "CSP", docDomain, thirdParty, specificOnly},
+ cspMatch
+ );
FilterNotifier.emit("filter.hitCount", cspMatch, 0, 0, [details.tabId]);
if (cspMatch instanceof WhitelistFilter)
« no previous file with comments | « include.preload.js ('k') | lib/cssInjection.js » ('j') | lib/hitLogger.js » ('J')

Powered by Google App Engine
This is Rietveld