shadow1ng/fscan · error

%s: %w (webscan_afrog_format_parse_failed)

Error message

%s: %w (webscan_afrog_format_parse_failed)

What it means

loadAfrogPoc wraps yaml.Unmarshal errors when parsing an Afrog-format POC into AfrogPoc. Like the xray loader, the localized 'webscan_afrog_format_parse_failed' text is joined with the underlying yaml error (%w). It indicates the afrog POC data is not valid YAML or mismatches the AfrogPoc schema.

Source

Thrown at webscan/lib/poc_adapter.go:527

		Description string         `yaml:"description"`
		Reference   yamlStringList `yaml:"reference"`
		Tags        string         `yaml:"tags"`
		Created     string         `yaml:"created"`
	} `yaml:"info"`
	Set        map[string]interface{} `yaml:"set"`
	Rules      map[string]XrayRule    `yaml:"rules"` // 复用 xray 的 rule 结构
	Expression string                 `yaml:"expression"`
}

// AfrogPocAdapter afrog格式适配器
type AfrogPocAdapter struct {
	*AfrogPoc
}

func loadAfrogPoc(data []byte) (*AfrogPocAdapter, error) {
	var poc AfrogPoc
	if err := yaml.Unmarshal(data, &poc); err != nil {
		return nil, fmt.Errorf("%s: %w", i18n.GetText("webscan_afrog_format_parse_failed"), err)
	}
	return &AfrogPocAdapter{&poc}, nil
}

// GetName 获取POC名称(优先使用Info.Name,否则使用ID)
func (a *AfrogPocAdapter) GetName() string {
	if a.Info.Name != "" {
		return a.Info.Name
	}
	return a.ID
}

// GetFormat 获取POC格式类型
func (a *AfrogPocAdapter) GetFormat() PocFormat {
	return FormatAfrog
}

// ToFscanPoc 将afrog格式转换为fscan格式

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Read the wrapped yaml error for the exact failing line/column
  2. Fix the YAML at that location (indentation with spaces, correct field types, quoting)
  3. Cross-check field names against the AfrogPoc struct definition in this repo
  4. Validate the file with a YAML linter/parser before loading

Example fix

// before: wrong type (info as string)
info: "severity high"
// after
info:
  severity: high
Defensive patterns

Strategy: try-catch

Validate before calling

if len(data) == 0 { return errors.New("empty afrog POC data") }
if err := yaml.Unmarshal(data, &map[string]any{}); err != nil {
    return fmt.Errorf("afrog POC is not valid YAML: %w", err)
}

Type guard

func looksLikeAfrogPoc(data []byte) bool {
    var v map[string]any
    return yaml.Unmarshal(data, &v) == nil && v != nil
}

Try / catch

poc, err := LoadUniversalPoc(data)
if err != nil {
    if strings.Contains(err.Error(), "webscan_afrog_format_parse_failed") {
        log.Warnf("bad afrog POC: %v", err)
        return nil
    }
    return err
}

Prevention

When it happens

Trigger: Calling LoadUniversalPoc with afrog-format POC bytes that yaml.Unmarshal cannot decode into AfrogPoc — syntax errors, wrong types for set/list fields, or unknown structure.

Common situations: Afrog POC files copied from older afrog versions whose schema changed (renamed fields); hand-edited YAML with tabs or bad indentation; truncated or empty POC file; non-UTF8 encoding.

Related errors


AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06). Data as JSON: /api/errors/13ba9ddedf8edc82. Report an issue: GitHub.