{"record":{"id":"edc016a430ae956b","repo":"shadow1ng/fscan","slug":"parser-invalid-ip-range-val","errorCode":null,"errorMessage":"parser_invalid_ip_range_val","messagePattern":"parser_invalid_ip_range_val","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/parsers/parsers.go","lineNumber":384,"sourceCode":"\treturn parseIPFullRange(startIP, endIP)\n}\n\n// parseIPShortRange 解析短格式IP范围\nfunc parseIPShortRange(startIPStr, endSuffix string) ([]string, error) {\n\tendNum, err := strconv.Atoi(endSuffix)\n\tif err != nil || endNum > 255 {\n\t\treturn nil, fmt.Errorf(\"%s\", i18n.Tr(\"parser_invalid_ip_end_val\", endSuffix))\n\t}\n\n\tipParts := strings.Split(startIPStr, \".\")\n\tif len(ipParts) != 4 {\n\t\treturn nil, fmt.Errorf(\"%s\", i18n.Tr(\"parser_invalid_ip_fmt\", startIPStr))\n\t}\n\n\tprefixIP := strings.Join(ipParts[0:3], \".\")\n\tstartNum, err := strconv.Atoi(ipParts[3])\n\tif err != nil || startNum > endNum {\n\t\treturn nil, fmt.Errorf(\"%s\", i18n.Tr(\"parser_invalid_ip_range_val\", startIPStr, endSuffix))\n\t}\n\n\tvar allIP []string\n\tfor i := startNum; i <= endNum; i++ {\n\t\tallIP = append(allIP, fmt.Sprintf(\"%s.%d\", prefixIP, i))\n\t}\n\n\treturn allIP, nil\n}\n\n// parseIPFullRange 解析完整格式的IP范围\nfunc parseIPFullRange(startIP, endIP net.IP) ([]string, error) {\n\tstart4 := startIP.To4()\n\tend4 := endIP.To4()\n\tif start4 == nil || end4 == nil {\n\t\treturn nil, fmt.Errorf(\"%s\", i18n.GetText(\"parser_ipv4_only\"))\n\t}\n","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/parsers/parsers.go#L366-L402","documentation":"After validating the end suffix and 4-octet shape, parseIPShortRange converts the last octet of the start IP to an integer. This error fires when that octet is non-numeric or when the start number is greater than the end number, which would produce an empty/degenerate range.","triggerScenarios":"Ranges like '192.168.1.60-50' (start octet > end) or '192.168.1.x-50' (non-numeric start octet).","commonSituations":"Swapped start/end values when writing target ranges; typos in the final octet; auto-generated ranges where the interval collapsed to nothing.","solutions":["Swap the values so the start octet is <= the end octet, e.g. '192.168.1.10-60'.","Ensure the start IP's last octet is numeric and <= 255.","Pre-validate in code: parse both numbers and check start <= end before invoking."],"exampleFix":"// before\nParseIPRangeString(\"192.168.1.60-50\")\n// after\nParseIPRangeString(\"192.168.1.50-60\")","handlingStrategy":"validation","validationCode":"func orderedShortRange(r string) bool {\n    dash := strings.IndexByte(r, '-')\n    if dash < 0 { return false }\n    octets := strings.Split(r[:dash], \".\")\n    if len(octets) != 4 { return false }\n    start, err1 := strconv.Atoi(octets[3])\n    end, err2 := strconv.Atoi(r[dash+1:])\n    return err1 == nil && err2 == nil && start <= end\n}","typeGuard":null,"tryCatchPattern":"ips, err := parseIPRangeString(rangeStr)\nif err != nil {\n    return fmt.Errorf(\"start must be <= end in %q: %w\", rangeStr, err)\n}","preventionTips":["Compare start and end octets before building the range string","Normalize descending ranges by swapping values","Check the last octet of the start IP is numeric"],"tags":["ip-range","parsing","validation"],"backgroundTag":"invalid-argument-value","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"}