{"record":{"id":"f1c6ccc48f6c7708","repo":"shadow1ng/fscan","slug":"failed-to-write-header-information-w","errorCode":null,"errorMessage":"Failed to write header information: %w","messagePattern":"Failed to write header information: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/local/keylogger.go","lineNumber":185,"sourceCode":"\t\tsession.LogInfo(i18n.GetText(\"keylogger_no_input\"))\n\t\treturn nil\n\t}\n\n\tfile, err := os.OpenFile(outputFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600)\n\tif err != nil {\n\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","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/local/keylogger.go#L167-L203","documentation":"Wrap of a write failure in saveKeysToFile: after successfully opening the keylogger output file, writing the buffered header block (banner, start time, platform, event count) to it failed. The %w carries the underlying file-write error (e.g. disk full or closed file); the original os.OpenFile failure is reported by a separate error.","triggerScenarios":"Thrown at plugins/local/keylogger.go:185 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and quotas on the output volume","Retry the save; keystrokes remain in the in-memory buffer until flushed","Write to a different location if the volume is failing"],"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-14T00:17:10.932Z"}