Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/system-credential-provid…
Browse files Browse the repository at this point in the history
…er' into anya/shared-credential-migration
  • Loading branch information
amddg44 committed Dec 4, 2024
2 parents ae0d97c + befc1f1 commit f99c717
Show file tree
Hide file tree
Showing 150 changed files with 7,559 additions and 2,595 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PhishingDetection"
BuildableName = "PhishingDetection"
BlueprintName = "PhishingDetection"
BlueprintIdentifier = "MaliciousSiteProtection"
BuildableName = "MaliciousSiteProtection"
BlueprintName = "MaliciousSiteProtection"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Expand Down Expand Up @@ -539,6 +539,20 @@
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PrivacyStats"
BuildableName = "PrivacyStats"
BlueprintName = "PrivacyStats"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand Down Expand Up @@ -782,9 +796,9 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PhishingDetectionTests"
BuildableName = "PhishingDetectionTests"
BlueprintName = "PhishingDetectionTests"
BlueprintIdentifier = "MaliciousSiteProtectionTests"
BuildableName = "MaliciousSiteProtectionTests"
BlueprintName = "MaliciousSiteProtectionTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
Expand Down Expand Up @@ -818,6 +832,16 @@
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PrivacyStatsTests"
BuildableName = "PrivacyStatsTests"
BlueprintName = "PrivacyStatsTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
35 changes: 31 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "dfef00ef77f5181d1d8a4f7cc88f7b7c0514dd34",
"version" : "6.39.0"
"revision" : "c4bb146afdf0c7a93fb9a7d95b1cb255708a470d",
"version" : "6.41.0"
}
},
{
Expand Down Expand Up @@ -50,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/privacy-dashboard",
"state" : {
"revision" : "757bbbae1e2afbb421caee9bfca04ee5c56c3af8",
"version" : "7.2.0"
"revision" : "49db79829dcb166b3524afdbc1c680890452ce1c",
"version" : "7.2.1"
}
},
{
Expand All @@ -63,6 +63,24 @@
"version" : "3.0.0"
}
},
{
"identity" : "swift-clocks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-clocks.git",
"state" : {
"revision" : "b9b24b69e2adda099a1fa381cda1eeec272d5b53",
"version" : "1.0.5"
}
},
{
"identity" : "swift-concurrency-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
"state" : {
"revision" : "163409ef7dae9d960b87f34b51587b6609a76c1f",
"version" : "1.3.0"
}
},
{
"identity" : "swifter",
"kind" : "remoteSourceControl",
Expand All @@ -89,6 +107,15 @@
"revision" : "5de0a610a7927b638a5fd463a53032c9934a2c3b",
"version" : "3.0.0"
}
},
{
"identity" : "xctest-dynamic-overlay",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "a3f634d1a409c7979cabc0a71b3f26ffa9fc8af1",
"version" : "1.4.3"
}
}
],
"version" : 2
Expand Down
55 changes: 42 additions & 13 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,24 @@ let package = Package(
.library(name: "PixelKitTestingUtilities", targets: ["PixelKitTestingUtilities"]),
.library(name: "SpecialErrorPages", targets: ["SpecialErrorPages"]),
.library(name: "DuckPlayer", targets: ["DuckPlayer"]),
.library(name: "PhishingDetection", targets: ["PhishingDetection"]),
.library(name: "MaliciousSiteProtection", targets: ["MaliciousSiteProtection"]),
.library(name: "Onboarding", targets: ["Onboarding"]),
.library(name: "BrokenSitePrompt", targets: ["BrokenSitePrompt"]),
.library(name: "PageRefreshMonitor", targets: ["PageRefreshMonitor"]),
.library(name: "PrivacyStats", targets: ["PrivacyStats"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/duckduckgo-autofill.git", exact: "15.1.0"),
.package(url: "https://github.com/duckduckgo/GRDB.swift.git", exact: "2.4.2"),
.package(url: "https://github.com/duckduckgo/TrackerRadarKit", exact: "3.0.0"),
.package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.3.0"),
.package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "3.0.0"),
.package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "6.39.0"),
.package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "7.2.0"),
.package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "6.41.0"),
.package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "7.2.1"),
.package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"),
.package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"),
.package(url: "https://github.com/1024jp/GzipSwift.git", exact: "6.0.1")
.package(url: "https://github.com/1024jp/GzipSwift.git", exact: "6.0.1"),
.package(url: "https://github.com/pointfreeco/swift-clocks.git", exact: "1.0.5"),
],
targets: [
.target(
Expand Down Expand Up @@ -249,6 +251,7 @@ let package = Package(
"ContentBlocking",
"Persistence",
"BrowserServicesKit",
"MaliciousSiteProtection",
.product(name: "PrivacyDashboardResources", package: "privacy-dashboard")
],
path: "Sources/PrivacyDashboard",
Expand Down Expand Up @@ -390,7 +393,8 @@ let package = Package(
dependencies: [
"Common",
"UserScript",
"BrowserServicesKit"
"BrowserServicesKit",
"MaliciousSiteProtection",
],
swiftSettings: [
.define("DEBUG", .when(configuration: .debug))
Expand All @@ -407,9 +411,11 @@ let package = Package(
]
),
.target(
name: "PhishingDetection",
name: "MaliciousSiteProtection",
dependencies: [
"Common"
"Common",
"Networking",
"PixelKit",
],
swiftSettings: [
.define("DEBUG", .when(configuration: .debug))
Expand Down Expand Up @@ -445,6 +451,20 @@ let package = Package(
.define("DEBUG", .when(configuration: .debug))
]
),
.target(
name: "PrivacyStats",
dependencies: [
"Common",
"Persistence",
"TrackerRadarKit"
],
resources: [
.process("PrivacyStats.xcdatamodeld")
],
swiftSettings: [
.define("DEBUG", .when(configuration: .debug))
]
),

// MARK: - Test Targets
.testTarget(
Expand Down Expand Up @@ -640,19 +660,21 @@ let package = Package(
.testTarget(
name: "DuckPlayerTests",
dependencies: [
"DuckPlayer"
"DuckPlayer",
"BrowserServicesKitTestsUtils",
]
),

.testTarget(
name: "PhishingDetectionTests",
name: "MaliciousSiteProtectionTests",
dependencies: [
"PhishingDetection",
"PixelKit"
"TestUtils",
"MaliciousSiteProtection",
.product(name: "Clocks", package: "swift-clocks"),
],
resources: [
.copy("Resources/hashPrefixes.json"),
.copy("Resources/filterSet.json")
.copy("Resources/phishingHashPrefixes.json"),
.copy("Resources/phishingFilterSet.json"),
]
),
.testTarget(
Expand All @@ -679,6 +701,13 @@ let package = Package(
"PageRefreshMonitor"
]
),
.testTarget(
name: "PrivacyStatsTests",
dependencies: [
"PrivacyStats",
"TestUtils",
]
),
],
cxxLanguageStandard: .cxx11
)
4 changes: 2 additions & 2 deletions Sources/BrowserServicesKit/Autofill/AutofillUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
//

import Common
import WebKit
import UserScript
import os.log
import UserScript
@preconcurrency import WebKit

var previousIncontextSignupPermanentlyDismissedAt: Double?
var previousEmailSignedIn: Bool?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ public enum ContentBlockerDebugEvents {

case contentBlockingCompilationTime

case contentBlockingLookupRulesSucceeded
case contentBlockingFetchLRCSucceeded
case contentBlockingLRCMissing
case contentBlockingNoMatchInLRC
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,17 @@ public class ContentBlockerRulesManager: CompiledRuleListsSource {

if !self.lookupCompiledRules() {
if let lastCompiledRules = lastCompiledRulesStore?.rules, !lastCompiledRules.isEmpty {
self.fetchLastCompiledRules(with: lastCompiledRules)
if self.fetchLastCompiledRules(with: lastCompiledRules) {
self.errorReporting?.fire(.contentBlockingFetchLRCSucceeded)
} else {
self.errorReporting?.fire(.contentBlockingNoMatchInLRC)
}
} else {
self.errorReporting?.fire(.contentBlockingLRCMissing)
self.startCompilationProcess()
}
} else {
self.errorReporting?.fire(.contentBlockingLookupRulesSucceeded)
}
}
}
Expand Down Expand Up @@ -261,7 +268,7 @@ public class ContentBlockerRulesManager: CompiledRuleListsSource {
Go through source managers and check if there are already compiled rules in the WebKit rule cache.
Returns true if rules were found, false otherwise.
*/
private func fetchLastCompiledRules(with lastCompiledRules: [LastCompiledRules]) {
private func fetchLastCompiledRules(with lastCompiledRules: [LastCompiledRules]) -> Bool {
Logger.contentBlocking.debug("Fetch last compiled rules: \(lastCompiledRules.count, privacy: .public)")

let initialCompilationTask = LastCompiledRulesLookupTask(sourceRules: rulesSource.contentBlockerRulesLists,
Expand All @@ -274,8 +281,10 @@ public class ContentBlockerRulesManager: CompiledRuleListsSource {
// We want to confine Compilation work to WorkQueue, so we wait to come back from async Task
mutex.wait()

if let rules = initialCompilationTask.getFetchedRules() {
applyRules(rules)
let rulesFound = initialCompilationTask.getFetchedRules()

if let rulesFound {
applyRules(rulesFound)
} else {
lock.lock()
state = .idle
Expand All @@ -284,6 +293,8 @@ public class ContentBlockerRulesManager: CompiledRuleListsSource {

// No matter if rules were found or not, we need to schedule recompilation, after all
scheduleCompilation()

return rulesFound != nil
}

private func prepareSourceManagers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
// limitations under the License.
//

import WebKit
import Common
import ContentBlocking
import TrackerRadarKit
import UserScript
import ContentBlocking
import Common
@preconcurrency import WebKit

public protocol SurrogatesUserScriptDelegate: NSObjectProtocol {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public final class SpecialPagesUserScript: NSObject, UserScript, UserScriptMessa
@available(macOS 11.0, iOS 14.0, *)
extension SpecialPagesUserScript: WKScriptMessageHandlerWithReply {
@MainActor
public func userContentController(_ userContentController: WKUserContentController,
didReceive message: WKScriptMessage) async -> (Any?, String?) {
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) async -> (Any?, String?) {
let action = broker.messageHandlerFor(message)
do {
let json = try await broker.execute(action: action, original: message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import Combine
import Common
import UserScript
import WebKit
import QuartzCore
import os.log
import QuartzCore
import UserScript
@preconcurrency import WebKit

public protocol UserContentControllerDelegate: AnyObject {
@MainActor
Expand Down
Loading

0 comments on commit f99c717

Please sign in to comment.