{"record":{"id":"7e901c494cbf769f","repo":"shadow1ng/fscan","slug":"s-w-keylogger-entry-write-failed","errorCode":null,"errorMessage":"%s: %w [keylogger_entry_write_failed]","messagePattern":"(.+?): %w \\[keylogger_entry_write_failed\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/local/keylogger.go","lineNumber":191,"sourceCode":"\t\treturn fmt.Errorf(\"%s: %w\", i18n.GetText(\"output_file_open_failed\"), err)\n\t}\n\tdefer func() { _ = file.Close() }()\n\n\t// 写入头部信息\n\theader := i18n.GetText(\"keylogger_log_header\") + \"\\n\"\n\theader += i18n.Tr(\"local_start_time\", time.Now().Format(\"2006-01-02 15:04:05\")) + \"\\n\"\n\theader += i18n.Tr(\"local_platform\", runtime.GOOS) + \"\\n\"\n\theader += i18n.Tr(\"keylogger_event_count\", len(p.keyBuffer)) + \"\\n\"\n\theader += \"========================\\n\\n\"\n\n\tif _, err := file.WriteString(header); err != nil {\n\t\treturn fmt.Errorf(\"%s: %w\", i18n.GetText(\"keylogger_header_write_failed\"), err)\n\t}\n\n\t// 写入键盘记录\n\tfor _, entry := range p.keyBuffer {\n\t\tif _, err := file.WriteString(entry + \"\\n\"); err != nil {\n\t\t\treturn fmt.Errorf(\"%s: %w\", i18n.GetText(\"keylogger_entry_write_failed\"), err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// 平台特定的键盘记录实现 - 简化版本，仅做演示\nfunc (p *KeyloggerPlugin) startWindowsKeylogging(ctx context.Context) error {\n\t// Windows平台键盘记录实现\n\t// 在实际实现中需要使用Windows API\n\tp.addKeyToBuffer(i18n.GetText(\"keylogger_demo_windows\"))\n\n\t// 模拟记录一段时间\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tcase <-time.After(5 * time.Second):\n\t\t// 模拟结束","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/local/keylogger.go#L173-L209","documentation":"Raised in saveKeysToFile when writing one buffered keystroke entry to the file fails; the localized 'keylogger_write_failed'-style message wraps the I/O error and the bracketed marker keylogger_entry_write_failed identifies the stage.","triggerScenarios":"Thrown at plugins/local/keylogger.go:191 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and file permissions","Retry the save — the buffer is only cleared after successful persistence","Move the output to a healthy filesystem"],"exampleFix":null,"handlingStrategy":"retry","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"}