From bfba4076b47c440c99d914037ef6bbb81aa44238 Mon Sep 17 00:00:00 2001 From: Leslie Tilton <23057410+Banrion@users.noreply.github.com> Date: Fri, 23 Jan 2026 10:25:18 -0600 Subject: [PATCH] Added a fallback url when downloading phishing url list --- .../phishing-detection/phishing-resources.ts | 6 ++ .../services/phishing-data.service.ts | 65 ++++++++++++++----- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/apps/browser/src/dirt/phishing-detection/phishing-resources.ts b/apps/browser/src/dirt/phishing-detection/phishing-resources.ts index 4cd155c8ae3..9561ba781c2 100644 --- a/apps/browser/src/dirt/phishing-detection/phishing-resources.ts +++ b/apps/browser/src/dirt/phishing-detection/phishing-resources.ts @@ -1,6 +1,8 @@ export type PhishingResource = { name?: string; remoteUrl: string; + /** Fallback URL to use if remoteUrl fails (e.g., due to SSL interception/cert issues) */ + fallbackUrl: string; checksumUrl: string; todayUrl: string; /** Matcher used to decide whether a given URL matches an entry from this resource */ @@ -19,6 +21,8 @@ export const PHISHING_RESOURCES: Record { - // Use defer to return defer(() => { const now = Date.now(); - // forkJoin kicks off both requests in parallel return forkJoin({ applicationVersion: from(this.platformUtilsService.getApplicationVersion()), remoteChecksum: from(this.fetchPhishingChecksum(this.resourceType)), @@ -247,21 +256,41 @@ export class PhishingDataService { // Streams the full phishing data set and saves it to IndexedDB private _updateFullDataSet() { - this.logService.info("[PhishingDataService] Starting FULL update..."); const resource = getPhishingResources(this.resourceType); if (!resource?.remoteUrl) { return throwError(() => new Error("Invalid resource URL")); } + this.logService.info(`[PhishingDataService] Starting FULL update using ${resource.remoteUrl}`); return from(this.apiService.nativeFetch(new Request(resource.remoteUrl))).pipe( switchMap((response) => { if (!response.ok || !response.body) { - return throwError(() => new Error(`Full fetch failed: ${response.statusText}`)); + return throwError( + () => + new Error( + `[PhishingDataService] Full fetch failed: ${response.status}, ${response.statusText}`, + ), + ); } return from(this.indexedDbService.saveUrlsFromStream(response.body)); }), + catchError((err: unknown) => { + this.logService.error( + `[PhishingDataService] Full dataset update failed using primary source ${err}`, + ); + this.logService.warning( + `[PhishingDataService] Falling back to: ${resource.fallbackUrl} (Note: Fallback data may be less up-to-date)`, + ); + // Try fallback URL + return from(this.apiService.nativeFetch(new Request(resource.fallbackUrl))).pipe( + catchError((fallbackError: unknown) => { + this.logService.error(`[PhishingDataService] Fallback source failed`); + return throwError(() => fallbackError); + }), + ); + }), ); }