{"record":{"id":"8c48d05845fbd828","repo":"owasp-amass/amass","slug":"ip-address-parsing-failed-8c48d0","errorCode":null,"errorMessage":"IP address parsing failed","messagePattern":"IP address parsing failed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/afmt/parse.go","lineNumber":100,"sourceCode":"\nfunc (p *ParseIPs) String() string {\n\tif p == nil {\n\t\treturn \"\"\n\t}\n\tvar builder strings.Builder\n\tfor i, ipaddr := range *p {\n\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}","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/afmt/parse.go#L82-L118","documentation":"ParseIPs is a flag.Value implementation for comma-separated IP address/range flags. Set rejects an empty string with this error before doing any parsing. Non-empty input must consist of comma-separated entries each of which is a resolvable range, a parseable IP, or a CIDR.","triggerScenarios":"Calling Set(\"\") on a *ParseIPs, e.g. `-ip \"$IP_LIST\"` where IP_LIST is empty, or passing `-ip \"\"` in a script with an unset variable.","commonSituations":"Empty environment variables in scripts, CI templates with missing inputs, or mistaken attempts to clear a default flag value with an empty string.","solutions":["Provide a non-empty comma-separated value such as \"192.168.1.1,10.0.0.0/24\".","Guard the variable in the shell (test -n) before invoking the command.","Omit the flag entirely when no IPs are needed."],"exampleFix":"// before\n-ip \"$IPS\"    # IPS empty -> IP address parsing failed\n// after\n-ip \"192.168.1.1,192.168.1.10-20,10.0.0.0/24\"","handlingStrategy":"validation","validationCode":"func validateIPsFlag(value string) error {\n\tif strings.TrimSpace(value) == \"\" {\n\t\treturn errors.New(\"flag requires at least one IP, range, or CIDR\")\n\t}\n\tfor _, v := range strings.Split(value, \",\") {\n\t\tif net.ParseIP(strings.TrimSpace(v)) == nil && !strings.Contains(v, \"-\") && !strings.Contains(v, \"/\") {\n\t\t\treturn fmt.Errorf(\"entry %q is not an IP, range, or CIDR\", v)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func isIPOrRange(s string) bool { return net.ParseIP(s) != nil || strings.ContainsAny(s, \"-/\") }","tryCatchPattern":null,"preventionTips":["Test shell variables for non-emptiness before passing them as flags.","Omit the flag entirely rather than passing an empty string.","Keep a validated IP inventory file and generate the flag from it."],"tags":["cli","flag-parsing","network","ip-address"],"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-14T00:17:10.932Z"}