{"record":{"id":"f6908240ed882120","repo":"shadow1ng/fscan","slug":"portfinger-input-empty","errorCode":null,"errorMessage":"portfinger_input_empty","messagePattern":"portfinger_input_empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/portfinger/probe_parser.go","lineNumber":76,"sourceCode":"\t}\n\n\t// 设置探测器属性\n\tp.Name = directive.DirectiveName\n\tp.Data = strings.Split(directive.DirectiveStr, directive.Delimiter)[0]\n\tp.Protocol = strings.ToLower(strings.TrimSpace(proto))\n\n\treturn nil\n}\n\n// 从字符串解析探测器信息\nfunc (p *Probe) fromString(data string) error {\n\tvar err error\n\n\t// 预处理数据\n\tdata = strings.TrimSpace(data)\n\tlines := strings.Split(data, \"\\n\")\n\tif len(lines) == 0 {\n\t\treturn fmt.Errorf(\"%s\", i18n.GetText(\"portfinger_input_empty\"))\n\t}\n\n\tprobeStr := lines[0]\n\tif err := p.parseProbeInfo(probeStr); err != nil {\n\t\treturn err\n\t}\n\n\t// 解析匹配规则和其他配置\n\tvar matchs []Match\n\tfor _, line := range lines {\n\t\tswitch {\n\t\tcase strings.HasPrefix(line, \"match \"):\n\t\t\tmatch, matchErr := p.getMatch(line)\n\t\t\tif matchErr != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmatchs = append(matchs, match)\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/core/portfinger/probe_parser.go#L58-L94","documentation":"fromString trims the input and splits it into lines; if there are no lines at all to process it reports that the input is empty. In practice strings.Split never returns an empty slice, so this is a defensive guard against blank input being handed to probe parsing.","triggerScenarios":"Calling fromString with an empty or whitespace-only string, e.g. when a probe file is empty, read failed silently, or all content was trimmed away.","commonSituations":"Empty probe database files, reading a file with only blank lines, a configuration pointing at an empty/placeholder file, or passing an uninitialized string variable.","solutions":["Check that the probe file exists, is readable, and has non-blank content before calling fromString/Init.","Trim/validate the input string in the caller and skip parsing when it is empty.","Log or handle the empty-file case explicitly in Init instead of letting it surface as a parse error.","Verify file-reading code returns real content (check bytes read) rather than swallowing read errors."],"exampleFix":"// before\np, err := parser.FromString(probeFileContent)\n// after\nif strings.TrimSpace(probeFileContent) == \"\" {\n    return fmt.Errorf(\"probe file is empty\")\n}\np, err := parser.FromString(probeFileContent)","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(probeData) == \"\" {\n    return errors.New(\"probe input is empty\")\n}","typeGuard":null,"tryCatchPattern":"probe, err := parser.FromString(data)\nif err != nil {\n    if strings.Contains(err.Error(), \"input_empty\") {\n        return nil // nothing to parse; not fatal\n    }\n    return err\n}","preventionTips":["Check file size and content before feeding to fromString","Skip blank probe files explicitly in the loader","Guard against silent read failures returning empty strings"],"tags":["portfinger","parsing","empty-input"],"backgroundTag":"empty-required-field","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"}