{"record":{"id":"13ba9ddedf8edc82","repo":"shadow1ng/fscan","slug":"s-w-webscan-afrog-format-parse-failed","errorCode":null,"errorMessage":"%s: %w (webscan_afrog_format_parse_failed)","messagePattern":"(.+?): %w \\(webscan_afrog_format_parse_failed\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"webscan/lib/poc_adapter.go","lineNumber":527,"sourceCode":"\t\tDescription string         `yaml:\"description\"`\n\t\tReference   yamlStringList `yaml:\"reference\"`\n\t\tTags        string         `yaml:\"tags\"`\n\t\tCreated     string         `yaml:\"created\"`\n\t} `yaml:\"info\"`\n\tSet        map[string]interface{} `yaml:\"set\"`\n\tRules      map[string]XrayRule    `yaml:\"rules\"` // 复用 xray 的 rule 结构\n\tExpression string                 `yaml:\"expression\"`\n}\n\n// AfrogPocAdapter afrog格式适配器\ntype AfrogPocAdapter struct {\n\t*AfrogPoc\n}\n\nfunc loadAfrogPoc(data []byte) (*AfrogPocAdapter, error) {\n\tvar poc AfrogPoc\n\tif err := yaml.Unmarshal(data, &poc); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"webscan_afrog_format_parse_failed\"), err)\n\t}\n\treturn &AfrogPocAdapter{&poc}, nil\n}\n\n// GetName 获取POC名称（优先使用Info.Name，否则使用ID）\nfunc (a *AfrogPocAdapter) GetName() string {\n\tif a.Info.Name != \"\" {\n\t\treturn a.Info.Name\n\t}\n\treturn a.ID\n}\n\n// GetFormat 获取POC格式类型\nfunc (a *AfrogPocAdapter) GetFormat() PocFormat {\n\treturn FormatAfrog\n}\n\n// ToFscanPoc 将afrog格式转换为fscan格式","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/webscan/lib/poc_adapter.go#L509-L545","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the wrapped yaml error for the exact failing line/column","Fix the YAML at that location (indentation with spaces, correct field types, quoting)","Cross-check field names against the AfrogPoc struct definition in this repo","Validate the file with a YAML linter/parser before loading"],"exampleFix":"// before: wrong type (info as string)\ninfo: \"severity high\"\n// after\ninfo:\n  severity: high","handlingStrategy":"try-catch","validationCode":"if len(data) == 0 { return errors.New(\"empty afrog POC data\") }\nif err := yaml.Unmarshal(data, &map[string]any{}); err != nil {\n    return fmt.Errorf(\"afrog POC is not valid YAML: %w\", err)\n}","typeGuard":"func looksLikeAfrogPoc(data []byte) bool {\n    var v map[string]any\n    return yaml.Unmarshal(data, &v) == nil && v != nil\n}","tryCatchPattern":"poc, err := LoadUniversalPoc(data)\nif err != nil {\n    if strings.Contains(err.Error(), \"webscan_afrog_format_parse_failed\") {\n        log.Warnf(\"bad afrog POC: %v\", err)\n        return nil\n    }\n    return err\n}","preventionTips":["Validate afrog POC YAML in CI with a linter","Match field names to the current afrog schema version","Avoid hand-editing POC YAML without re-validating","Keep POC files UTF-8, space-indented, non-empty"],"tags":["yaml","poc","afrog"],"backgroundTag":"yaml-parse-error","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"}