Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

No Bug: Backport beta with abp-rust to development. #1469

Merged
merged 23 commits into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
96b151f
Fix #1309: Don't use NSBatchDeleteRequest on In-Memory store(#1310)
danishjafri88 Jul 30, 2019
2d2f344
Fix #1314: Update bootstrap script to use the upstream YubiKit (#1315)
jumde Jul 31, 2019
280dbd4
Fix #1285: Added support for Exclusion List for WebAuthN
Brandon-T Aug 1, 2019
0caa865
No Bug: Version bumped to 1.11 (#1317) (#1318)
jhreis Aug 1, 2019
7947af5
No Bug: Add Release notes for 1.10 (#1305)
srirambv Aug 1, 2019
69ca0aa
Fix: #1320 Release Notes for 1.11 (#1321)
srirambv Aug 2, 2019
f132234
Fix #1217: Support PINs for security keys (#1303)
jumde Aug 6, 2019
6d60284
Fix #1284: Support passwordless logins for security keys (#1327)
jumde Aug 6, 2019
6a3fada
No Bug: Update rewards library, update SnapKit to 5.0.1 (#1331)
iccub Aug 6, 2019
09226a4
No Bug: Version bumped to 1.11 (#1317)
jhreis Aug 1, 2019
7bf173e
Fix #1298: Text input support for AlertPopupView (#1341)
jamesmudgett Aug 8, 2019
40dfc7c
Fix #1307: Upgrade adblock stats library to use adblock-rust. (#1308)
iccub Aug 8, 2019
d348f13
Bump lodash from 4.17.11 to 4.17.15 (#1294)
dependabot[bot] Aug 8, 2019
f78581b
Fix #1071 - Update package-lock.json to fix audit errors (#1352)
jumde Aug 8, 2019
be82ed3
Fix #1360: Handle special characters in error descriptions (#1361)
jumde Aug 9, 2019
1c13787
Fix #1349: Touch key dialog should be displayed for the tab requestin…
jumde Aug 9, 2019
1758e62
Fix #1369: No longer track app version with source control. (#1370)
jhreis Aug 10, 2019
28f1667
Fix #1373: Set dummy tab id for private mode browsing. (#1375)
iccub Aug 12, 2019
78232d5
Fix #1359, Fix #1153, Fix #1347: Improved modals for security keys (#…
jumde Aug 12, 2019
ab4f3b4
Fix #1335: Added animation UI for WebAuth, add lottie-ios dep. (#1384)
iccub Aug 13, 2019
73f87a5
Revert "Fix #1307: Upgrade adblock stats library to use adblock-rust.…
jhreis Aug 16, 2019
ddc2c22
Fix #1442: Adblock rust integration. (#1441)
iccub Aug 30, 2019
f56dd41
Merge remote-tracking branch 'origin/beta' into backport_abp_rust_beta
iccub Sep 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
- Fixed auto-focus of a tab when a link is opened using the share sheet. ([#698](https://github.com/brave/brave-ios/issues/698))
- Fixed missing translations when viewing introduction summary under private tab. ([#1239](https://github.com/brave/brave-ios/issues/1239))
- Fixed webcompat issues with https://borsen.dk/ due to Brave shields. ([#1061](https://github.com/brave/brave-ios/issues/1061))


4 changes: 4 additions & 0 deletions Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
0AA21E4A2302C4CC00358988 /* webauth_verify_key.json in Resources */ = {isa = PBXBuildFile; fileRef = 0AA21E472302C4CC00358988 /* webauth_verify_key.json */; };
0AA21E4B2302C4CC00358988 /* webauth_insert_key.json in Resources */ = {isa = PBXBuildFile; fileRef = 0AA21E482302C4CC00358988 /* webauth_insert_key.json */; };
0AA21E4C2302C4CC00358988 /* webauth_touch_key.json in Resources */ = {isa = PBXBuildFile; fileRef = 0AA21E492302C4CC00358988 /* webauth_touch_key.json */; };
0AA4AA99231849450009AAEF /* ABPFilterParserData.dat in Resources */ = {isa = PBXBuildFile; fileRef = 0AA4AA98231849440009AAEF /* ABPFilterParserData.dat */; };
0AA4FC392109D685000B173A /* CRUDProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA4FC382109D685000B173A /* CRUDProtocols.swift */; };
0AAAAC972249174A009A8763 /* SyncAlerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAAAC962249174A009A8763 /* SyncAlerts.swift */; };
0AAAACAD22491CC7009A8763 /* ErrorExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAAACAC22491CC7009A8763 /* ErrorExtensions.swift */; };
Expand Down Expand Up @@ -1216,6 +1217,7 @@
0AA21E472302C4CC00358988 /* webauth_verify_key.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = webauth_verify_key.json; sourceTree = "<group>"; };
0AA21E482302C4CC00358988 /* webauth_insert_key.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = webauth_insert_key.json; sourceTree = "<group>"; };
0AA21E492302C4CC00358988 /* webauth_touch_key.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = webauth_touch_key.json; sourceTree = "<group>"; };
0AA4AA98231849440009AAEF /* ABPFilterParserData.dat */ = {isa = PBXFileReference; lastKnownFileType = file; path = ABPFilterParserData.dat; sourceTree = "<group>"; };
0AA4FC382109D685000B173A /* CRUDProtocols.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CRUDProtocols.swift; sourceTree = "<group>"; };
0AAAAC962249174A009A8763 /* SyncAlerts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncAlerts.swift; sourceTree = "<group>"; };
0AAAACAC22491CC7009A8763 /* ErrorExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorExtensions.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2636,6 +2638,7 @@
children = (
0A063D4B22EB2945001CE50B /* ablock_rust_lib.h */,
0A063D4A22EB2945001CE50B /* libadblock.a */,
0AA4AA98231849440009AAEF /* ABPFilterParserData.dat */,
);
path = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -5209,6 +5212,7 @@
D0FCF8081FE4772D004A7995 /* MainFrameAtDocumentStart.js in Resources */,
0A0D3D5021A5609600BEE65B /* SafeBrowsingError.html in Resources */,
74821FFE1DB6D3AC00EEEA72 /* MailSchemes.plist in Resources */,
0AA4AA99231849450009AAEF /* ABPFilterParserData.dat in Resources */,
4422D57621C05DE600BF1855 /* httpse.leveldb.tgz in Resources */,
FA9294011D6584A200AC8D33 /* QRCode.xcassets in Resources */,
D308EE561CBF0BF5006843F2 /* CertError.css in Resources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
"version" : 1,
"author" : "xcode"
}
}
}
Binary file not shown.
12 changes: 8 additions & 4 deletions Client/WebFilters/AdblockResourceDownloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class AdblockResourceDownloader {

static let folderName = "abp-data"

static let endpoint = "https://adblock-data.s3.brave.com/iOS13"

init(networkManager: NetworkManager = NetworkManager(), locale: String? = Locale.current.languageCode) {
if locale == nil {
log.warning("No locale provided, using default one(\"en\")")
Expand Down Expand Up @@ -68,15 +70,17 @@ class AdblockResourceDownloader {
let fileName = type.identifier

let completedDownloads = type.associatedFiles.map { fileType -> Deferred<AdBlockNetworkResource> in
let fileExtension = "." + fileType.rawValue
let fileExtension = fileType.rawValue
let etagExtension = fileExtension + ".etag"

guard let resourceName = type.resourceName(for: fileType),
let url = URL(string: fileType.endpoint + resourceName + fileExtension) else {
guard let resourceName = type.resourceName(for: fileType), var url = type.endpoint else {
return Deferred<AdBlockNetworkResource>()
}

let etag = fileFromDocumentsAsString(fileName + etagExtension, inFolder: folderName)
url.appendPathComponent(resourceName)
url.appendPathExtension(fileExtension)

let etag = fileFromDocumentsAsString("\(fileName).\(etagExtension)", inFolder: folderName)
let request = nm.downloadResource(with: url, resourceType: .cached(etag: etag))
.mapQueue(queue) { resource in
AdBlockNetworkResource(resource: resource, fileType: fileType, type: type)
Expand Down
68 changes: 31 additions & 37 deletions Client/WebFilters/AdblockResourcesMappings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Foundation
struct AdblockResourcesMappings {
static func generalAdblockName(for fileType: FileType) -> String? {
switch fileType {
case .dat: return "rs-ABPFilterParserData"
case .json: return "latest"
case .dat: return "combined-included-rs"
case .json: return "combined-included"
default: return nil
}
}
Expand All @@ -25,41 +25,35 @@ enum ResourceLocale: String {
var resourceId = ""

switch self {
case .ar: resourceId = "9FCEECEC-52B4-4487-8E57-8781E82C91D0"
case .bg: resourceId = "FD176DD1-F9A0-4469-B43E-B1764893DD5C"
case .zh: resourceId = "11F62B02-9D1F-4263-A7F8-77D2B55D4594"
case .cs: resourceId = "7CCB6921-7FDA-4A9B-B70A-12DD0A8F08EA"
case .de: resourceId = "E71426E7-E898-401C-A195-177945415F38"
case .da: resourceId = "9EF6A21C-5014-4199-95A2-A82491274203"
case .et: resourceId = "0783DBFD-B5E0-4982-9B4A-711BDDB925B7"
case .fi: resourceId = "1C6D8556-3400-4358-B9AD-72689D7B2C46"
case .fr: resourceId = "9852EFC4-99E4-4F2D-A915-9C3196C7A1DE"
case .el: resourceId = "6C0F4C7F-969B-48A0-897A-14583015A587"
case .hu: resourceId = "EDEEE15A-6FA9-4FAC-8CA8-3565508EAAC3"
case .id: resourceId = "93123971-5AE6-47BA-93EA-BE1E4682E2B6"
case .hi: resourceId = "4C07DB6B-6377-4347-836D-68702CF1494A"
case .fa: resourceId = "C3C2F394-D7BB-4BC2-9793-E0F13B2B5971"
case .is: resourceId = "48796273-E783-431E-B864-44D3DCEA66DC"
case .he: resourceId = "85F65E06-D7DA-4144-B6A5-E1AA965D1E47"
case .it: resourceId = "AB1A661D-E946-4F29-B47F-CA3885F6A9F7"
case .ja: resourceId = "03F91310-9244-40FA-BCF6-DA31B832F34D"
case .ko: resourceId = "1E6CF01B-AFC4-47D2-AE59-3E32A1ED094F"
case .lt: resourceId = "4E8B1A63-DEBE-4B8B-AD78-3811C632B353"
case .lv: resourceId = "15B64333-BAF9-4B77-ADC8-935433CD6F4C"
case .nl: resourceId = "9D644676-4784-4982-B94D-C9AB19098D2A"
case .pl: resourceId = "BF9234EB-4CB7-4CED-9FCB-F1FD31B0666C"
case .ru, .uk, .be: resourceId = "80470EEC-970F-4F2C-BF6B-4810520C72E6"
case .es: resourceId = "AE657374-1851-4DC4-892B-9212B13B15A7"
case .sl: resourceId = "418D293D-72A8-4A28-8718-A1EE40A45AAF"
case .sv: resourceId = "7DC2AC80-5BBC-49B8-B473-A31A1145CAC1"
case .tr: resourceId = "1BE19EFD-9191-4560-878E-30ECA72B5B3C"
case .vi: resourceId = "6A0209AC-9869-4FD6-A9DF-039B4200D52C"
}

switch fileType {
case .dat: return "rs-" + resourceId
case .json: return resourceId + "-latest"
case .tgz: return ""
case .ar: return "9FCEECEC-52B4-4487-8E57-8781E82C91D0"
case .bg: return "FD176DD1-F9A0-4469-B43E-B1764893DD5C"
case .zh: return "11F62B02-9D1F-4263-A7F8-77D2B55D4594"
case .cs: return "7CCB6921-7FDA-4A9B-B70A-12DD0A8F08EA"
case .de: return "E71426E7-E898-401C-A195-177945415F38"
case .da: return "9EF6A21C-5014-4199-95A2-A82491274203"
case .et: return "0783DBFD-B5E0-4982-9B4A-711BDDB925B7"
case .fi: return "1C6D8556-3400-4358-B9AD-72689D7B2C46"
case .fr: return "9852EFC4-99E4-4F2D-A915-9C3196C7A1DE"
case .el: return "6C0F4C7F-969B-48A0-897A-14583015A587"
case .hu: return "EDEEE15A-6FA9-4FAC-8CA8-3565508EAAC3"
case .id: return "93123971-5AE6-47BA-93EA-BE1E4682E2B6"
case .hi: return "4C07DB6B-6377-4347-836D-68702CF1494A"
case .fa: return "C3C2F394-D7BB-4BC2-9793-E0F13B2B5971"
case .is: return "48796273-E783-431E-B864-44D3DCEA66DC"
case .he: return "85F65E06-D7DA-4144-B6A5-E1AA965D1E47"
case .it: return "AB1A661D-E946-4F29-B47F-CA3885F6A9F7"
case .ja: return "03F91310-9244-40FA-BCF6-DA31B832F34D"
case .ko: return "1E6CF01B-AFC4-47D2-AE59-3E32A1ED094F"
case .lt: return "4E8B1A63-DEBE-4B8B-AD78-3811C632B353"
case .lv: return "15B64333-BAF9-4B77-ADC8-935433CD6F4C"
case .nl: return "9D644676-4784-4982-B94D-C9AB19098D2A"
case .pl: return "BF9234EB-4CB7-4CED-9FCB-F1FD31B0666C"
case .ru, .uk, .be: return "80470EEC-970F-4F2C-BF6B-4810520C72E6"
case .es: return "AE657374-1851-4DC4-892B-9212B13B15A7"
case .sl: return "418D293D-72A8-4A28-8718-A1EE40A45AAF"
case .sv: return "7DC2AC80-5BBC-49B8-B473-A31A1145CAC1"
case .tr: return "1BE19EFD-9191-4560-878E-30ECA72B5B3C"
case .vi: return "6A0209AC-9869-4FD6-A9DF-039B4200D52C"
}
}
}
19 changes: 11 additions & 8 deletions Client/WebFilters/AdblockerType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ private let log = Logger.browserLogger

enum FileType: String {
case dat, json, tgz

var endpoint: String {
switch self {
case .dat: return "https://adblock-data.s3.brave.com/4/"
case .json: return "https://adblock-data.s3.brave.com/ios/"
case .tgz: return "" // Httpse resources are not supported yet.
}
}
}

enum AdblockerType {
Expand Down Expand Up @@ -57,6 +49,17 @@ enum AdblockerType {
}
}

/// A name under which given resource is stored on server.
var endpoint: URL? {
guard var url = URL(string: AdblockResourceDownloader.endpoint) else { return nil }

if case .regional = self {
url.appendPathComponent("regional")
}

return url
}

var blockListName: BlocklistName? {
switch self {
case .general: return BlocklistName.ad
Expand Down
19 changes: 19 additions & 0 deletions Client/WebFilters/ShieldStats/Adblock/AdBlockStats.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,25 @@ class AdBlockStats: LocalAdblockResourceProtocol {
}

func startLoading() {
parseBundledGeneralBlocklist()
loadDownloadedDatFiles()
}

private func parseBundledGeneralBlocklist() {
guard let path = Bundle.main.path(forResource: bundledGeneralBlocklist, ofType: "dat") else {
log.error("Can't find path for bundled general blocklist")
return
}
let fileUrl = URL(fileURLWithPath: path)

do {
let data = try Data(contentsOf: fileUrl)
generalAdblockEngine.set(data: data)
} catch {
log.error("Failed to parse bundled general blocklist: \(error)")
}
}

private func loadDownloadedDatFiles() {
let fm = FileManager.default

Expand Down Expand Up @@ -122,6 +138,9 @@ class AdBlockStats: LocalAdblockResourceProtocol {

if engine.set(data: data) {
log.debug("Adblock file with id: \(id) deserialized successfully")
// Clearing the cache or checked urls.
// The new list can bring blocked resource that were previously set as not-blocked.
fifoCacheOfUrlsChecked = FifoDict()
completion.fill(())
} else {
log.error("Failed to deserialize adblock list with id: \(id)")
Expand Down
Binary file not shown.