mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-28 02:40:53 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user