shadow1ng/fscan · error
portfinger_input_empty
Error message
portfinger_input_empty
What it means
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.
Source
Thrown at core/portfinger/probe_parser.go:76
}
// 设置探测器属性
p.Name = directive.DirectiveName
p.Data = strings.Split(directive.DirectiveStr, directive.Delimiter)[0]
p.Protocol = strings.ToLower(strings.TrimSpace(proto))
return nil
}
// 从字符串解析探测器信息
func (p *Probe) fromString(data string) error {
var err error
// 预处理数据
data = strings.TrimSpace(data)
lines := strings.Split(data, "\n")
if len(lines) == 0 {
return fmt.Errorf("%s", i18n.GetText("portfinger_input_empty"))
}
probeStr := lines[0]
if err := p.parseProbeInfo(probeStr); err != nil {
return err
}
// 解析匹配规则和其他配置
var matchs []Match
for _, line := range lines {
switch {
case strings.HasPrefix(line, "match "):
match, matchErr := p.getMatch(line)
if matchErr != nil {
continue
}
matchs = append(matchs, match)
View on GitHub (pinned to 95cc12e753)
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.
Example fix
// before
p, err := parser.FromString(probeFileContent)
// after
if strings.TrimSpace(probeFileContent) == "" {
return fmt.Errorf("probe file is empty")
}
p, err := parser.FromString(probeFileContent) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(probeData) == "" {
return errors.New("probe input is empty")
} Try / catch
probe, err := parser.FromString(data)
if err != nil {
if strings.Contains(err.Error(), "input_empty") {
return nil // nothing to parse; not fatal
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- portfinger_probe_name_invalid
- portfinger_probe_file_empty
- portfinger_probe_exclude_duplicate
- Parse error: first line must start with "Probe " or "Exclude
- parser_cidr_failed: %w
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/f6908240ed882120.
Report an issue: GitHub.