{"record":{"id":"4fb422b2bcbb2784","repo":"shadow1ng/fscan","slug":"parser-cidr-failed-w","errorCode":null,"errorMessage":"parser_cidr_failed: %w","messagePattern":"parser_cidr_failed: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/parsers/host_iterator.go","lineNumber":307,"sourceCode":"\t\t\treturn nil, err\n\t\t}\n\t\tsources = append(sources, src)\n\t}\n\treturn sources, nil\n}\n\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}","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/parsers/host_iterator.go#L289-L325","documentation":"newHostSource fails when a host expression containing '/' looks like a CIDR but newCIDRHostSource cannot parse it, wrapping the parse error with an i18n message. It indicates malformed CIDR notation in the target specification.","triggerScenarios":"Passing targets like '192.168.1.0/33', 'abc/24', or '192.168.1.0/xx' where the prefix length or base address is invalid.","commonSituations":"Hand-written target lists with typos; copied CIDR with wrong prefix length; variable interpolation producing 'prefix/24' garbage.","solutions":["Correct the CIDR notation (valid base IP and prefix 0-32)","Validate CIDR strings with net.ParseCIDR before passing them","Split multiple targets and test each individually to locate the bad one"],"exampleFix":"// before\ntargets := []string{\"192.168.1.0/33\"}\n// after\nfor _, t := range targets {\n    if _, _, err := net.ParseCIDR(t); err != nil { log.Fatalf(\"bad CIDR %s: %v\", t, err) }\n}","handlingStrategy":"validation","validationCode":"if strings.Contains(target, \"/\") {\n    if _, _, err := net.ParseCIDR(target); err != nil {\n        return fmt.Errorf(\"invalid CIDR %q: %w\", target, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"srcs, err := newHostSources(targets)\nif err != nil {\n    if strings.Contains(err.Error(), \"parser_cidr_failed\") {\n        log.Fatalf(\"fix CIDR notation: %v\", err)\n    }\n}","preventionTips":["Validate all target expressions with net.ParseCIDR/net.ParseIP up front","Generate CIDRs programmatically instead of hand-writing them","Trim whitespace and stray characters from targets"],"tags":["cidr","parsing","network","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-14T05:17:10.506Z"}