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

Commit

Permalink
Merge pull request #13638 from bsclifton/revert-hsts
Browse files Browse the repository at this point in the history
Revert "Merge pull request #13437 from brave/hsts-fingerprinting"
  • Loading branch information
bsclifton committed Mar 28, 2018
1 parent 0c503ab commit cf9ee27
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 151 deletions.
21 changes: 0 additions & 21 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,6 @@ function registerForHeadersReceived (session, partition) {
muonCb({ cancel: true })
return
}

let parsedTargetUrl = urlParse(details.url || '')
let parsedFirstPartyUrl = urlParse(firstPartyUrl)
const trackableSecurityHeaders = ['Strict-Transport-Security', 'Expect-CT',
'Public-Key-Pins', 'Public-Key-Pins-Report-Only']
if (isThirdPartyHost(parsedFirstPartyUrl.hostname, parsedTargetUrl.hostname)) {
trackableSecurityHeaders.forEach(function (header) {
delete details.responseHeaders[header]
delete details.responseHeaders[header.toLowerCase()]
})
}

for (let i = 0; i < headersReceivedFilteringFns.length; i++) {
let results = headersReceivedFilteringFns[i](details, isPrivate)
if (!module.exports.isResourceEnabled(results.resourceName, firstPartyUrl, isPrivate)) {
Expand Down Expand Up @@ -841,15 +829,6 @@ module.exports.clearStorageData = () => {
}
}

module.exports.clearHSTSData = () => {
for (let partition in registeredSessions) {
let ses = registeredSessions[partition]
setImmediate(() => {
ses.clearHSTSData.bind(ses)(() => {})
})
}
}

/**
* Clears all session caches.
*/
Expand Down
8 changes: 1 addition & 7 deletions app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -823,15 +823,9 @@ module.exports.runPreMigrations = (data) => {
}

if (data.lastAppVersion) {
let runHSTSCleanup = false
try { runHSTSCleanup = compareVersions(data.lastAppVersion, '0.22.00') < 1 } catch (e) {}

if (runHSTSCleanup) {
filtering.clearHSTSData()
}

// Force WidevineCdm to be upgraded when last app version <= 0.18.25
let runWidevineCleanup = false

try { runWidevineCleanup = compareVersions(data.lastAppVersion, '0.18.25') < 1 } catch (e) {}

if (runWidevineCleanup) {
Expand Down
145 changes: 49 additions & 96 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 0 additions & 27 deletions test/unit/app/sessionStoreTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ const compareVersions = require('compare-versions')
require('../braveUnit')

describe('sessionStore unit tests', function () {
let filtering
let sessionStore

let shutdownClearHistory = false
let shutdownClearAutocompleteData = false
let shutdownClearAutofillData = false
Expand All @@ -40,7 +38,6 @@ describe('sessionStore unit tests', function () {
}
}
const fakeFiltering = {
clearHSTSData: () => {},
clearStorageData: () => {},
clearCache: () => {},
clearHistory: () => {}
Expand Down Expand Up @@ -93,7 +90,6 @@ describe('sessionStore unit tests', function () {
}
})
mockery.registerMock('./filtering', fakeFiltering)
filtering = require('./filtering')
sessionStore = require('../../../app/sessionStore')
})

Expand Down Expand Up @@ -788,7 +784,6 @@ describe('sessionStore unit tests', function () {
let localeInitSpy
let backupSessionStub
let runImportDefaultSettings
let clearHSTSDataSpy

before(function () {
runPreMigrationsSpy = sinon.spy(sessionStore, 'runPreMigrations')
Expand All @@ -798,7 +793,6 @@ describe('sessionStore unit tests', function () {
localeInitSpy = sinon.spy(fakeLocale, 'init')
backupSessionStub = sinon.stub(sessionStore, 'backupSession')
runImportDefaultSettings = sinon.spy(sessionStore, 'runImportDefaultSettings')
clearHSTSDataSpy = sinon.spy(filtering, 'clearHSTSData')
})

after(function () {
Expand All @@ -808,27 +802,6 @@ describe('sessionStore unit tests', function () {
runPostMigrationsSpy.restore()
localeInitSpy.restore()
backupSessionStub.restore()
clearHSTSDataSpy.restore()
})

describe('check clearHSTSData invocations', function () {
describe('if lastAppVersion is 0.23', function () {
it('clearHSTSData is not invoked', function () {
let exampleState = sessionStore.defaultAppState()
exampleState.lastAppVersion = '0.23'
sessionStore.runPreMigrations(exampleState)
assert.equal(clearHSTSDataSpy.notCalled, true)
})
})

describe('if lastAppVersion is 0.21', function () {
it('clearHSTSData is calledOnce', function () {
let exampleState = sessionStore.defaultAppState()
exampleState.lastAppVersion = '0.21'
sessionStore.runPreMigrations(exampleState)
assert.equal(clearHSTSDataSpy.calledOnce, true)
})
})
})

describe('when reading the session file', function () {
Expand Down

0 comments on commit cf9ee27

Please sign in to comment.