Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Fix websockets bypass in Brave filtering
Browse files Browse the repository at this point in the history
Fix #6997.
Requires brave/muon#160

Auditors: @bridiver

Test Plan: covered by automated test
  • Loading branch information
diracdeltas committed Feb 16, 2017
1 parent 0d3dacf commit f91f678
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ function initForPartition (partition) {
fns.forEach((fn) => { fn(ses, partition, module.exports.isPrivate(partition)) })
}

const filterableProtocols = ['http:', 'https:']
const filterableProtocols = ['http:', 'https:', 'ws:', 'wss:']

function shouldIgnoreUrl (details) {
// internal requests
Expand Down
18 changes: 18 additions & 0 deletions test/components/braveryPanelTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,24 @@ describe('Bravery Panel', function () {
.click(blockAdsOption)
.waitForTextValue(adsBlockedStat, '2')
})
it('blocks websocket tracking', function * () {
const url = Brave.server.url('websockets.html')
yield this.app.client
.waitForDataFile('adblock')
.tabByIndex(0)
.loadUrl(url)
.waitForTextValue('#result', 'success')
.waitForTextValue('#error', 'error')
.openBraveMenu(braveMenu, braveryPanel)
.waitForTextValue(adsBlockedStat, '1')
.click(adsBlockedStat)
.waitUntil(function () {
return this.getText('.braveryPanelBody li')
.then((body) => {
return body[0] === 'ws://ag.innovid.com/dv/sync?tid=2'
})
})
})
// TODO(bridiver) using slashdot won't provide reliable results so we should
// create our own iframe page with urls we expect to be blocked
it('detects blocked elements in iframe in private tab', function * () {
Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/websockets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div id='result'></div>
<div id='error'></div>
<script>
// This should get blocked by adblock if it is on
var exampleSocket = new WebSocket("ws://ag.innovid.com/dv/sync?tid=2");
exampleSocket.onerror = (e) => {
document.getElementById('error').innerText = 'error'
}
// This should be a valid connection
var ws = new WebSocket("wss://wss.websocketstest.com:443/service")
ws.onopen = function() {
document.getElementById('result').innerText = 'success'
}
</script>

0 comments on commit f91f678

Please sign in to comment.