{"record":{"id":"86fe292c4c3e2736","repo":"shadow1ng/fscan","slug":"parser-no-valid-hosts","errorCode":null,"errorMessage":"parser_no_valid_hosts","messagePattern":"parser_no_valid_hosts","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/parsers/parsers.go","lineNumber":84,"sourceCode":"\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\n// parseHostString 解析主机字符串\nfunc parseHostString(host string) ([]string, error) {\n\tvar hosts []string\n\n\tfor _, h := range strings.Split(host, \",\") {\n\t\th = strings.TrimSpace(h)\n\t\tif h == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch {\n\t\tcase h == \"192\":\n\t\t\tcidrHosts, err := parseIPCIDR(\"192.168.0.0/16\")","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/parsers/parsers.go#L66-L102","documentation":"After collecting hosts from the file and host argument and applying exclusions, ParseIP requires at least one remaining target. If the deduplicated, sorted list is empty it returns 'parser_no_valid_hosts'. This fires when no hosts were supplied, every line failed to parse (invalid lines are skipped), or exclusions removed everything.","triggerScenarios":"ParseIP(\"\", \"\") with no file; a hosts file containing only unparseable lines; or targets fully consumed by the nohosts list (e.g. ParseIP(\"192.168.1.0/24\",\"\",\"192.168.1.0/24\")).","commonSituations":"Forgetting the -h argument, pointing -hf at an empty or comment-only file, or an exclusion pattern that overlaps all targets.","solutions":["Provide a non-empty host argument (e.g. -h 192.168.1.0/24) or a valid hosts file","Check the hosts file for content and that entries are in a supported format","Reduce or correct the nohosts list so it doesn't exclude every target","Log/inspect skipped file lines — parseHostString errors are silently ignored"],"exampleFix":"// before\nParseIP(\"\", \"\") // nothing to scan\n// after\nParseIP(\"192.168.1.0/24\", \"\")","handlingStrategy":"validation","validationCode":"if host == \"\" && filename == \"\" {\n\treturn errors.New(\"no targets: provide -h or -hf\")\n}\nif filename != \"\" {\n\tif data, _ := os.ReadFile(filename); len(strings.TrimSpace(string(data))) == 0 {\n\t\treturn errors.New(\"hosts file is empty\")\n\t}\n}","typeGuard":null,"tryCatchPattern":"hosts, err := parsers.ParseIP(host, file, nohosts...)\nif err != nil {\n\tif strings.Contains(err.Error(), \"parser_no_valid_hosts\") {\n\t\tlog.Fatalf(\"no scannable targets remained (check -h/-hf and exclusions)\")\n\t}\n\treturn err\n}","preventionTips":["Always supply at least one target source","Keep exclusion patterns narrower than the target set","Check hosts-file lines parse; invalid lines are skipped silently"],"tags":["empty-input","validation","ip-parsing"],"backgroundTag":"empty-result-set","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"}