-
-
Notifications
You must be signed in to change notification settings - Fork 246
feat: check against urls with path #6416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
eslint-warning-thresholds.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be modifying this file should we ?
urlPaths: Record<string, Record<string, Record<string, string[]>>>, | ||
) => { | ||
const urlWithProtocol = url.startsWith('http') ? url : `https://${url}`; | ||
const { hostname, pathname } = new URL(urlWithProtocol); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new URL()
throws on bad input. Should we wrap this with a try/catch?
@@ -132,6 +136,7 @@ export type PhishingStalelist = { | |||
export type PhishingListState = { | |||
allowlist: string[]; | |||
blocklist: string[]; | |||
blocklistPaths: Record<string, Record<string, Record<string, string[]>>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about a type like this instead for better readability
type PathBlockNode = {
isBlocked: boolean;
blockAllSubpaths: boolean;
children: Record<string, PathBlockNode>;
};
type BlocklistPaths = Record<string, PathBlockNode>;
- We can assume that whenever config is given to this function, that separateBlocklistEntries has already been called so this would be unnecessary to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Phishing Detector Ignores C2 Domain Blocklists
Legacy PhishingDetector
configurations no longer correctly handle c2DomainBlocklist
. The c2DomainBlocklist
property is no longer passed to getDefaultPhishingDetectorConfig
in the legacy constructor path, causing C2 domain blocklists to be ignored. This is a regression for existing legacy configurations.
packages/phishing-controller/src/PhishingDetector.ts#L76-L92
core/packages/phishing-controller/src/PhishingDetector.ts
Lines 76 to 92 in 9368c52
constructor(opts: PhishingDetectorOptions) { | |
// recommended configuration | |
if (Array.isArray(opts)) { | |
this.#configs = processConfigs(opts); | |
this.#legacyConfig = false; | |
// legacy configuration | |
} else { | |
this.#configs = [ | |
getDefaultPhishingDetectorConfig({ | |
allowlist: opts.whitelist, | |
blocklist: opts.blacklist, | |
fuzzylist: opts.fuzzylist, | |
tolerance: opts.tolerance, | |
}), | |
]; | |
this.#legacyConfig = true; | |
} |
Explanation
There has been an advent of sites such as
sites.google.com
being used maliciously that bypass the checks as they contain an allowlisted hostname. This PR aims to enable the Phishing Controller to block URL paths so that we can maintain the same allowlist but also block malicious websites that use allowlisted hostnames.References
Checklist