{"record":{"id":"7611e01432230c1a","repo":"shadow1ng/fscan","slug":"parser-invalid-end-ip-7611e0","errorCode":null,"errorMessage":"parser_invalid_end_ip","messagePattern":"parser_invalid_end_ip","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/parsers/parsers.go","lineNumber":363,"sourceCode":"\t}\n\n\tstartIPStr := strings.TrimSpace(parts[0])\n\tendIPStr := strings.TrimSpace(parts[1])\n\n\tstartIP := net.ParseIP(startIPStr)\n\tif startIP == nil {\n\t\treturn nil, fmt.Errorf(\"%s\", i18n.Tr(\"parser_invalid_start_ip\", startIPStr))\n\t}\n\n\t// 处理简写格式 (如: 192.168.1.1-100)\n\tif len(endIPStr) < 4 || !strings.Contains(endIPStr, \".\") {\n\t\treturn parseIPShortRange(startIPStr, endIPStr)\n\t}\n\n\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], \".\")","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/parsers/parsers.go#L345-L381","documentation":"In parseIPRangeString, for full-format ranges (end contains '.'), the end part is parsed with net.ParseIP. If invalid, 'parser_invalid_end_ip' is returned with the offending string. It means the right side of the '-' range is not a parseable IP address.","triggerScenarios":"parseIPRangeString receiving ranges like '192.168.1.1-192.168.1' or '192.168.1.1-.100' where the end token fails net.ParseIP (and is long enough / dotted enough to skip the shorthand path).","commonSituations":"Truncated end addresses in hand-written target lists, copy-paste errors dropping an octet, or scripts substituting variables that resolve to empty/malformed ends.","solutions":["Write the end address as a full dotted-quad IPv4, e.g. 192.168.1.1-192.168.1.254","Use shorthand form 192.168.1.1-100 if only the last octet varies (and end is short/undotted)","Pre-validate with net.ParseIP(parts[1]) != nil before calling ParseIP"],"exampleFix":"// before\nParseIP(\"192.168.1.1-192.168.1\", \"\")\n// after\nParseIP(\"192.168.1.1-192.168.1.254\", \"\")","handlingStrategy":"validation","validationCode":"func validEndIP(rangeStr string) bool {\n\tparts := strings.Split(rangeStr, \"-\")\n\treturn len(parts) == 2 && net.ParseIP(strings.TrimSpace(parts[1])) != nil\n}","typeGuard":null,"tryCatchPattern":"if !validEndIP(rangeStr) {\n\treturn fmt.Errorf(\"end of %q is not an IP\", rangeStr)\n}\n_, err := parsers.ParseIP(rangeStr, \"\")","preventionTips":["Write the end address as a full dotted-quad IPv4","Use numeric shorthand (e.g. .1.1-100) only for single-octet variation","Verify variable substitution in scripts that build ranges"],"tags":["ip-range","ip-parsing","invalid-input"],"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-14T05:17:10.506Z"}