{"record":{"id":"6655bdb59ca02649","repo":"shadow1ng/fscan","slug":"parser-cidr-failed-w-6655bd","errorCode":null,"errorMessage":"parser_cidr_failed: %w","messagePattern":"parser_cidr_failed: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/parsers/parsers.go","lineNumber":122,"sourceCode":"\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\thosts = append(hosts, cidrHosts...)\n\t\tcase h == \"172\":\n\t\t\tcidrHosts, err := parseIPCIDR(\"172.16.0.0/12\")\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 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// 端口解析","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/parsers/parsers.go#L104-L140","documentation":"Inside parseHostString, any comma-separated token containing '/' is treated as a CIDR and parsed by parseIPCIDR. On failure the error is wrapped with 'parser_cidr_failed' plus the offending token. It signals an invalid CIDR expression in the host list.","triggerScenarios":"parseHostString (called from ParseIP) encounters a token with '/' that net.ParseCIDR rejects — bad mask like '10.0.0.0/33', non-IP before the slash, or an IPv6 CIDR when only IPv4 is supported.","commonSituations":"Typos in netmasks, pasting 'host/path' strings accidentally, or using IPv6 CIDRs with an IPv4-only scanner.","solutions":["Fix the CIDR in the host argument (valid IPv4 + mask 0-32), e.g. 192.168.1.0/24","Remove non-CIDR tokens that merely contain '/'","Validate with net.ParseCIDR before calling ParseIP","If IPv6 is needed, confirm library support first — the matcher is IPv4-only"],"exampleFix":"// before\nParseIP(\"10.0.0.0/33\", \"\")\n// after\nParseIP(\"10.0.0.0/32\", \"\")","handlingStrategy":"validation","validationCode":"func validCIDR(s string) bool {\n\tip, _, err := net.ParseCIDR(s)\n\treturn err == nil && ip.To4() != nil\n}","typeGuard":null,"tryCatchPattern":"hosts, err := parsers.ParseIP(host, \"\")\nif err != nil {\n\tif strings.Contains(err.Error(), \"parser_cidr_failed\") {\n\t\tlog.Fatalf(\"fix CIDR in %q: %v\", host, err)\n\t}\n\treturn err\n}","preventionTips":["Validate CIDR tokens with net.ParseCIDR before calling ParseIP","Keep masks within 0-32 for IPv4","Don't include non-CIDR strings containing '/' in target lists"],"tags":["cidr","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"}