feat(scope): accept *.example.com in asset scope

Bug bounty programs write a domain and its subdomains as *.example.com.
ParseScopeLine rejected that line ("not recognizable as a valid
domain/IP/CIDR"), and the web scope editor rejected it before it reached
the server, so every wildcard line had to be rewritten by hand.

Drop a leading "*." label and store the line as the example.com domain
rule. Company and task scope match assets on their registrable domain, so
that rule already covers the subdomains. The wildcard is accepted only on
a registrable domain: *.api.example.com would store a rule that matches
nothing, so it is rejected along with *.co.uk and *.<IP>.

Step 1 of #519.
This commit is contained in:
Phantom-IN
2026-11-24 03:28:46 +05:30
parent 81eafd0856
commit 9d615bb1ec
4 changed files with 104 additions and 19 deletions
+10 -6
View File
@@ -84,12 +84,16 @@ function domainHostname(value: string): string | null {
if (value.startsWith("//")) candidate = `http:${value}`;
else if (!value.includes("://")) candidate = `http://${value}`;
const url = new URL(candidate);
return (
url.hostname
.replace(/^\[|\]$/g, "")
.replace(/\.$/, "")
.toLowerCase() || null
);
const hostname = url.hostname
.replace(/^\[|\]$/g, "")
.replace(/\.$/, "")
.toLowerCase();
// "*.example.com" scopes a domain and its subdomains; the server accepts it on a registrable domain.
if (hostname.startsWith("*.")) {
const domain = hostname.slice(2);
return ipVersion(domain) === null ? domain : null;
}
return hostname || null;
} catch {
return null;
}