{"record":{"id":"b5006434d759d1f8","repo":"owasp-amass/amass","slug":"s-is-not-a-valid-ip-address-or-range-b50064","errorCode":null,"errorMessage":"%s is not a valid IP address or range","messagePattern":"(.+?) is not a valid IP address or range","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/afmt/parse.go","lineNumber":107,"sourceCode":"\t\tif i > 0 {\n\t\t\tbuilder.WriteRune(',')\n\t\t}\n\t\tbuilder.WriteString(ipaddr.String())\n\t}\n\treturn builder.String()\n}\n\n// Set implements the flag.Value interface.\nfunc (p *ParseIPs) Set(s string) error {\n\tif s == \"\" {\n\t\treturn fmt.Errorf(\"IP address parsing failed\")\n\t}\n\n\tfor _, v := range strings.Split(s, \",\") {\n\t\tif start, end, ok := parseRange(v); ok {\n\t\t\tips := amassnet.RangeHosts(start, end)\n\t\t\tif len(ips) == 0 {\n\t\t\t\treturn fmt.Errorf(\"%s is not a valid IP address or range\", v)\n\t\t\t}\n\t\t\tfor _, ip := range ips {\n\t\t\t\t*p = append(*p, ip)\n\t\t\t}\n\t\t\tcontinue\n\t\t} else if ip := net.ParseIP(v); ip != nil {\n\t\t\t*p = append(*p, ip)\n\t\t\tcontinue\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"%s is not a valid IP address or range\", v)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc parseRange(s string) (start net.IP, end net.IP, ok bool) {\n\ttwoIPs := strings.Split(s, \"-\")\n\tif len(twoIPs) != 2 {","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/afmt/parse.go#L89-L125","documentation":"Within ParseIPs.Set, each comma-separated entry is first tried via parseRange; if range-like, amassnet.RangeHosts must yield at least one IP. If the range yields zero hosts — or the entry is otherwise not a single valid IP — the flag returns this per-entry error, keeping the parsed []net.IP free of unusable entries.","triggerScenarios":"Passing a range whose start >= end or with mismatched address families (e.g. \"10.0.0.5-10.0.0.1\", \"192.168.1.1-::10\") so RangeHosts returns zero IPs, or a token that fails range parsing and net.ParseIP (e.g. \"192.168.1.999\", \"example.com\").","commonSituations":"Reversed ranges after copy-paste, hostnames given where only IPs are accepted, octet typos producing unparseable addresses, IPv4/IPv6 mixing in ranges.","solutions":["Validate each entry with net.ParseIP or as start-end range before passing the flag.","Fix reversed ranges so start < end within the same address family.","Replace hostnames with resolved IP addresses; DNS names are not accepted here."],"exampleFix":"// before\n-ip \"example.com,192.168.1.1\"    // example.com is not a valid IP address or range\n// after\n-ip \"93.184.216.34,192.168.1.1\"  // use the resolved address","handlingStrategy":"validation","validationCode":"func validIPRangeEntry(v string) bool {\n\tif ip := net.ParseIP(v); ip != nil { return true }\n\tif i := strings.Index(v, \"-\"); i > 0 {\n\t\tstart, end := net.ParseIP(v[:i]), net.ParseIP(v[i+1:])\n\t\tif start != nil && end != nil {\n\t\t\treturn bytes.Compare(start.To16(), end.To16()) <= 0\n\t\t}\n\t}\n\treturn false\n}","typeGuard":"func isParseableIP(s string) bool { return net.ParseIP(s) != nil }","tryCatchPattern":null,"preventionTips":["Resolve hostnames to IPs before passing them; hostnames are not accepted.","Ensure range start < end and both endpoints share the same address family.","Run net.ParseIP on each entry in a pre-check script."],"tags":["cli","flag-parsing","ip-address","validation"],"backgroundTag":"invalid-flag-value","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}