{"record":{"id":"12594194c13bc91b","repo":"shadow1ng/fscan","slug":"parser-ip-range-failed-w-125941","errorCode":null,"errorMessage":"parser_ip_range_failed: %w","messagePattern":"parser_ip_range_failed: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/parsers/parsers.go","lineNumber":128,"sourceCode":"\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\thosts = append(hosts, cidrHosts...)\n\t\tcase h == \"10\":\n\t\t\tcidrHosts, err := parseIPCIDR(\"10.0.0.0/8\")\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\thosts = append(hosts, cidrHosts...)\n\t\tcase strings.Contains(h, \"/\"):\n\t\t\tcidrHosts, err := parseIPCIDR(h)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(i18n.Tr(\"parser_cidr_failed\", h)+\": %w\", err)\n\t\t\t}\n\t\t\thosts = append(hosts, cidrHosts...)\n\t\tcase strings.Contains(h, \"-\") && !strings.Contains(h, \":\") && looksLikeIPRange(h):\n\t\t\trangeHosts, err := parseIPRangeString(h)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(i18n.Tr(\"parser_ip_range_failed\", h)+\": %w\", err)\n\t\t\t}\n\t\t\thosts = append(hosts, rangeHosts...)\n\t\tdefault:\n\t\t\thosts = append(hosts, h)\n\t\t}\n\t}\n\n\treturn hosts, nil\n}\n\n// =============================================================================\n// 端口解析\n// =============================================================================\n\n// ParsePort 解析端口配置字符串为端口号列表\nfunc ParsePort(ports string) []int {\n\tif ports == \"\" {\n\t\treturn nil","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/parsers/parsers.go#L110-L146","documentation":"Inside parseHostString, tokens containing '-' (without ':', looking like IP ranges) are parsed by parseIPRangeString. Failure is wrapped with 'parser_ip_range_failed' plus the offending token, indicating an invalid IP range expression in the host list.","triggerScenarios":"parseHostString sees a hyphenated token like '192.168.1.5-abc' or '192.168.1.100-192.168.1.1' that passes looksLikeIPRange but fails start/end IP parsing or produces an inverted range.","commonSituations":"Reversed ranges, ranges mixing hostnames and IPs, or domain names with hyphens misinterpreted when looksLikeIPRange misjudges them.","solutions":["Use a valid range with start <= end, e.g. 192.168.1.1-192.168.1.100","For shorthand, keep the last octet numeric (192.168.1.1-100)","Remove hyphenated strings that are not IP ranges (quote domain names elsewhere)","Pre-validate both endpoints with net.ParseIP before calling ParseIP"],"exampleFix":"// before\nParseIP(\"192.168.1.100-192.168.1.10\", \"\") // reversed\n// after\nParseIP(\"192.168.1.10-192.168.1.100\", \"\")","handlingStrategy":"validation","validationCode":"func validIPRange(s string) bool {\n\tparts := strings.Split(s, \"-\")\n\tif len(parts) != 2 { return false }\n\ta, b := net.ParseIP(parts[0]), net.ParseIP(parts[1])\n\treturn a != nil && b != nil && bytes.Compare(a, b) <= 0\n}","typeGuard":null,"tryCatchPattern":"hosts, err := parsers.ParseIP(host, \"\")\nif err != nil {\n\tif strings.Contains(err.Error(), \"parser_ip_range_failed\") {\n\t\tlog.Fatalf(\"fix range in %q: %v\", host, err)\n\t}\n\treturn err\n}","preventionTips":["Ensure start <= end in ranges","Use full IPs on both sides or numeric shorthand for the last octet only","Exclude hyphenated non-IP strings from target lists"],"tags":["ip-range","ip-parsing","invalid-input"],"backgroundTag":"invalid-argument-format","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}