{"record":{"id":"63a96c127cba3c0a","repo":"shadow1ng/fscan","slug":"webscan-rulemap-key-invalid","errorCode":"webscan_rulemap_key_invalid","errorMessage":"webscan_rulemap_key_invalid","messagePattern":"webscan_rulemap_key_invalid","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"webscan/lib/Client.go","lineNumber":338,"sourceCode":"//   - error: 解析错误\nfunc (r *RuleMap) UnmarshalYAML(unmarshal func(interface{}) error) error {\n\t// 使用MapSlice保持键的顺序\n\tvar tmp1 yaml.MapSlice\n\tif err := unmarshal(&tmp1); err != nil {\n\t\treturn err\n\t}\n\n\t// 解析规则内容\n\tvar tmp = make(map[string][]Rules)\n\tif err := unmarshal(&tmp); err != nil {\n\t\treturn err\n\t}\n\n\t// 按顺序转换为RuleMap结构\n\tfor _, one := range tmp1 {\n\t\tkey, ok := one.Key.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s\", i18n.GetText(\"webscan_rulemap_key_invalid\"))\n\t\t}\n\t\tvalue := tmp[key]\n\t\t*r = append(*r, RuleItem{key, value})\n\t}\n\treturn nil\n}\n\n// UnmarshalYAML 实现ListMap的YAML解析接口\n// 参数：\n//   - unmarshal: YAML解析函数\n//\n// 返回：\n//   - error: 解析错误\nfunc (r *ListMap) UnmarshalYAML(unmarshal func(interface{}) error) error {\n\t// 解析YAML映射\n\tvar tmp yaml.MapSlice\n\tif err := unmarshal(&tmp); err != nil {\n\t\treturn err","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/webscan/lib/Client.go#L320-L356","documentation":"Guard in RuleMap.UnmarshalYAML: a key in the ordered YAML mapping could not be asserted to string (non-scalar or complex key). The rule map requires string keys mapping to rule lists, so decoding fails on the offending entry.","triggerScenarios":"Thrown at webscan/lib/Client.go:338 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure all keys in the rules map are plain strings","Remove YAML complex keys (e.g. sequences as keys)","Fix or drop the malformed POC rule file"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}