{"record":{"id":"9d51d9e44a4b8dda","repo":"shadow1ng/fscan","slug":"parser-ip-range-failed-w","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/host_iterator.go","lineNumber":313,"sourceCode":"\nfunc newHostSource(host string) (hostSource, error) {\n\tswitch {\n\tcase host == \"192\":\n\t\treturn newCIDRHostSource(\"192.168.0.0/16\")\n\tcase host == \"172\":\n\t\treturn newCIDRHostSource(\"172.16.0.0/12\")\n\tcase host == \"10\":\n\t\treturn newCIDRHostSource(\"10.0.0.0/8\")\n\tcase strings.Contains(host, \"/\"):\n\t\tsrc, err := newCIDRHostSource(host)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(i18n.Tr(\"parser_cidr_failed\", host)+\": %w\", err)\n\t\t}\n\t\treturn src, nil\n\tcase strings.Contains(host, \"-\") && !strings.Contains(host, \":\") && looksLikeIPRange(host):\n\t\tsrc, err := newRangeHostSource(host)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(i18n.Tr(\"parser_ip_range_failed\", host)+\": %w\", err)\n\t\t}\n\t\treturn src, nil\n\tdefault:\n\t\treturn &singleHostSource{host: host}, nil\n\t}\n}\n\nfunc newCIDRHostSource(cidr string) (hostSource, error) {\n\t_, ipNet, err := net.ParseCIDR(cidr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tstart, ok := ipToUint32(ipNet.IP)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"%s\", i18n.GetText(\"parser_ipv4_only\"))\n\t}\n\tones, bits := ipNet.Mask.Size()","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/parsers/host_iterator.go#L295-L331","documentation":"newHostSource fails when a host expression containing '-' and looking like an IP range cannot be parsed by newRangeHostSource, wrapping the parse error with an i18n message. It indicates a malformed IP range in the target specification.","triggerScenarios":"Passing ranges like '192.168.1.5-192.168.1.2' (start > end), '192.168.1.5-999', or truncated tails where looksLikeIPRange passed but parsing failed.","commonSituations":"Typos in range endpoints; octet values above 255; reversed start/end; truncated copy-paste of a range.","solutions":["Correct the range: valid IPs and start <= end, e.g. 192.168.1.1-192.168.1.254","Validate endpoints with net.ParseIP before passing","Check the wrapped error to see the exact parse failure"],"exampleFix":"// before\n\"192.168.1.10-192.168.1.2\" // reversed\n// after\n\"192.168.1.2-192.168.1.10\"","handlingStrategy":"validation","validationCode":"if strings.Contains(target, \"-\") {\n    parts := strings.SplitN(target, \"-\", 2)\n    a, b := net.ParseIP(parts[0]), net.ParseIP(parts[1])\n    if a == nil || b == nil || compareIP(a, b) > 0 {\n        return fmt.Errorf(\"invalid IP range %q\", target)\n    }\n}","typeGuard":null,"tryCatchPattern":"srcs, err := newHostSources(targets)\nif err != nil {\n    if strings.Contains(err.Error(), \"parser_ip_range_failed\") {\n        log.Fatalf(\"fix IP range: %v\", err)\n    }\n}","preventionTips":["Ensure range start <= end and both endpoints are valid IPs","Avoid octets above 255 and truncated tails","Sanitize copy-pasted target lists before use"],"tags":["ip-range","parsing","validation"],"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"}