1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 05:30:01 +00:00

Fix domain error.

This commit is contained in:
Jimmy Vo
2025-03-19 13:18:20 -04:00
parent 1b626d665c
commit 64c01e57b2
2 changed files with 6 additions and 29 deletions

View File

@@ -1,4 +1,3 @@
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
import { PhishingDetectionBrowserService } from "./content/phishing-detection-browser.service";
@@ -22,9 +21,9 @@ async function loadPhishingDetectionContent() {
});
if (isPhishingDomain) {
const domain = Utils.getDomain(activeUrl);
const url = new URL(activeUrl);
PhishingDetectionBrowserService.notifyUser(domain);
PhishingDetectionBrowserService.notifyUser(url.hostname);
}
}

View File

@@ -3,7 +3,6 @@ import { Subscription } from "rxjs";
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { ScheduledTaskNames } from "@bitwarden/common/platform/scheduling";
import { TaskSchedulerService } from "@bitwarden/common/platform/scheduling/task-scheduler.service";
@@ -38,9 +37,6 @@ export class PhishingDetectionService {
PhishingDetectionService.setupCheckUrlListener();
// Initializing the data for local development
PhishingDetectionService.loadMockedData();
// Register the update task
this.taskSchedulerService.registerTaskHandler(
ScheduledTaskNames.phishingDomainUpdate,
@@ -130,9 +126,10 @@ export class PhishingDetectionService {
}
}
static checkUrl(url: string): boolean {
const domain = Utils.getDomain(url);
return domain ? PhishingDetectionService.knownPhishingDomains.has(domain) : false;
static checkUrl(inputUrl: string): boolean {
const url = new URL(inputUrl);
return url ? PhishingDetectionService.knownPhishingDomains.has(url.hostname) : false;
}
static async updateKnownPhishingDomains(): Promise<void> {
@@ -211,25 +208,6 @@ export class PhishingDetectionService {
this.retryCount = 0;
}
static async getActiveUrl(): Promise<string> {
const win = await BrowserApi.getCurrentWindow();
const currentWindow = await BrowserApi.tabsQuery({ windowId: win.id, active: true });
// @TODO: Account for cases with no active windows.
return currentWindow[0].url;
}
// @TODO: WIP. We can have a pop-up or send a notification to other services.
static notifyUser(url: string) {}
// @TODO: This can be remove once we implement the real code.
static loadMockedData() {
PhishingDetectionService.knownPhishingDomains.add("google.com");
PhishingDetectionService.knownPhishingDomains.add("atlassian.net");
PhishingDetectionService.knownPhishingDomains.add("example.com");
PhishingDetectionService.knownPhishingDomains.add("w3schools.com");
}
/*
This listener will check the URL when the tab has finished loading.
*/