{"record":{"id":"e1ca2b5024478a0f","repo":"shadow1ng/fscan","slug":"parser-parse-exclude-failed-w","errorCode":null,"errorMessage":"parser_parse_exclude_failed: %w","messagePattern":"parser_parse_exclude_failed: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/parsers/parsers.go","lineNumber":71,"sourceCode":"\tif host != \"\" {\n\t\thostList, err := parseHostString(host)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(i18n.GetText(\"parser_parse_host_failed\")+\": %w\", err)\n\t\t}\n\t\thosts = append(hosts, hostList...)\n\t}\n\n\t// 处理排除主机\n\tif len(nohosts) > 0 {\n\t\tmatcher := newHostMatcher()\n\t\thasExclude := false\n\t\tfor _, exclude := range nohosts {\n\t\t\tif strings.TrimSpace(exclude) == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\thasExclude = true\n\t\t\tif err := matcher.add(exclude); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(i18n.GetText(\"parser_parse_exclude_failed\")+\": %w\", err)\n\t\t\t}\n\t\t}\n\t\tif hasExclude {\n\t\t\thosts = excludeFromList(hosts, matcher)\n\t\t}\n\t}\n\n\t// 去重和排序\n\thosts = removeDuplicateStrings(hosts)\n\tsort.Strings(hosts)\n\n\tif len(hosts) == 0 {\n\t\treturn nil, fmt.Errorf(\"%s\", i18n.GetText(\"parser_no_valid_hosts\"))\n\t}\n\n\treturn hosts, nil\n}\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/parsers/parsers.go#L53-L89","documentation":"ParseIP applies exclusions via hostMatcher.add for each -nohosts entry. If adding an exclusion expression fails (malformed CIDR or range inside the exclusion list), the error is wrapped with 'parser_parse_exclude_failed'. It means the exclude list, not the target list, contains an invalid expression.","triggerScenarios":"Calling ParseIP(host, file, \"10.0.0.0/33\") or any nohosts entry whose CIDR/range part fails to parse — matcher.add returns the inner error which is wrapped here.","commonSituations":"Copy-pasted exclusion lists with a bad netmask, an IPv6 CIDR passed to an IPv4-only matcher, or a broken range like '192.168.1.100-192.168.1.1'.","solutions":["Check the wrapped inner error to identify the bad exclusion entry","Correct the CIDR/range syntax in the -nohosts value","Remove the invalid entry if the exclusion is optional","Validate each exclusion string with net.ParseCIDR or the range grammar before calling ParseIP"],"exampleFix":"// before\nParseIP(\"10.0.0.0/8\", \"\", \"10.0.0.0/33\")\n// after\nParseIP(\"10.0.0.0/8\", \"\", \"10.0.0.5/32\")","handlingStrategy":"validation","validationCode":"for _, ex := range nohosts {\n\tif strings.Contains(ex, \"/\") {\n\t\tif _, _, err := net.ParseCIDR(strings.TrimSpace(ex)); err != nil {\n\t\t\treturn fmt.Errorf(\"bad exclusion CIDR %q\", ex)\n\t\t}\n\t}\n}","typeGuard":null,"tryCatchPattern":"hosts, err := parsers.ParseIP(host, file, nohosts...)\nif err != nil {\n\tif strings.Contains(err.Error(), \"parser_parse_exclude_failed\") {\n\t\tlog.Printf(\"bad exclusion entry: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Validate every -nohosts entry with net.ParseCIDR or range checks","Keep exclusion lists as simple CIDRs or exact IPs","Test exclusion lists against a known target set before scanning"],"tags":["ip-parsing","exclusion","wraps-error"],"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"}