{"record":{"id":"d540cbb98669e963","repo":"shadow1ng/fscan","slug":"parser-invalid-ip-fmt-d540cb","errorCode":null,"errorMessage":"parser_invalid_ip_fmt","messagePattern":"parser_invalid_ip_fmt","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/parsers/parsers.go","lineNumber":378,"sourceCode":"\t// 处理完整格式 (如: 192.168.1.1-192.168.1.100)\n\tendIP := net.ParseIP(endIPStr)\n\tif endIP == nil {\n\t\treturn nil, fmt.Errorf(\"%s\", i18n.Tr(\"parser_invalid_end_ip\", endIPStr))\n\t}\n\n\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) {","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/parsers/parsers.go#L360-L396","documentation":"parseIPShortRange splits the start IP string on '.' and requires exactly 4 octets. If the start portion is not a dotted-quad (or was not caught earlier), this error is returned with the bad string. It guards the subsequent prefix/octet arithmetic.","triggerScenarios":"Calling parseIPRangeString with a short-form range whose start part is not a valid dotted-quad, e.g. '192.168.1-50', '192.168.1.1.1-20', or a hostname like 'example.com-10'.","commonSituations":"Users writing hostname ranges or abbreviated IPs ('192.168-50') in scan target lists; IPv6 addresses passed to an IPv4-only parser; extra/missing dots from typos.","solutions":["Provide the start IP as a full dotted quad, e.g. '192.168.1.10-50'.","Validate the start portion has exactly 4 dot-separated numeric octets before calling.","Use a hostname resolution step first if the input may be a name rather than an IP."],"exampleFix":"// before\nParseIPRangeString(\"192.168.1-50\")\n// after\nParseIPRangeString(\"192.168.1.1-50\")","handlingStrategy":"validation","validationCode":"func validStartIP(startPart string) bool {\n    parts := strings.Split(startPart, \".\")\n    if len(parts) != 4 { return false }\n    for _, p := range parts {\n        n, err := strconv.Atoi(p)\n        if err != nil || n < 0 || n > 255 { return false }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":"ips, err := parseIPRangeString(rangeStr)\nif err != nil {\n    return fmt.Errorf(\"bad range start %q: %w\", rangeStr, err)\n}","preventionTips":["Always supply full dotted-quad start IPs","Resolve hostnames to IPs before range parsing","Reject IPv6 input early in IPv4-only code paths"],"tags":["ip-range","parsing","format"],"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"}